New Pkg: Immediate Compile and Version Variable?


#1

I am beginning to use Julia 1.0. Pkg.dir() no longer seems to work (and has no docs). What has replaced it? Pkg.status() works differently. Alas, these are just minor questions. I have a reason for posting to development"

  1. Should the default on Pkg.add() be to do the first-time compilation right away, too? Who would want to add a package and not run it? Is there a reason?

  2. Do packages have a variable that tells the package manager whether they have been ported/tested on a particular julia version? (This is not just a minimum Julia version.) I am asking because Glob and TimeSeries have a successful Pkg.add(), but both flunk on first-time compilation (and I have a fresh julia 1.0). So I am wondering whether these two packages [as examples] have made the jump from 0.6 to 1.0. if they have, then not very successfully so. if they have not, then the Pkg.add() should have told me this.


#2

In 99.5% of cases you can replace it with @__DIR__ usage. Otherwise there is Base.pathof.

If you plan to add an extra package after it might be that you need to recompile anyway, so you do double work.

No, and in theory/in the future the package manager should not install packages, unless the package declares that it works. For example, when Julia v2.0 is released, packages that don’t explicitly support this will not be installable. See https://docs.julialang.org/en/latest/stdlib/Pkg/#Compatibility-1


#3

@__DIR__ just gives the cwd for me. It does not tell me where the (local) packages for this version are installed for me. can you please give an example of Base.pathof() usage?


#4

You should use this in the file which need to reach into the package.

using Example
Base.pathof(Example)

but again, try to use @__DIR__.


#5

still can’t figure out how to obtain the version number of a package.

julia> using DataFrames

julia> Base.pathof(DataFrames)
"/Users/me/.julia/packages/DataFrames/utxEh/src/DataFrames.jl"

I need something like 0.11.3. I tried to

# grep -R -i version /Users/ivo/.julia/packages/DataFrames/utxEh/src/

to see if I could find a version string in a place, but failed.

On reflection, it would make sense to make an immediate compilation the default for Pkg.add(), especially in the REPL; but an optional keyword can suppress it .


#6

A version number, of there is one, is recorded in the manifest file. You can also call Pkg.installed().


#7

Doesn’t Pkg.status() tell you this?


#8

Stefan, David—can you please give a simple use example?


#9

I think the request is for a snippet that, from within another package, obtains the version number of some specific installed package (or nothing if not installed).


#10

I’m no expert… but will the following code do the trick?

julia> using Pkg;
julia> Installed = Pkg.installed();
julia> Installed["PyPlot"]
v"2.6.0"

The response of Pkg.installed() is a dictionary. I guess if you use a key that doesn’t exist in your dictionary, there will be an error message.

Of course, you can then test the version:

julia> Installed["PyPlot"] < v"2.7"
true

#11

thanks. I tried it on other computers, and I must have done something wrong. how odd. now it works.