octave-maintainers
[Top][All Lists]
Advanced

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

Re: path for an installed package


From: David Pinto
Subject: Re: path for an installed package
Date: Wed, 15 Oct 2014 15:55:27 +0100

On 15 October 2014 11:13, Colin Macdonald <address@hidden> wrote:
> Hi,
>
> How can I find the "base directory" where my package is installed?
> E.g., on my system, "pkg install" puts my package in
> /home/cbm/octave/octsympy-0.1.0).  How can I find that path?
>
> This looks promising:
>
>>> pfx = pkg ("prefix")
>
> Should I find it myself with "dir"?  Search "path"?  Some secret "pkg"
> command?  Hoping its the last one!

There is no easy way to do this. At the moment the best way is to use
'pkg describe', filter your package from the cell array, and use its 'dir'
field.  The difficulty here is that "describe" (and "list"), returns a cell
array rather than a struct array [1] (I guess because different packages
can have arbitrary fields on their DESCRIPTION files) but I hope that will
change in the future (don't wait for it though).

Here's how to do it:

  pkg_l = pkg ("list");
  idx = strcmp (your_pkg, cellfun (@(x) x.name, pkg_l, "UniformOutput", false));
  if (! any (idx))
    error ("the package %s is not installed", your_pkg);
  endif
  pkg_path = pkg_l{idx}.dir

[1] 
http://octave.1599824.n4.nabble.com/Re-struct-array-output-from-pkg-td4666848.html



reply via email to

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