pypa / virtualenv

Virtual Python Environment builder
https://virtualenv.pypa.io
MIT License
4.81k stars 1.03k forks source link

`python2 -S` is broken #2025

Closed navytux closed 1 year ago

navytux commented 3 years ago

Issue

Hello up there. I've discovered that python -S is broken in virtualenv created for python2. It works ok for python3. Please find details below:

kirr@deco:~/src/tools/py/pypa/virtualenv$ . 1.venv/bin/activate
(1.venv) kirr@deco:~/src/tools/py/pypa/virtualenv$ python
Python 2.7.18 (default, Apr 20 2020, 20:30:41) 
[GCC 9.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
(1.venv) kirr@deco:~/src/tools/py/pypa/virtualenv$ python -S
Python 2.7.18 (default, Apr 20 2020, 20:30:41) 
[GCC 9.3.0] on linux2
>>> import os
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/os.py", line 49, in <module>
    import posixpath as path
ImportError: No module named posixpath

Thanks beforehand, Kirill

Environment

Provide at least:

```console (neo) (z4-dev) (g.env) kirr@deco:~/src/tools/py/pypa/virtualenv$ pip list DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality. Package Version Location ---------------------------------- -------------------- ---------------------------------------------- appdirs 1.4.4 atomicwrites 1.4.0 attrs 20.2.0 backports.functools-lru-cache 1.6.1 backports.shutil-get-terminal-size 1.0.0 BTrees 4.7.2 cffi 1.14.0 configparser 4.0.2 contextlib2 0.6.0.post1 Cython 0.29.21 dateparser 0.7.6 decorator 4.4.2 distlib 0.3.1 enum34 1.1.10 erp5.util 0.4.69 filelock 3.0.12 funcsigs 1.0.2 futures 3.3.0 gevent 20.6.2 greenlet 0.4.16 Importing 1.10 importlib-metadata 2.0.0 importlib-resources 3.3.0 ipython 5.10.0 ipython-genutils 0.2.0 manuel 1.10.1 mock 3.0.5 more-itertools 5.0.0 msgpack 1.0.0 neoppod 1.12.0 /home/kirr/src/neo/src/lab.nexedi.com/kirr/neo numpy 1.16.6 nxdtest 0.0.0.dev1 /home/kirr/src/wendelin/nxdtest packaging 20.4 pathlib2 2.3.5 persistent 4.6.4 pexpect 4.8.0 pickleshare 0.7.5 pip 20.2.4 pkg-resources 0.0.0 pluggy 0.13.1 prompt-toolkit 1.0.18 psutil 5.7.2 ptyprocess 0.6.0 py 1.9.0 pycparser 2.20 Pygments 2.5.2 pygolang 0.0.7.post1 /home/kirr/src/tools/go/pygolang pyparsing 2.4.7 pytest 4.6.11 python-dateutil 2.8.1 pytz 2020.1 random2 1.0.1 regex 2020.6.8 scandir 1.10.0 scipy 1.2.3 setuptools 44.1.1 setuptools-dso 1.7 simplegeneric 0.8.1 singledispatch 3.4.0.3 six 1.15.0 traitlets 4.3.3 transaction 1.7.0 trollius 2.2.post1 typing 3.7.4.3 tzlocal 2.1 virtualenv 20.2.2.dev1+g4daa295 /home/kirr/src/tools/py/pypa/virtualenv/src wcwidth 0.2.5 wheel 0.34.2 zc.lockfile 2.0 ZConfig 3.5.0 zdaemon 4.3 ZEO 4.3.1 /home/kirr/src/wendelin/z/ZEO4/src zipp 1.2.0 ZODB 4.4.5 /home/kirr/src/wendelin/z/ZODB4/src ZODB3 3.11.0 zodbpickle 2.0.0 zodbtools 0.0.0.dev8 /home/kirr/src/wendelin/z/zodbtools zodburi 2.4.0 zope.event 4.4 zope.exceptions 4.3 zope.interface 5.1.0 zope.testing 4.7 zope.testrunner 5.2 ```

Output of the virtual environment creation

Make sure to run the creation with -vvv --with-traceback:

```console (neo) (z4-dev) (g.env) kirr@deco:~/src/tools/py/pypa/virtualenv$ virtualenv -vvv --with-traceback 1.venv 2>&1 |tee 1.log 33 setup logging to NOTSET [DEBUG report:43] 69 find interpreter for spec PythonSpec(path=/home/kirr/src/wendelin/venv/z4-dev/bin/python2) [INFO builtin:52] 69 discover exe for PythonInfo(spec=CPython2.7.18.final.0-64, exe=/home/kirr/src/wendelin/venv/z4-dev/bin/python2, platform=linux2, version=u'2.7.18 (default, Apr 20 2020, 20:30:41) \n[GCC 9.3.0]', encoding_fs_io=UTF-8-None) in /usr [DEBUG py_info:371] 70 filesystem is case-sensitive [DEBUG info:28] 71 Attempting to acquire lock 140100375852752 on /home/kirr/.local/share/virtualenv/py_info/1/beb4f305451b4835b36a63cb1c75e625a7251cf8d76b65be2f5856eee68cb551.lock [DEBUG filelock:270] 71 Lock 140100375852752 acquired on /home/kirr/.local/share/virtualenv/py_info/1/beb4f305451b4835b36a63cb1c75e625a7251cf8d76b65be2f5856eee68cb551.lock [INFO filelock:274] 71 got python info of /usr/bin/python2.7 from /home/kirr/.local/share/virtualenv/py_info/1/beb4f305451b4835b36a63cb1c75e625a7251cf8d76b65be2f5856eee68cb551.json [DEBUG via_disk_folder:135] 72 Attempting to release lock 140100375852752 on /home/kirr/.local/share/virtualenv/py_info/1/beb4f305451b4835b36a63cb1c75e625a7251cf8d76b65be2f5856eee68cb551.lock [DEBUG filelock:315] 72 Lock 140100375852752 released on /home/kirr/.local/share/virtualenv/py_info/1/beb4f305451b4835b36a63cb1c75e625a7251cf8d76b65be2f5856eee68cb551.lock [INFO filelock:318] 72 proposed PythonInfo({u'base_exec_prefix': None, u'system_stdlib': u'/usr/lib/python2.7', u'sysconfig': {u'makefile_filename': u'/usr/lib/python2.7/config-x86_64-linux-gnu/Makefile'}, u'prefix': u'/usr', u'stdout_encoding': None, u'executable': '/home/kirr/src/wendelin/venv/z4-dev/bin/python2', u'implementation': u'CPython', u'exec_prefix': u'/usr', u'platform': u'linux2', u'version': u'2.7.18 (default, Apr 20 2020, 20:30:41) \n[GCC 9.3.0]', u'sysconfig_paths': {u'platstdlib': u'{platbase}/lib/python{py_version_short}', u'platlib': u'{platbase}/local/lib/python{py_version_short}/dist-packages', u'purelib': u'{base}/local/lib/python{py_version_short}/dist-packages', u'stdlib': u'{base}/lib/python{py_version_short}', u'scripts': u'{base}/local/bin', u'include': u'{base}/local/include/python{py_version_short}', u'data': u'{base}/local'}, u'base_prefix': None, u'system_stdlib_platform': u'/usr/lib/python2.7', u'file_system_encoding': u'UTF-8', u'version_info': VersionInfo(major=2, minor=7, micro=18, releaselevel=u'final', serial=0), u'sysconfig_vars': {u'base': u'/usr', u'platbase': u'/usr', u'PYTHONFRAMEWORK': u'', u'py_version_short': u'2.7'}, u'path': [u'/home/kirr/src/wendelin/venv/z-dev/lib/python2.7/site-packages/virtualenv/discovery', u'/home/kirr/src/tools/txt/docutils/docutils', u'/usr/lib/python2.7', u'/usr/lib/python2.7/plat-x86_64-linux-gnu', u'/usr/lib/python2.7/lib-tk', u'/usr/lib/python2.7/lib-old', u'/usr/lib/python2.7/lib-dynload', u'/usr/local/lib/python2.7/dist-packages', u'/usr/lib/python2.7/dist-packages', u'/usr/lib/python2.7/dist-packages/PILcompat', u'/usr/lib/python2.7/dist-packages/wx-3.0-gtk3'], u'max_size': 9223372036854775807, u'has_venv': False, u'real_prefix': None, u'distutils_install': {u'purelib': u'lib/python2.7/site-packages', u'headers': u'include/python2.7/UNKNOWN', u'scripts': u'bin', u'data': u'', u'platlib': u'lib/python2.7/site-packages'}, u'architecture': 64, u'original_executable': u'/usr/bin/python2.7', u'os': u'posix', u'system_executable': u'/usr/bin/python2.7'}) [INFO builtin:58] 73 accepted PythonInfo({u'base_exec_prefix': None, u'system_stdlib': u'/usr/lib/python2.7', u'sysconfig': {u'makefile_filename': u'/usr/lib/python2.7/config-x86_64-linux-gnu/Makefile'}, u'prefix': u'/usr', u'stdout_encoding': None, u'executable': '/home/kirr/src/wendelin/venv/z4-dev/bin/python2', u'implementation': u'CPython', u'exec_prefix': u'/usr', u'platform': u'linux2', u'version': u'2.7.18 (default, Apr 20 2020, 20:30:41) \n[GCC 9.3.0]', u'sysconfig_paths': {u'platstdlib': u'{platbase}/lib/python{py_version_short}', u'platlib': u'{platbase}/local/lib/python{py_version_short}/dist-packages', u'purelib': u'{base}/local/lib/python{py_version_short}/dist-packages', u'stdlib': u'{base}/lib/python{py_version_short}', u'scripts': u'{base}/local/bin', u'include': u'{base}/local/include/python{py_version_short}', u'data': u'{base}/local'}, u'base_prefix': None, u'system_stdlib_platform': u'/usr/lib/python2.7', u'file_system_encoding': u'UTF-8', u'version_info': VersionInfo(major=2, minor=7, micro=18, releaselevel=u'final', serial=0), u'sysconfig_vars': {u'base': u'/usr', u'platbase': u'/usr', u'PYTHONFRAMEWORK': u'', u'py_version_short': u'2.7'}, u'path': [u'/home/kirr/src/wendelin/venv/z-dev/lib/python2.7/site-packages/virtualenv/discovery', u'/home/kirr/src/tools/txt/docutils/docutils', u'/usr/lib/python2.7', u'/usr/lib/python2.7/plat-x86_64-linux-gnu', u'/usr/lib/python2.7/lib-tk', u'/usr/lib/python2.7/lib-old', u'/usr/lib/python2.7/lib-dynload', u'/usr/local/lib/python2.7/dist-packages', u'/usr/lib/python2.7/dist-packages', u'/usr/lib/python2.7/dist-packages/PILcompat', u'/usr/lib/python2.7/dist-packages/wx-3.0-gtk3'], u'max_size': 9223372036854775807, u'has_venv': False, u'real_prefix': None, u'distutils_install': {u'purelib': u'lib/python2.7/site-packages', u'headers': u'include/python2.7/UNKNOWN', u'scripts': u'bin', u'data': u'', u'platlib': u'lib/python2.7/site-packages'}, u'architecture': 64, u'original_executable': u'/usr/bin/python2.7', u'os': u'posix', u'system_executable': u'/usr/bin/python2.7'}) [DEBUG builtin:60] 100 create virtual environment via CPython2Posix(dest=/home/kirr/src/tools/py/pypa/virtualenv/1.venv, clear=False, no_vcs_ignore=False, global=False) [INFO session:52] 101 create folder /home/kirr/src/tools/py/pypa/virtualenv/1.venv/bin [DEBUG _sync:25] 102 create folder /home/kirr/src/tools/py/pypa/virtualenv/1.venv/include [DEBUG _sync:25] 102 create folder /home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/site-packages [DEBUG _sync:25] 102 write /home/kirr/src/tools/py/pypa/virtualenv/1.venv/pyvenv.cfg [DEBUG pyenv_cfg:34] 102 home = /usr [DEBUG pyenv_cfg:38] 102 implementation = CPython [DEBUG pyenv_cfg:38] 102 version_info = 2.7.18.final.0 [DEBUG pyenv_cfg:38] 102 virtualenv = 20.2.2.dev1+g4daa295 [DEBUG pyenv_cfg:38] 102 include-system-site-packages = false [DEBUG pyenv_cfg:38] 102 base-prefix = /usr [DEBUG pyenv_cfg:38] 102 base-exec-prefix = /usr [DEBUG pyenv_cfg:38] 102 base-executable = /usr/bin/python2.7 [DEBUG pyenv_cfg:38] 103 copy /usr/bin/python2.7 to /home/kirr/src/tools/py/pypa/virtualenv/1.venv/bin/python [DEBUG _sync:52] 106 symlink /usr/lib/python2.7/os.py to /home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/os.py [DEBUG _sync:44] 106 symlink /usr/lib/python2.7/os.pyc to /home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/os.pyc [DEBUG _sync:44] 106 symlink directory /usr/include/python2.7 to /home/kirr/src/tools/py/pypa/virtualenv/1.venv/include/python2.7 [DEBUG _sync:44] 106 symlink /usr/lib/python2.7/config-x86_64-linux-gnu/Makefile to /home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/config-x86_64-linux-gnu/Makefile [DEBUG _sync:44] 106 symlink directory /usr/lib/python2.7/lib-dynload to /home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/lib-dynload [DEBUG _sync:44] 107 create virtualenv import hook file /home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/site-packages/_virtualenv.pth [DEBUG api:95] 107 create /home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/site-packages/_virtualenv.py [DEBUG api:98] 108 ============================== target debug ============================== [DEBUG session:54] 108 debug via /home/kirr/src/tools/py/pypa/virtualenv/1.venv/bin/python /home/kirr/src/tools/py/pypa/virtualenv/src/virtualenv/create/debug.py [DEBUG creator:223] 108 { "makefile_filename": "/usr/lib/python2.7/config-x86_64-linux-gnu/Makefile", "site": "", "datetime": "", "sys": { "executable": "/home/kirr/src/tools/py/pypa/virtualenv/1.venv/bin/python", "real_prefix": "/usr", "base_exec_prefix": "/usr", "exec_prefix": "/home/kirr/src/tools/py/pypa/virtualenv/1.venv", "io_encoding": null, "meta_path": [ "" ], "fs_encoding": "UTF-8", "prefix": "/home/kirr/src/tools/py/pypa/virtualenv/1.venv", "_base_executable": null, "path": [ "/home/kirr/src/tools/txt/docutils/docutils", "/usr/lib/python2.7", "/usr/lib/python2.7/plat-x86_64-linux-gnu", "/usr/lib/python2.7/lib-tk", "/usr/lib/python2.7/lib-old", "/usr/lib/python2.7/lib-dynload", "/home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/site-packages" ], "base_prefix": "/usr" }, "json": "", "version": "2.7.18 (default, Apr 20 2020, 20:30:41) \n[GCC 9.3.0]", "os": "", "math": "" } [DEBUG session:55] 123 add seed packages via FromAppData(download=False, pip=bundle, wheel=bundle, setuptools=bundle, via=copy, app_data_dir=/home/kirr/.local/share/virtualenv) [INFO session:59] 126 got embed update of distribution setuptools from /home/kirr/.local/share/virtualenv/wheel/2.7/embed/1/setuptools.json [DEBUG via_disk_folder:135] 127 got embed update of distribution pip from /home/kirr/.local/share/virtualenv/wheel/2.7/embed/1/pip.json [DEBUG via_disk_folder:135] 129 got embed update of distribution wheel from /home/kirr/.local/share/virtualenv/wheel/2.7/embed/1/wheel.json [DEBUG via_disk_folder:135] 130 got embed update of distribution setuptools from /home/kirr/.local/share/virtualenv/wheel/2.7/embed/1/setuptools.json [DEBUG via_disk_folder:135] 131 got embed update of distribution pip from /home/kirr/.local/share/virtualenv/wheel/2.7/embed/1/pip.json [DEBUG via_disk_folder:135] 131 got embed update of distribution wheel from /home/kirr/.local/share/virtualenv/wheel/2.7/embed/1/wheel.json [DEBUG via_disk_folder:135] 132 install pip from wheel /home/kirr/src/tools/py/pypa/virtualenv/src/virtualenv/seed/wheels/embed/pip-20.2.4-py2.py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:49] 132 install wheel from wheel /home/kirr/src/tools/py/pypa/virtualenv/src/virtualenv/seed/wheels/embed/wheel-0.35.1-py2.py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:49] 133 install setuptools from wheel /home/kirr/src/tools/py/pypa/virtualenv/src/virtualenv/seed/wheels/embed/setuptools-44.1.1-py2.py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:49] 133 Attempting to acquire lock 140100373321168 on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/setuptools-44.1.1-py2.py3-none-any.lock [DEBUG filelock:270] 133 Lock 140100373321168 acquired on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/setuptools-44.1.1-py2.py3-none-any.lock [INFO filelock:274] 133 Attempting to acquire lock 140100373201744 on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pip-20.2.4-py2.py3-none-any.lock [DEBUG filelock:270] 134 Attempting to acquire lock 140100373202640 on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/wheel-0.35.1-py2.py3-none-any.lock [DEBUG filelock:270] 134 Attempting to release lock 140100373321168 on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/setuptools-44.1.1-py2.py3-none-any.lock [DEBUG filelock:315] 134 Lock 140100373321168 released on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/setuptools-44.1.1-py2.py3-none-any.lock [INFO filelock:318] 134 Lock 140100373202640 acquired on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/wheel-0.35.1-py2.py3-none-any.lock [INFO filelock:274] 134 Lock 140100373201744 acquired on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pip-20.2.4-py2.py3-none-any.lock [INFO filelock:274] 134 Attempting to release lock 140100373202640 on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/wheel-0.35.1-py2.py3-none-any.lock [DEBUG filelock:315] 134 copy directory /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/setuptools-44.1.1-py2.py3-none-any/setuptools to /home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/site-packages/setuptools [DEBUG _sync:52] 134 Lock 140100373202640 released on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/wheel-0.35.1-py2.py3-none-any.lock [INFO filelock:318] 135 Attempting to release lock 140100373201744 on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pip-20.2.4-py2.py3-none-any.lock [DEBUG filelock:315] 135 Lock 140100373201744 released on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pip-20.2.4-py2.py3-none-any.lock [INFO filelock:318] 135 copy directory /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/wheel-0.35.1-py2.py3-none-any/wheel to /home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/site-packages/wheel [DEBUG _sync:52] 135 copy /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pip-20.2.4-py2.py3-none-any/pip-20.2.4.virtualenv to /home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/site-packages/pip-20.2.4.virtualenv [DEBUG _sync:52] 136 copy directory /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pip-20.2.4-py2.py3-none-any/pip to /home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/site-packages/pip [DEBUG _sync:52] 140 copy directory /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/wheel-0.35.1-py2.py3-none-any/wheel-0.35.1.dist-info to /home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/site-packages/wheel-0.35.1.dist-info [DEBUG _sync:52] 142 copy /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/wheel-0.35.1-py2.py3-none-any/wheel-0.35.1.virtualenv to /home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/site-packages/wheel-0.35.1.virtualenv [DEBUG _sync:52] 145 generated console scripts wheel wheel-2.7 wheel2.7 wheel2 [DEBUG base:48] 166 copy /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/setuptools-44.1.1-py2.py3-none-any/setuptools-44.1.1.virtualenv to /home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/site-packages/setuptools-44.1.1.virtualenv [DEBUG _sync:52] 168 copy /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/setuptools-44.1.1-py2.py3-none-any/easy_install.py to /home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/site-packages/easy_install.py [DEBUG _sync:52] 169 copy directory /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/setuptools-44.1.1-py2.py3-none-any/pkg_resources to /home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/site-packages/pkg_resources [DEBUG _sync:52] 177 copy directory /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/setuptools-44.1.1-py2.py3-none-any/setuptools-44.1.1.dist-info to /home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/site-packages/setuptools-44.1.1.dist-info [DEBUG _sync:52] 181 generated console scripts easy_install easy_install2 easy_install2.7 easy_install-2.7 [DEBUG base:48] 212 copy directory /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pip-20.2.4-py2.py3-none-any/pip-20.2.4.dist-info to /home/kirr/src/tools/py/pypa/virtualenv/1.venv/lib/python2.7/site-packages/pip-20.2.4.dist-info [DEBUG _sync:52] 214 generated console scripts pip pip-2.7 pip2.7 pip2 [DEBUG base:48] 214 add activators for Python, CShell, Fish, PowerShell, Bash [INFO session:66] 216 write /home/kirr/src/tools/py/pypa/virtualenv/1.venv/pyvenv.cfg [DEBUG pyenv_cfg:34] 216 home = /usr [DEBUG pyenv_cfg:38] 216 implementation = CPython [DEBUG pyenv_cfg:38] 216 version_info = 2.7.18.final.0 [DEBUG pyenv_cfg:38] 216 virtualenv = 20.2.2.dev1+g4daa295 [DEBUG pyenv_cfg:38] 216 include-system-site-packages = false [DEBUG pyenv_cfg:38] 217 base-prefix = /usr [DEBUG pyenv_cfg:38] 217 base-exec-prefix = /usr [DEBUG pyenv_cfg:38] 217 base-executable = /usr/bin/python2.7 [DEBUG pyenv_cfg:38] 217 created virtual environment CPython2.7.18.final.0-64 in 185ms creator CPython2Posix(dest=/home/kirr/src/tools/py/pypa/virtualenv/1.venv, clear=False, no_vcs_ignore=False, global=False) seeder FromAppData(download=False, pip=bundle, wheel=bundle, setuptools=bundle, via=copy, app_data_dir=/home/kirr/.local/share/virtualenv) added seed packages: pip==20.2.4, setuptools==44.1.1, wheel==0.35.1 activators PythonActivator,CShellActivator,FishActivator,PowerShellActivator,BashActivator [WARNING __main__:17] ```
gaborbernat commented 3 years ago

This works for me on the macOs. Do you have a repro via a Docker image?

navytux commented 3 years ago

Yes, I can reproduces that in debian docker image e.g. via docker run --name test -it debian:

``` - apt-get update there - apt-get install python2 python3-pip - apt-get install git root@78830e43339f:/# git clone https://github.com/pypa/virtualenv.git Cloning into 'virtualenv'... remote: Enumerating objects: 9, done. remote: Counting objects: 100% (9/9), done. remote: Compressing objects: 100% (8/8), done. remote: Total 11274 (delta 2), reused 1 (delta 1), pack-reused 11265 Receiving objects: 100% (11274/11274), 84.45 MiB | 7.96 MiB/s, done. Resolving deltas: 100% (7089/7089), done. root@78830e43339f:/# cd virtualenv/ root@78830e43339f:/virtualenv# pip3 install -e . Obtaining file:///virtualenv Installing build dependencies ... done Collecting appdirs<2,>=1.4.3 (from virtualenv==20.2.2.dev1+g4daa295) Downloading https://files.pythonhosted.org/packages/3b/00/2344469e2084fb287c2e0b57b72910309874c3245463acd6cf5e3db69324/appdirs-1.4.4-py2.py3-none-any.whl Collecting distlib<1,>=0.3.1 (from virtualenv==20.2.2.dev1+g4daa295) Downloading https://files.pythonhosted.org/packages/f5/0a/490fa011d699bb5a5f3a0cf57de82237f52a6db9d40f33c53b2736c9a1f9/distlib-0.3.1-py2.py3-none-any.whl (335kB) 100% |████████████████████████████████| 337kB 1.9MB/s Collecting filelock<4,>=3.0.0 (from virtualenv==20.2.2.dev1+g4daa295) Downloading https://files.pythonhosted.org/packages/93/83/71a2ee6158bb9f39a90c0dea1637f81d5eef866e188e1971a1b1ab01a35a/filelock-3.0.12-py3-none-any.whl Requirement already satisfied: six<2,>=1.9.0 in /usr/lib/python3/dist-packages (from virtualenv==20.2.2.dev1+g4daa295) (1.12.0) Collecting importlib-metadata>=0.12 (from virtualenv==20.2.2.dev1+g4daa295) Downloading https://files.pythonhosted.org/packages/4a/c3/78826cdf0f7bf2d307aa4c6922aac9bd53c5d4f0de64e7db52771e641c8f/importlib_metadata-3.1.0-py2.py3-none-any.whl Collecting zipp>=0.5 (from importlib-metadata>=0.12->virtualenv==20.2.2.dev1+g4daa295) Downloading https://files.pythonhosted.org/packages/41/ad/6a4f1a124b325618a7fb758b885b68ff7b058eec47d9220a12ab38d90b1f/zipp-3.4.0-py3-none-any.whl Installing collected packages: appdirs, distlib, filelock, zipp, importlib-metadata, virtualenv Running setup.py develop for virtualenv Successfully installed appdirs-1.4.4 distlib-0.3.1 filelock-3.0.12 importlib-metadata-3.1.0 virtualenv zipp-3.4.0 root@78830e43339f:/virtualenv# virtualenv -p python2 1.venv created virtual environment CPython2.7.16.final.0-64 in 436ms creator CPython2Posix(dest=/virtualenv/1.venv, clear=False, no_vcs_ignore=False, global=False) seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv) added seed packages: pip==20.2.4, setuptools==44.1.1, wheel==0.35.1 activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator root@78830e43339f:/virtualenv# . 1.venv/bin/activate (1.venv) root@78830e43339f:/virtualenv# python Python 2.7.16 (default, Oct 10 2019, 22:02:15) [GCC 8.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> (1.venv) root@78830e43339f:/virtualenv# python -S Python 2.7.16 (default, Oct 10 2019, 22:02:15) [GCC 8.3.0] on linux2 >>> import os Traceback (most recent call last): File "", line 1, in File "/virtualenv/1.venv/lib/python2.7/os.py", line 49, in import posixpath as path ImportError: No module named posixpath ```
perrinjerome commented 3 years ago

If my bisect is correct, the regression comes from 9569493453a39d63064ed7c20653987ba15c99e5

perrinjerome commented 3 years ago

If my bisect is correct, the regression comes from 9569493

The reproduction steps were about using python3 to create a python2 virtualenv. Before 9569493, the created 1.venv/bin/python is a symlink to system python2 executable and python -S -c "import os" works fine. After, it is a copy.

But it seems the symlinking was accidental, the intention was to copy executable for python2. In https://github.com/pypa/virtualenv/commit/9569493453a39d63064ed7c20653987ba15c99e5#diff-e87e31e7905a55448cbbeda24d36cc6ae4eb6cca03ee0b31224872c53c6baa26R53-R55 there is a change to check if the target python is python2 instead of checking if the python running virtualenv is python2. When creating a python2 environment using python2, python -S -c "import os" does not work before or after 9569493.

So 9569493 just fixes an inconsistency when running python3 and does not introduce a regression.

gaborbernat commented 1 year ago

We no longer support python 2.