JuliaPy / pyjuliapkg

Manage your Julia dependencies from Python
MIT License
45 stars 12 forks source link

CONDA_PREFIX overriding JULIA_DEPOT_PATH #12

Closed oschulz closed 1 year ago

oschulz commented 1 year ago

Currently, $CONDA_PREFIX (and $VIRTUAL_ENV) overrides ignores $JULIA_DEPOT_PATH. This is a problem in scenarios where (Ana)conda is installed in a read-only location, like an Apptainer/Shifter container or a shared storage location on a larger multi-user compute system/cluster. Since $JULIA_DEPOT_PATH gets ignored, the user runs into trouble like this

[...]
[juliapkg] Using Julia project at /opt/anaconda3/julia_env
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/user/.local/lib/python3.9/site-packages/juliapkg/deps.py", line 278, in project
    resolve()
  File "/user/.local/lib/python3.9/site-packages/juliapkg/deps.py", line 233, in resolve
    os.makedirs(project, exist_ok=True)
  File "/opt/anaconda3/lib/python3.9/os.py", line 225, in makedirs
    mkdir(name, mode)
OSError: [Errno 30] Read-only file system: '/opt/anaconda3/julia_env'

Could we change the resolution mechanism so that $JULIA_DEPOT_PATH takes priority over $CONDA_PREFIX (and ideally $VIRTUAL_ENV as well)?

cjdoris commented 1 year ago

Your issue is nothing to do with JULIA_DEPOT_PATH, which is not modified by this package. The location of Julia projects is unrelated to the depot unless you are using a default/shared/temporary project, but this package explicitly sets the project to be inside your Python environment.

So your issue really is that this package assumes your Python environment is writeable, which it is not in your case. A couple of workarounds are (a) don't use the root conda environment (which is generally a good idea anyway) or (b) set PYTHON_JULIAPKG_PROJECT to some writable directory or (c) get the user with write permission in the root environment to also initialise JuliaPkg.

oschulz commented 1 year ago

Sorry, yes, I should have put that better, JULIA_DEPOT_PATH itself is not changed, of course. But setting PYTHON_JULIAPKG_PROJECT doesn't seem to help:

$ export PYTHON_JULIAPKG_PROJECT=/tmp/pyjlprj
$ python

>>> import juliapkg
>>> juliapkg.project()
[juliapkg] ...
...
OSError: [Errno 30] Read-only file system: '/opt/anaconda3/julia_env'
cjdoris commented 1 year ago

That shouldn't happen, I think you must be on an old version of JuliaPkg - can you update and try again please.

oschulz commented 1 year ago

I think you must be on an old version of JuliaPkg

Oh, you're right - I'm sorry, I thought I was on juliapkg v0.1.7, but something must have been mixed up with my Python paths. That why I tried the JULIA_DEPOT_PATH route in the first place, because PYTHON_JULIAPKG_PROJECT didn't seem to have any effect.

Sorry again!