JuliaPy / pyjuliapkg

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

fix `JULIA_PROJECT=@.` logic #7

Closed marius311 closed 2 years ago

marius311 commented 2 years ago

Previously the break only broke out of the for loop but guessing you intended it to break out of both loops. This achieves I think the intended logic instead. Note also that if we don't find anything, the thing to do would be to default to the v#.# environment, at least thats what Julia itself does. I left that in as a comment but I'm not sure how to best do that.

cjdoris commented 2 years ago

Thanks for the PR, but it has reminded me that I was intending to remove this functionality. The issue is that JuliaPkg "owns" the project it uses, so will clobber anything the user has put there, which is not the desired behaviour for JULIA_PROJECT.

I'll probably replace it with PYTHON_JULIAPKG_PROJECT for those who want to configure it, but it will take an explicit path.

Any thoughts?

marius311 commented 2 years ago

What would be the relation between JULIA_PROJECT, JULIA_PYTHONCALL_PROJECT, and PYTHON_JULIAPKG_PROJECT? In any case, as long as there were an easy way to make it so I can specify an existing Julia project to use when calling from Python, that's all I'd need. I would find it nicer if that could be done like @. but explicit path would be ok too

cjdoris commented 2 years ago

JULIA_PYTHONCALL_PROJECT isn't a thing.

With this change, JULIA_PROJECT will be ignored when using JuliaPkg. Instead the project will be PYTHON_JULIAPKG_PROJECT or a default env-specific place.

I've implemented this on main now btw.

marius311 commented 2 years ago

It is here but maybe I misunderstood it as a user rather than internal API since JULIA_PYTHONCALL_EXE is meant for the user.

Does JuliaPkg have to clobber the project? My use case (which I'd guess is not atypical) is I have an existing Julia environment (so I don't need juliapkg/juliacall to install any Julia packages for me) and I want to run some Julia code in that environment as called from Python via juliacall. Is that not possible without clobbering the environment? For this use-case, it would also be quite useful if juliacall obeyed JULIA_PROJECT=@. since I basically want the same behavior as if I ran Julia natively in that folder, just that I'm calling from Python.

cjdoris commented 2 years ago

Ah yes, that's internal (it isn't documented after all). I could change the name to make that clearer.

That's a perfectly reasonable use-case. Right now, you can set PYTHON_JULIAPKG_OFFLINE=yes and it will not touch the project it is using.

(Except that these lines will overwrite Project.toml, which is a bug, they need to be moved into the block below.)

So I guess we could use JULIA_PROJECT if we are in offline mode and PYTHON_JULIAPKG_PROJECT is not set. I'm not sure this is a great idea though, because someone may enable offline mode just because their internet is down, but they want to keep using the project already created by JuliaPkg.

Maybe another mode, which is the same as offline mode but it also observes JULIA_PROJECT. I'm not sure what it would be called. PYTHON_JULIAPKG_LOCAL=yes?

cjdoris commented 2 years ago

PYTHON_JULIAPKG_NOCLOBBER?