Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: PYTHONNOUSERSITE propagates from Python binaries to whatever they run #32915

Open
gleber-da opened this issue Dec 21, 2017 · 6 comments
Labels
0.kind: enhancement 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: python

Comments

@gleber-da
Copy link

gleber-da commented Dec 21, 2017

Issue description

We have observed this with ansible-playbook. Our playbook executes a python script inside, which was doing

pip3 install --user pyyaml
python3 -c 'import yaml'

and it was failing, since python3 binary would pick up the env variable set in the ansible-playbook binary.

Steps to reproduce

nix-shell -p ansible --run "ansible localhost -a python3.6"

and then type

import sys
sys.path

and check if there's ~/.local/lib/python2.6/site-packages or similar package. If it is not there, the issue stands.

Technical details

Possible solution would to replace use of PYTHONNOUSERSITE with -s argument to Python binary.

  • system: "x86_64-darwin"
  • host os: Darwin 17.3.0, macOS 10.13.2
  • multi-user?: no
  • sandbox: no
  • version: nix-env (Nix) 1.11.15pre4522_506828d0
  • channels(gleber): "nixpkgs-18.03pre122585.b212125b541"
  • nixpkgs: /Users/gleber/code/foo/bar/lib/gc-roots/nixpkgs-snapshot
@gleber-da
Copy link
Author

@joamaki CC

@FRidh
Copy link
Member

FRidh commented Dec 21, 2017

The reason the environment variable is exported is to prevent impurities. The downside of exporting environment variables is that they always propagate all the way down the process tree, unless they are explicitly unset at some point. Using the -s argument applies it only to the process executed in the wrapper.

I think we could make this change. Could you test with https://github.com/FRidh/nixpkgs/tree/imp/pythonnousersite.

@FRidh
Copy link
Member

FRidh commented Jan 6, 2018

See #33528 for the proposed change.

@FRidh
Copy link
Member

FRidh commented Jan 7, 2018

Closing since #33528 is now in staging.

@FRidh FRidh closed this as completed Jan 7, 2018
@FRidh FRidh reopened this Jan 7, 2018
@FRidh
Copy link
Member

FRidh commented Jan 7, 2018

Reverted it in e527eb0.
See 3102035#commitcomment-26697936

@stale
Copy link

stale bot commented Jun 4, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: python
Projects
None yet
Development

No branches or pull requests

2 participants