[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Distribute "data files" with a package

From: Sergei Steshenko
Subject: Re: Distribute "data files" with a package
Date: Mon, 31 Mar 2014 07:07:54 -0700 (PDT)

----- Original Message -----
> From: Daniel Kraft <address@hidden>
> To: Octave User <address@hidden>
> Cc: 
> Sent: Monday, March 31, 2014 2:41 PM
> Subject: Distribute "data files" with a package
> Hi!
> I'm currently working on an Octave package, and want to distribute
> certain "data files" with it.  (In my particular case, it is an image
> file to be used by one of the package's "demo" functions.)
> When I include the file in the package's "inst/" directory, it 
> gets
> installed correctly to the package installation folder.  However, now
> I'm wondering how I can access it from within a demo function.  I tried
> without an explicit directory specification, but that fails (since it
> looks in the current working directory as opposed to the .m file's
> directory).
> This must be something others have already stumbled upon -- how can one
> access such "data files" distributed with a package?  Is there a
> function that can be called from within an .m file and that returns the
> directory that contains the .m file?
> The best I could find so far is "pkg list", and then sifting through 
> the
> list of packages looking for my package's name and then using the
> installation directory.  But that seems to be too complicated for such a
> "seemingly easy" task.  Is there no better way to query for the
> installation directory of a particular package, for instance?  Or even
> of "this package" from within a package's functions?
> Thanks!  Yours,
> Daniel
> -- 
> OpenPGP: 901C 5216 0537 1D2A F071  5A0E 4D94 6EED 04F7 CF52
> Namecoin: id/domob ->
> --
> Done:  Arc-Bar-Cav-Hea-Kni-Ran-Rog-Sam-Tou-Val-Wiz
> To go: Mon-Pri

Well, Octave packaging needs to redefined and redone from scratch.

Anyway, since functions work, and since in functional paradigm everything, 
including constants, is a function, you can probably solve your problem 
wrapping your data in a function.

I.e. something like this:

my_data = function get_my_data()
  my_data = [1, 2, 3 ...]; # this line should be autogenerated based on real 

Then you can call get_my_data(), created a file in CWD and use the file for 
your demo.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]