cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
4.5k stars 339 forks source link

python: remove `LD_LIBRARY_PATH` hack from running python environment #1562

Open vlaci opened 3 weeks ago

vlaci commented 3 weeks ago

Injecting LD_LIBRARY_PATH to the Python runtime environment is great to bypass the need of having to patch non-nix binaries loaded into that environment, however it breaks down, when Python executes any other program not compiled for the given Nix system, e.g. a shell script via subprocess.

To work this around, devenv will inject a pth^1 file to the virtual environment it creates, which mangles the LD_LIBRARY_PATH variable, undoing any changes to it made by devenv but preserving changes from other sources.

I am unsure what the best way would be to integrate this, bit I think the approach in general is sane. I am tested only the poetry case currently.

Fixes #1111

bobvanderlinden commented 2 weeks ago

I was thinking, since this will probably be needed just for Linux, that it might be nice to eventually have an LD_PRELOAD that removed the path from LD_LIBRARY_PATH. That way this exact same trick can be applied to ruby, nodejs and more.

Still useful to have this pth to see how it fares in the python world.

domenkozar commented 5 days ago

Can we get some tests for this?