PythonCall.jl icon indicating copy to clipboard operation
PythonCall.jl copied to clipboard

Turn off conda initialization during incremental compilation?

Open marius311 opened this issue 2 years ago • 3 comments

If you have a using PythonCall inside your package "Foo", then just precompiling Foo will trigger creation of the PythonCall's Conda environment, downloading of packages, etc...

IMO this is undesired. I know there's environment variables to prevent this, but while I remember to set them when actually running a program, its very often I forget during precompilation, especially since precompilation automatically gets triggered at various times (when instantiating, upgrading, etc...)

Wondering if it makes sense to turn that off during precompilation entirely with a check to ccall(:jl_generating_output, Cint, ())? It would mean Python wouldn't be available to any dependent packages during precompilation either, but perhaps thats a better behavior? I don't have the strongest feelings one way or the either, probably leaning slightly that it'd be nicer to make this change, but just wanted to point out.

marius311 avatar Apr 22 '23 21:04 marius311

I agree it would be nice, and I've wondered the same in the past.

However, suppose that Foo does something Pythonic in its __init__ function (e.g. imports a Python module). Now suppose that Bar is another package which depends on Foo. Then to precompile Bar you need to import Foo, which calls Foo.__init__(), which imports a Python module, which requires your Python dependencies to be installed.

So in the current set-up, I don't think this is possible.

Perhaps I could disallow doing anything Pythonic during module init, but I don't think that's a good idea. Ideas welcome!

cjdoris avatar Apr 24 '23 15:04 cjdoris

This issue has been marked as stale because it has been open for 30 days with no activity. If the issue is still relevant then please leave a comment, or else it will be closed in 7 days.

github-actions[bot] avatar Aug 21 '23 01:08 github-actions[bot]

This issue has been closed because it has been stale for 7 days. You can re-open it if it is still relevant.

github-actions[bot] avatar Aug 28 '23 01:08 github-actions[bot]