JuliaPy / PythonCall.jl

Python and Julia in harmony.
https://juliapy.github.io/PythonCall.jl/stable/
MIT License
776 stars 63 forks source link

Respect JULIA_PROJECT environment variable if set #426

Open schlichtanders opened 10 months ago

schlichtanders commented 10 months ago

I am using the python package juliacall and am surprised to find that it ignores JULIA_PROJECT environment variable. Julia documentation about JULIA_PROJECT.

It would be great if this standard variable is respected. Currently juliacall opens a new julia environment pyjuliapkg

schlichtanders commented 10 months ago

It seems related to https://github.com/JuliaPy/PyJuliaPkg in that a workaround could be to set PYTHON_JULIAPKG_PROJECT

EDIT: This is not working because of this related bug https://github.com/JuliaPy/pyjuliapkg/issues/15 - PyJuliaPkg will simply delete the entire project folder. There is no workaround for this behaviour currently.

schlichtanders commented 10 months ago

It seems there is not a single workaround to start JuliaCall in a predefined environment. Respecting the environment variable JULIA_PROJECT could be a good way to add this feature.

schlichtanders commented 10 months ago

PythonCall already sets up a pseudo juliacall package when plainly run from julia.

Maybe this already existing mechanism could be reused to start juliacall in an existing environment.

cjdoris commented 10 months ago

Ignoring JULIA_PROJECT is intended. You can set PYTHON_JULIAPKG_PROJECT and PYTHON_JULIAPKG_OFFLINE=yes to get the behaviour you want, I think?

schlichtanders commented 10 months ago

Thank you for reminding me that both variables need to be set. For me, coming from julia, it is very unintuitive to set two environment variables in order to get an Julia environment to work.

My tests where successful, it worked. Thank you.


What about translating the JULIA_PROJECT environment variable automatically to those two PYTHON_JULIAPKG environment variables?