when building my nix-shell environment, I found that including package pre-commit in mkShellbuildInputs results in populated PYTHONPATH shell environment variable, but including Poetry doesn’t. Both are Python packages and are built in very similar way. The only difference is that Poetry declares pythonNamespaces while pre-commit doesn’t, but according my testing (trying to override pre-commit with setting pythonNamespaces) it doesn’t have any impact on resulting PYTHONPATH.
Example:
shell.nix with poetry:
pkgs.mkShell {
name = "xyz";
buildInputs = with pkgs; [
poetry
];
$ echo $PYTHONPATH
[NOTHING]
shell.nix with pre-commit:
pkgs.mkShell {
name = "xyz";
buildInputs = with pkgs; [
pre-commit
];
Looks like it might be PYTHOPATH leaking as described in some other threads but I am still not sure what is causing this especially in this case when one package leaks and other not.
If I understand it correctly, poetry is now built by poetry2nix (pkgs/development/tools/poetry2nix/poetry2nix/pkgs/poetry/default.nix) and pkgs/development/python-modules/poetry/default.nix is not used at all for (there is no reference of it in all-packages.nix) ?
So I know this is an old thread, but I actually ran into that exact issue again. I have my own Python package (using pkgs.python3Packages.callPackage) which I then convert to an application with pkgs.python3Packages.toPythonApplication. Inserting the latter in a devshell causes pollution of PYTHONPATH. somehow that sounds counter intuitive when using a Python “application”. Was there any progress on this problem?
I was confused by this too and the reason PYTHONPATH is propagated in python application is to avoid rebuilds. I added a comment, PR and issue on tracker