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
venv and ensurepip are affected by pip environment variable settings #63933
Comments
http://buildbot.python.org/all/builders/AMD64%20Ubuntu%20LTS%203.x/builds/3178/steps/test/logs/stdio Re-running failed tests in verbose mode ====================================================================== Traceback (most recent call last):
File "/opt/python/3.x.langa-ubuntu/build/Lib/test/test_venv.py", line 288, in test_with_pip
self.run_with_capture(venv.create, self.env_dir, with_pip=True)
File "/opt/python/3.x.langa-ubuntu/build/Lib/test/test_venv.py", line 48, in run_with_capture
func(*args, **kwargs)
File "/opt/python/3.x.langa-ubuntu/build/Lib/venv/__init__.py", line 359, in create
builder.create(env_dir)
File "/opt/python/3.x.langa-ubuntu/build/Lib/venv/__init__.py", line 86, in create
self._setup_pip(context)
File "/opt/python/3.x.langa-ubuntu/build/Lib/venv/__init__.py", line 242, in _setup_pip
subprocess.check_output(cmd)
File "/opt/python/3.x.langa-ubuntu/build/Lib/subprocess.py", line 618, in check_output
raise CalledProcessError(retcode, process.args, output=output)
subprocess.CalledProcessError: Command '['/tmp/tmp4_ukigy9/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 3 |
A different error on Solaris: Re-running test 'test_venv' in verbose mode ====================================================================== Traceback (most recent call last):
File "/home/cpython/buildslave/cc-32/3.x.snakebite-solaris11-amd64/build/Lib/test/test_venv.py", line 294, in test_with_pip
self.assertEqual(err, b"")
AssertionError: b"/home/cpython/buildslave/cc-32/3.x.snake[163 chars]):\n" != b'' |
Error similar to Solaris on OpenIndiana: http://buildbot.python.org/all/builders/AMD64%20OpenIndiana%203.x/builds/6946/steps/test/logs/stdio ====================================================================== Traceback (most recent call last):
File "/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/test/test_venv.py", line 294, in test_with_pip
self.assertEqual(err, b"")
AssertionError: b'/tmp/tmpnv3o61s9/bin/python: No module named pip\n' != b'' |
Interesting, looks like the warnings from bpo-19694 *weren't* the cause
> Traceback (most recent call last):
> File
> "/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/test/test_venv.py",
> line 294, in test_with_pip
> self.assertEqual(err, b"")
> AssertionError: b'/tmp/tmpnv3o61s9/bin/python: No module named pip\n' !=
> b''
>
>
|
Nick: I get that gdb failure, bisecting now. See bpo-19743. |
New changeset cb598129837c by Nick Coghlan in branch 'default': |
New changeset 989de1a267b1 by Nick Coghlan in branch 'default': |
Could a deprecation warning cause the failing test? Traceback (most recent call last):
File "C:\buildbot.python.org\3.x.kloth-win64\build\lib\runpy.py", line 160, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\buildbot.python.org\3.x.kloth-win64\build\lib\runpy.py", line 73, in _run_code
exec(code, run_globals)
File "C:\buildbot.python.org\3.x.kloth-win64\build\lib\ensurepip\__main__.py", line 66, in <module>
main()
File "C:\buildbot.python.org\3.x.kloth-win64\build\lib\ensurepip\__main__.py", line 61, in main
default_pip=args.default_pip,
File "C:\buildbot.python.org\3.x.kloth-win64\build\lib\ensurepip\__init__.py", line 92, in bootstrap
_run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "C:\buildbot.python.org\3.x.kloth-win64\build\lib\ensurepip\__init__.py", line 28, in _run_pip
import pip
File "<frozen importlib._bootstrap>", line 2147, in _find_and_load
File "<frozen importlib._bootstrap>", line 2136, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1178, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1140, in _load_backward_compatible
File "C:\Users\Buildbot\AppData\Local\Temp\tmpi0kq8p59\pip-1.5.rc1-py2.py3-none-any.whl\pip\__init__.py", line 9, in <module>
File "<frozen importlib._bootstrap>", line 2147, in _find_and_load
File "<frozen importlib._bootstrap>", line 2136, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1178, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1140, in _load_backward_compatible
File "C:\Users\Buildbot\AppData\Local\Temp\tmpi0kq8p59\pip-1.5.rc1-py2.py3-none-any.whl\pip\log.py", line 8, in <module>
File "<frozen importlib._bootstrap>", line 2147, in _find_and_load
File "<frozen importlib._bootstrap>", line 2136, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1178, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1140, in _load_backward_compatible
File "C:\Users\Buildbot\AppData\Local\Temp\tmpi0kq8p59\setuptools-1.3.2-py2.py3-none-any.whl\pkg_resources.py", line 20, in <module>
File "C:\buildbot.python.org\3.x.kloth-win64\build\lib\imp.py", line 32, in <module>
PendingDeprecationWarning)
PendingDeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses |
Christian, that was my original theory in bpo-19694 (since that box runs with PYTHONWARNINGS=d set), but it doesn't look like it is the problem, since running in isolated mode didn't fix the issue (although it did suppress the warnings). |
That specific stack trace is from the commit where I inadvertently reverted the isolated mode fix - the pip installation test is always run with PYTHONWARNINGS=e now to make sure it will fail in non-isolated mode. |
OpenIndiana failure looks like a resource management issue in ctypes: Traceback (most recent call last):
File "/export/home/buildbot/32bits/3.x.cea-indiana-x86/build/Lib/test/test_venv.py", line 304, in test_with_pip
self.assertEqual(err, "")
AssertionError: "/export/home/buildbot/32bits/3.x.cea-ind[346 chars]):\n" != ''
- /export/home/buildbot/32bits/3.x.cea-indiana-x86/build/Lib/ctypes/util.py:179: ResourceWarning: unclosed file <_io.TextIOWrapper name=5 encoding='646'>
- for line in os.popen(cmd).readlines():
- /export/home/buildbot/32bits/3.x.cea-indiana-x86/build/Lib/ctypes/util.py:179: ResourceWarning: unclosed file <_io.TextIOWrapper name=5 encoding='646'>
- for line in os.popen(cmd).readlines(): Ubuntu LTS failure still puzzles me: ====================================================================== Traceback (most recent call last):
File "/opt/python/3.x.langa-ubuntu/build/Lib/test/test_venv.py", line 289, in test_with_pip
self.run_with_capture(venv.create, self.env_dir, with_pip=True)
subprocess.CalledProcessError: Command '['/tmp/tmpwsahapjn/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 3
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/python/3.x.langa-ubuntu/build/Lib/test/test_venv.py", line 295, in test_with_pip
self.fail(msg)
AssertionError: Command '['/tmp/tmpwsahapjn/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 3 **Subprocess Output** |
New changeset 7c080ee796a6 by Nick Coghlan in branch 'default': |
test_venv is now passing on 3.x OpenIndiana: http://buildbot.python.org/all/builders/x86%20OpenIndiana%203.x/builds/7129/steps/test/logs/stdio Ubuntu LTS buildbot is still unhappy: http://buildbot.python.org/all/builders/AMD64%20Ubuntu%20LTS%203.x/builds/3221/steps/test/logs/stdio And looking at the environment armed with the improved error details, this is likely the culprit: PIP_REQUIRE_VIRTUALENV=true I'll hack the test to delete it from the subprocess invocation for now, but I think there's a pip bug here: -E (and, equivalently, -I) should likely cause pip to ignore *its* environment variables as well. |
Confirmed: $ PIP_REQUIRE_VIRTUALENV=true ./python -m test test_venv
[1/1] test_venv
test test_venv failed -- Traceback (most recent call last):
File "/home/ncoghlan/devel/py3k/Lib/test/test_venv.py", line 298, in test_with_pip
self.run_with_capture(venv.create, self.env_dir, with_pip=True)
subprocess.CalledProcessError: Command '['/tmp/tmpo1fj4gy6/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 3
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ncoghlan/devel/py3k/Lib/test/test_venv.py", line 304, in test_with_pip
self.fail(msg)
AssertionError: Command '['/tmp/tmpo1fj4gy6/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 3 **Subprocess Output** 1 test failed: |
New changeset 9186fdae7e1f by Nick Coghlan in branch 'default': |
New changeset 124e51c19e4f by Nick Coghlan in branch 'default': |
test_venv appears to be green on all the stable buildbots now. However, blocking PIP_REQUIRE_VIRTUALENV in the test probably isn't the right place for workaround - resolution in venv or ensurepip would be more appropriate. |
Hmm, this may also indicate a bug in pip's "require virtualenv" handling. |
Issue for the lack of attention paid to sys.flags.ignore_environment: pypa/pip#1359 |
Issue for the failure to detect a native venv: pypa/pip#1358 |
1358 (failing to detect native virtual environments) will be resolved upstream, but for 1359 (telling pip to ignore the environment variables), I've decided I agree with Paul's suggestion on the pip issue that it makes sense for venv to just strip all environment variables starting with "PIP_" from the environment passed to the subprocess. |
New changeset 7a5a4d7c564d by Nick Coghlan in branch 'default': |
bpo-20053 covers a related issue with ensurepip and venv being affected by the user's default pip config file. |
The PIP_REQUIRES_VIRTUALENV buildbot still failed: http://buildbot.python.org/all/builders/AMD64%20Ubuntu%20LTS%203.x/builds/3495/steps/test/logs/stdio This suggests both that the setting didn't get cleared as expected *and* that pip 1.5rc2 still failed to detect the pyvenv created virtual environment. |
New changeset 98d8bf13a32c by Nick Coghlan in branch 'default': |
New changeset 3b3d1c312042 by Nick Coghlan in branch 'default': |
Buildbot is happy with that version: |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: