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

Unset PIP_REQUIRE_VIRTUALENV when running 'pip' #84

Closed

Conversation

adamchainz
Copy link
Contributor

If the PIP_REQUIRE_VIRTUALENV environment variable is set, it blocks pip install from running without a virtualenv being activated. This broke using python -m pep517.build on my project:

$ python -m pep517.build .
ERROR: Could not find an activated virtualenv (required).
Traceback (most recent call last):
  File "/Users/chainz/.pyenv/versions/3.8.3/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/chainz/.pyenv/versions/3.8.3/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/chainz/.pyenv/versions/3.8.3/lib/python3.8/site-packages/pep517/build.py", line 124, in <module>
    main(parser.parse_args())
  File "/Users/chainz/.pyenv/versions/3.8.3/lib/python3.8/site-packages/pep517/build.py", line 120, in main
    build(args.source_dir, dist, args.out_dir)
  File "/Users/chainz/.pyenv/versions/3.8.3/lib/python3.8/site-packages/pep517/build.py", line 87, in build
    env.pip_install(system['requires'])
  File "/Users/chainz/.pyenv/versions/3.8.3/lib/python3.8/site-packages/pep517/envbuild.py", line 100, in pip_install
    check_call(
  File "/Users/chainz/.pyenv/versions/3.8.3/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/Users/chainz/.pyenv/versions/3.8.3/bin/python', '-m', 'pip', 'install', '--ignore-installed', '--prefix', '/var/folders/kq/02p9h16n7zv_z7bhzmg6y_pm0000gn/T/pep517-build-env-fkh9ckg8', 'setuptools >= 40.6.0', 'wheel']' returned non-zero exit status 3.

This change makes pep517 unset the environment variable since its installs are safe to run.

If the PIP_REQUIRE_VIRTUALENV environment variable is set, it blocks `pip install` from running without a virtualenv being activated. This broke using `python -m pep517.build` on my project:

```
$ python -m pep517.build .
ERROR: Could not find an activated virtualenv (required).
Traceback (most recent call last):
  File "/Users/chainz/.pyenv/versions/3.8.3/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/chainz/.pyenv/versions/3.8.3/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/chainz/.pyenv/versions/3.8.3/lib/python3.8/site-packages/pep517/build.py", line 124, in <module>
    main(parser.parse_args())
  File "/Users/chainz/.pyenv/versions/3.8.3/lib/python3.8/site-packages/pep517/build.py", line 120, in main
    build(args.source_dir, dist, args.out_dir)
  File "/Users/chainz/.pyenv/versions/3.8.3/lib/python3.8/site-packages/pep517/build.py", line 87, in build
    env.pip_install(system['requires'])
  File "/Users/chainz/.pyenv/versions/3.8.3/lib/python3.8/site-packages/pep517/envbuild.py", line 100, in pip_install
    check_call(
  File "/Users/chainz/.pyenv/versions/3.8.3/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/Users/chainz/.pyenv/versions/3.8.3/bin/python', '-m', 'pip', 'install', '--ignore-installed', '--prefix', '/var/folders/kq/02p9h16n7zv_z7bhzmg6y_pm0000gn/T/pep517-build-env-fkh9ckg8', 'setuptools >= 40.6.0', 'wheel']' returned non-zero exit status 3.
```

This change makes pep517 unset the environment variable since its installs are safe to run.
@pradyunsg
Copy link
Member

Closing since we're going a different direction with this project (see #83). You might be interested in https://github.com/FFY00/python-build/issues/42 -- which will become pypa/build at some point in the future.

@pradyunsg pradyunsg closed this Aug 30, 2020
@adamchainz
Copy link
Contributor Author

Thanks for the reference. I'll keep an eye out for an official python-build release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants