not sure if it’s the right place for such a question. Feel free to say so if I should ask elsewhere!
In my package (ClimateTools.jl) I use some Python dependencies that are used mostly for mapping purpose. Right now, one of the dependency is somewhat tricky to install (basemap does not install on Python 3.6 for instance).
I’m wondering how I could set up TravisCI to
create a virtual env, installing the proper versions of the packages and a specific python version
in Julia, install PyCall, set-up ENV["PYTHON"]="virtualenv python"; Pkg.build("PyCall")
Step #2 is OK on my side, I already do it in my .travis file, but I can get the syntax right for the first step.
If you put setups in .travis.yml, you’ll have trouble with CIBot when registering the package (see The current METADATA release process). Maybe put something like this in your deps/build.jl (untested):
using Pkg
if lowercase(get(ENV, "CI", "false")) == "true"
let basepython = get(ENV, "PYTHON", "python")
envpath = joinpath(@__DIR__, "env")
run(`virtualenv --python=$basepython $envpath`)
if Sys.iswindows()
python = joinpath(envpath, "Scripts", "python.exe")
else
python = joinpath(envpath, "bin", "python")
end
run(`$python -m pip install basemap`)
ENV["PYTHON"] = python
Pkg.build("PyCall")
end
end
It’s a bit ugly to build PyCall again in your build process, but you can’t avoid it if you want to change Python path.
For reference, here’s what I did. It works on TravisCI but not JuliaCI though. I guess it’s because the if lowercase(get(ENV, "CI", "false")) == "true" evaluate to false on JuliaCI?
┌ Error: Error building `ClimateTools`:
│ ERROR: LoadError: IOError: could not spawn `virtualenv --python=python2 /home/jrun/ClimateTools/.julia/packages/ClimateTools/KQv9Y/deps/env`: no such file or directory (ENOENT)
Maybe you can run pip install --user virtualenv first. Or alternatively just use pip in user mdoe, i.e., run(`$basepython -m pip --user install numpy`) etc.