Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building PyCall Offline with Mamba #1050

Closed
callous4567 opened this issue Aug 21, 2023 · 4 comments
Closed

Building PyCall Offline with Mamba #1050

callous4567 opened this issue Aug 21, 2023 · 4 comments

Comments

@callous4567
Copy link

Hello;

This is a suggestion regarding making PyCall easier to use in an offline build under a very restrictive firewall using Conda.jl. Specifically, when carrying out its build.jl here the following lines

    if use_conda
        Conda.add("numpy"; satisfied_skip_solve=true)
    end

will result in an unsightly error as Conda fails to connect to the internet to check for any versioning and so forth on Numpy. Removing these lines allow full offline build/precompile of PyCall on a pre-filled distribution of Julia (with Conda having its set of pre-installed Python packages.)

I would think it satisfactory to verify Numpy's presence with a quick check similar to PyCall.pyimport("numpy") or similar?

@stevengj
Copy link
Member

The problem is that we can't call PyCall functions (e.g. PyCall.pyexists("numpy")) in the build script.

I suppose we could check success(`$python -c "import numpy"`).

But in the circumstance you describe, shouldn't you just build PyCall with ENV["PYTHON"] = "/path/to/your/python" to tell it to use your manual offline Python installation rather than trying to install via Conda?

@callous4567
Copy link
Author

callous4567 commented Aug 22, 2023

The problem is that we can't call PyCall functions (e.g. PyCall.pyexists("numpy")) in the build script.

I suppose we could check success(`$python -c "import numpy"`).

But in the circumstance you describe, shouldn't you just build PyCall with ENV["PYTHON"] = "/path/to/your/python" to tell it to use your manual offline Python installation rather than trying to install via Conda?

I do actually have to set ENV["PYTHON"]=... when I transfer to the work VM- otherwise Julia defaults to trying to use the one in /usr/bin/... (despite being tarballed with the ENV set to the Conda interpreter.) The issue still occurred when doing this. After looking at the build.jl file, I've found the reason that this is a problem- the Python I'm using is the one that Conda comes with- this line

use_conda = dirname(python) == abspath(Conda.PYTHONDIR)

triggers the check for numpy that ruins the build process in the offline build. The manual offline Python installation I'm using is actually just the one that Conda builds up (``/home/username/.julia/conda/3/x86_64/bin) and this triggers the statement above to be true, ruining the build as Conda tries to connect to internet it has no access to.

So, to sum up- the issue here is that the manual offline installation I'm using is one that I made using Conda when it was connected to the net- taking it offline and then trying to build it will result in a fail, as Conda can no longer do all the online versioning it normally does when you call a Conda.add().

It's a very niche issue for sure- I doubt there's many people building environments to later use offline without network access, nevermind with the default Conda interpreter, so I can understand if there's nothing to be done about it- I just hope if someone else encounters it they somehow find this post.

@stevengj
Copy link
Member

stevengj commented Aug 22, 2023

Changing if use_conda to if use_conda && !success(`$python -c "import numpy"`) seems reasonable enough if you want to try it out and maybe submit a PR.

@callous4567
Copy link
Author

Aye- I'll take a look into doing this at some point in the near future :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants