python3.buildEnv: support extending NIX_PYTHONPATH#261801
python3.buildEnv: support extending NIX_PYTHONPATH#261801yajo wants to merge 1 commit intoNixOS:stagingfrom
Conversation
|
Fixed in #297628 using a different strategy. |
36918fa to
983e53c
Compare
|
Answering to #326094 (comment) here to avoid polluting that other thread too much:
Fair point 😆 Well, let's be more accurate and say it fixed the problem for me while not presenting any incompatibilities, and I tested the fix in depth. Of course, if you happen to be exporting a FWIW, in my case I can export that variable in a devshell pointing to python dependencies from nix, and still create a venv, install editable packages on it, and be able to work, mixing all nix and impure dependencies in the venv. OTOH I can't find a reason why |
|
To not break with nested environments. When you use prefixing or suffixing you can mix packages causing breakage. Check the sitecustomize.py. It also unsets the variables because they should not leak further. |
|
Well, but that's the issue I'm fixing here. Basically I'm adding support
for nested environments.
El jue, 8 ago 2024, 16:51, Frederik Rietdijk ***@***.***>
escribió:
… To not break with nested environments. When you use prefixing or suffixing
you can mix packages causing breakage.
Check the sitecustomize.py. It also unsets the variables because they
should not leak further.
—
Reply to this email directly, view it on GitHub
<#261801 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHNXDMGRLAWX2AXEPOJ3XTZQOAW3AVCNFSM6AAAAAA6FJFV32VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZWGAZDINRTGM>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
|
That's why this cannot go in. It is The |
|
Sorry I don't understand that last comment. Do you mean that not supporting nested python environments is a feature? Could you please explain the benefits of not being able to do this? {python3, ...}: let
py3 = python3.withPackages (ps: [ps.ansible])
in
py3.withPackages (ps: [ps.werkzeug]) |
|
This should target staging branch as it is causing a mass rebuild. Read the links I provided here #334825 (comment) |
19bd170 to
d70454e
Compare
|
Thanks, done. |
Allow devshells to extend `$NIX_PYTHONPATH`, to effectively support nested virtualenvs. @moduon MT-1075 python3.buildEnv: beautify makeWrapper Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
d70454e to
2c5f9e6
Compare
|
Conflicts solved. This is still relevant IMHO. |
Allow devshells to extend
$NIX_PYTHONPATH, to effectively support nested virtualenvs.@moduon MT-1075
Description of changes
I'm trying to set up a devshell where:
In this specific scenario, some pure dependencies depend on impure ones.
For example, I'm developing odoo and some addons, but while doing so I want to have click-odoo-contrib at my fingertips while developing. Thus, I add it to my devshell. Sounds nice, but when I try to execute it, I get an
ImportError:That's expected. Odoo is installed as an editable dependency in an impure venv, because I'm developing it.
How could one pure package, packaged by nix, such as
click-odoo-contrib, import an impure one installed in a venv in editable mode? The solution is to customize the site. It turns out that's already handled by Nix in these lines:nixpkgs/pkgs/development/interpreters/python/sitecustomize.py
Lines 20 to 22 in 8fbb1f3
As you can see in that code, it supports multiple paths separated by colon.
However, without this patch, any binary produced from a Nix python environment will ignore any
NIX_PYTHONPATHvariable and replace it with what it wants.Now, after this is done, I can just add to my devshell an environment variable in the shape of
NIX_PYTHONPATH = "$PRJ_ROOT_DIR/.venv/${python.sitePackages}", and magicallyclick-odoo-listdbwill be able to importodooif it is installed into that venv.Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)