Loading mat files within a package function - package

I'm working on an package for GNU Octave. One of the package functions uses a large, pre-computed table of data. That data is stored in a mat file which I load and unload when the function is called. The problem is that I'm unsure of a good, installation non-specific way of doing this. As near as I can tell I have to give the load command an absolute path to the mat file within the package install directory. I can see no way of getting that directory at run-time. Am I missing something or am I just going about this the wrong way?

PKG_ADD is executed when the package is loaded so you can get the path where PKG_ADD resides in with __fqp__ = fileparts (mfilename ("fullpath"));From there you can init your data.
If you want the install dir from another package it's possible to load( pkg ("local_list")) and inspect local_packages.
I also think such specific Octave questions should go to the help#octave.org mailinglist.
Do you want to distribute your new package on octave-forge?

Related

How to store package repository globally?

A FreeBSD update forces me to run Xmonad by cabal-install. After I run "cabal new-update"
I find that it audaciously placed a 636MB file inside the directory "~/.cabal". Having a closer look I noticed that this is the unzipped version of a .tar.gz of 85MB.
Question #1: How can I inhibit to unpack this monster?
Question #2: I am loggin in as two different users. Is there a way to install the zipfile in a global place?
Thanks in advance,
Bertram
You can't inhibit the unpacking of it. Cabal needs it to operate. That said, your solution to how to replace it with a symlink seems fine.

Submitting an R job on a linux cluster

In submitting my R job to a cluster using the Rscript myscript.R command, I keep getting an error message saying the packages I have asked to load do not exist. However I have installed these packages onto a library on my profile. Do I have to set the working directory into the same pathway as the where the R packages are contained? I am genuinely puzzled by how to fix this error.
Thanks
Nikhail
try to add directly the install.packages command in your script. Like that, you're sure it will install properly:
for example add that at the beginning of your script (of course change "pacman;" for your real package and add one line per package):
if (!require("pacman")) install.packages("pacman")
I had this kind of problem before when the shell didn't call the good R for me (other version than the one I thought or 32 bits vs 64 bits). Don't know if it's your problem however...

How to sync version numbers for nuget packages when targeting multiple project files

I have a project which has three project files targeting various .net versions (mylib.net20.csproj, mylib.net40.csproj, and mylib.net40-client.csproj). I have a single nuspec file named mylib.nuspec for packaging them all together.
It might help to see the files section of the nuspec file, so here it is:
<files>
<file src="bin\net20\*.dll" target="lib\net20\" />
<file src="bin\net40-client\*.dll" target="lib\net40-client\" />
<file src="bin\net40\*.dll" target="lib\net40\" />
</files>
Right now I use a static version number in the nuspec file and I can successfully package everything by running nuget pack mylib.nuspec. However, I would like to start using $version$ so I don't have to remember to update the version number in two places.
If I simply change the version number to $version$, and build in the same way I get the predictable error:
Attempting to build package from 'mylib.nuspec'.
The replacement token 'version' has no value.
If I use $version$ and package with nuget pack mylib.net40.csproj, it is successful, but I get a package that completely ignores the nuspec file.
Q: What can I do to get the $version$ variable to work?
Technically, I could rename my nuspec file to mylib.net20.nuspec and then package with nuget pack mylib.net20.nuspec. I really don't want to rename my nuspec file in this way though.
creating a package can be done two ways
Using nuspec directly
Using your csproj file , which in fact uses your nuspec file at run time.
First case is pretty straight forward where all metadata defined in nuspec file will be considered for package creation.
nuget pack nuspecfilename.nuspec
On executing above command all hard coded values in your nuspec file will be used for package creation
Above Procedure uses nuspec file directly.
Now let come to your requirement , Using token $version$ in your nuspec files.
In order to work with tokens rather than hard coded values , we need to use csproj file while running nuget pack command.
nuget pack nameofyourprojectfile.csproj -p "configuration=Release;platform=x64"
I'll explain the command i have used ,the concept of using csproj file while generating a package is it will replace all tokens in nuspec file at the run time.
Your corresponding assembly info file to your csproj file will contain required metadata of version which will be replaced at run time.
-p is parameters to be used at run time , here i have assumed that my proj file builds in release and x64 platform so i have passed that at run time so nuget which for artifacts to bundle accordingly.
please refer Here for more details on how to create nuget packages from csproj.
But Ideally when you package from csproj file your nuspec file will be used at run time so ,technically nuspec file should have same name as that of your csproj file.
so requirement of dealing with multiple project files with different frame work may not be achieved with single nuspec file. you need to have individual nuspec accordingly to achieve this.
But if you still want to stick with same nuspec file with out renaming it or making changes to it.
i would suggest passing version at run time
nuget pack nameofnuspec.nuspec -v 1.3.4.5
-v - is version , or you can use -version as well followed by the version of your choice.
after running above command nuget package will be created with the version specified.
to check nuget package created , rename it .zip file and check ...)

How do I compile/build against Ocamlodbc

I've installed Ocamlodbc using opam install odbc, but I can't work out how to build an app that uses it with ocamlbuild. The examples that come with the source don't build either.
If I put
#require "odbc";;
into my .ocamlinit, I can open Odbc_unixodbc;; in utop, but any reference to functions in that module result in a "Reference to undefined global 'Odbc_unixodbc'" error.
The following snippet also fails with an error about no implementation for "Odbc_unixodbc"
open Odbc_unixodbc
let () = ignore (Odbc_unixodbc.connect "DSN" "UID" "PWD")
Trying
open Odbc
fails with "Unbound module Odbc"
I'm building the code with
ocamlbuild -pkg odbc test.native
The generated documentation for the package seem to suggest I should be opening the "Ocamlodbc" module, but that also results in an "Unbound module" error.
TL;DR
ocamlbuild -use-ocamlfind -pkg odbc test.native
Description
-use-ocamlfind tells ocamlbuild to use ocamlfind system to find libraries on your system. Otherwise, without this flag, you need to provide flags with concrete locations and also take care of the package dependencies. So, it is a good idea to always use ocamlfind.
If this command still doesn't work for you, then make sure, that you chose the right package name. You can use ocamlfind list to look at the set of all packages available on your system.
Further reading
While the above is ok for small programs, I would suggest to use OASIS system to handle all the flags for you.
You can start from this example, adapting dependency list to your neeeds.

Install Packages (for dummies)

I know there's a lot of information on here about installing python packages, but I'm quite new to python and I think I need a more "for dummies" level of help.
I was trying to install openpyxl for which as far as I can tell I need easy_install, for which, as far as I can tell, I need setuptools. I tried running the code provided here https://pypi.python.org/pypi/setuptools which is supposed to download and install setuptools (and according to some sites, easy_install aswell?) - it runs successfully, but help(modules) doesn't show setuptools or easy_install as modules, I have no idea whats installed and what isn't, or how I'm supposed to install any of it!
Essentially I'm very confused, very frustrated and really need someone to talk me through (in idiot-speak) what I'm supposed to do.
Thankyou!
We all start somewhere, I was there two weeks ago.
I'll assume you're using Python2. I believe Distribute and Pip are recommended for Python3 (which I will be using as examples). I will also assume you are on Windows.
First, python needs to be registered to Path. To check if this has been done automatically, open a command prompt (start -> programs -> accessories), and type 'python', then enter. If it returns the version number, etc, skip down a bit. If it throws an error, you need to add Python to Path.
Adding Python to Path
To add Python to Path on a Windows computer, go to:
Control Panel -> System -> Advanced Settings -> Environment Settings -> System Variables
Scroll down to select path, then click edit. Copy the entire line to a text document, and add your install directory for Python.exe (and the scripts folder) using ';' as a delimiter between different directories. Copy this back to Path and save. (Additionally close your command prompt window to reset it.)
For my Windows 7 machine, I added:
;C:\Python33;C:\Python33\scripts;
Take care when editing this file. There are many videos out there describing this in detail if you feel unsure about changing this.
Installing Modules (Such as setup_tools)
Once Python is registered in the Path file, download and unzip setup_tools to a folder within your Python install directory called 'modules'. I use ExtractNow to unzip, as it will unzip twice (as required) automatically.
Open a command prompt window again, and direct it to change directories by typing
cd [directory for module you want to install]
On my computer, this would be
cd C:\Python33\modules\distribute-0.6.40
Again, I use distribute, rather than setup_tools as it sounds like you need would for Python2. Simply use the appropriate directory. Press enter to change the directory.
Once you've entered this and it shows a changed directory, type:
python setup.py install
This indicates that you want to use the program python to use the setup.py file in the specified folder to install the module. This should be successful, and will write many lines of code.
If you want to install other modules, you would install them in a similar way. Python would automatically use setup_tools on your computer to finish each install.
Remember to import at the start of your script when using them to code:
import [module]
Happy Programming!

Resources