JuliaPy / PyCall.jl

Package to call Python functions from the Julia language
MIT License
1.46k stars 187 forks source link

check whether numpy is installed before running Conda.add during build #940

Open alhirzel opened 2 years ago

alhirzel commented 2 years ago

Currently, there is a call to Conda.add("numpy"):

https://github.com/JuliaPy/PyCall.jl/blob/3c66d9ea6d6c2166e11dece15b12335c24648e59/deps/build.jl#L78-L80

This call should be redundant per README:

https://github.com/JuliaPy/PyCall.jl/blob/3c66d9ea6d6c2166e11dece15b12335c24648e59/README.md#L253

I suggest this call be removed, eliminating the need to access the internet when using PyCall.jl. This is an important use case in some environments.

This has also come up in #742.

stevengj commented 2 years ago

It doesn't require the internet. You can build PyCall to use a local, pre-installed Python distribution by setting the PYTHON environment variable.

Moreover, this is about building — i.e. installing — PyCall. (It's possible to install Julia packages without Internet access, but quite annoying.) Even if it was built with the Conda Python, PyCall doesn't require Internet access to use it.

alhirzel commented 2 years ago

Hey @stevengj, you're right--I shouldn't have said "to use" PyCall, I should have said to build it. Subsequent ]builds of PyCall will still hit the Conda.add. I think it may be better to check if numpy is installed rather than unconditionally installing it. This enables one to generate a deployment environment that can ]build in-place.

stevengj commented 2 years ago

I see. Yes, it seems straightforward to check whether conda list includes numpy before adding.

Maximka-hue commented 1 year ago

Yes, i had fixed in the following way: have a try to do as @stevengj suggested, install numpy, then have a collision with package mkl at path ../.julia/3/pkgs/mkl***, deleted that directory and retry download, then after had successfully downloaded numpy, built PyCall with using Pkg;Pkg.build("PyCall"))

amnesia42 commented 11 months ago

I encountered the problem of PyCall building error and track this post. Although I am not sure how it works behind the surface, I am also sharing my experiences here.