PyCall.jl
PyCall.jl copied to clipboard
Set environment variables without package rebuild?
I have the following in my deps/build.jl file:
using PyCall
PyCall.Conda.add("wfdb")
And inside module:
module MyPackage
const WFDB = PyNULL()
function __init__()
copy!(WFDB, pyimport("wfdb"))
end
end # module
But this doesn't work on Linux, because there are different paths for PyCall.libpython and PyCall.Conda.PYTHONDIR.
As explained in the PyCall documentation, I should set ENV["PYTHON"]="", run Pkg.build("PyCall"), and re-launch Julia.
So, in GH Actions I've added a custom run command for MyPackage:
- name: "Set up Julia"
uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
arch: ${{ matrix.julia-arch }}
- uses: julia-actions/julia-buildpkg@v1
- run: julia --project=@. -e 'import Pkg; ENV["PYTHON"]=""; Pkg.add("PyCall"); Pkg.build("PyCall")'
- uses: julia-actions/julia-runtest@v1
But it breaks again in GH Actions for other packages, if they have MyPackage as a dependency.
So, should I really repeat this custom run command to all other packages that rely on MyPackage?
Or maybe I can somehow add scripts in my package, that will be run before build?