virtualenv icon indicating copy to clipboard operation
virtualenv copied to clipboard

Broken environment built via `virtualenv venv` with scheme `posix_local` in Debian testing bookworm

Open yingmanwumen opened this issue 2 years ago • 8 comments

Issue

Debian has set the sysconfig default scheme from posix_prefix to posix_local(https://lists.debian.org/debian-python/2022/03/msg00039.html). And when posix_local being chosen, the default ./venv/bin/activate is set to ./venv/local/bin/activate -- AND, it is BROKEN.

Reproduce:

Open an empty directory and use the command virtualenv venv

$ virtualenv venv
created virtual environment CPython3.10.4.final.0-64 in 101ms
  creator CPython3Posix(dest=/home/yingmanwumen/Desktop/test/venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/yingmanwumen/.local/share/virtualenv)
    added seed packages: pip==22.0.4, setuptools==62.1.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

the sysconfig scheme is posix_local:

$ python -m sysconfig
Platform: "linux-x86_64"
Python version: "3.10"
Current installation scheme: "posix_local"

Paths:
	data = "/usr/local"
	include = "/usr/include/python3.10"
	platinclude = "/usr/include/python3.10"
	platlib = "/usr/local/lib/python3.10/dist-packages"
	platstdlib = "/usr/lib/python3.10"
	purelib = "/usr/local/lib/python3.10/dist-packages"
	scripts = "/usr/local/bin"
	stdlib = "/usr/lib/python3.10"
...

And the directories:

$ tree -L 3
.
└── venv
    ├── lib
    │   └── python3.10
    ├── local
    │   ├── bin
    │   └── lib
    └── pyvenv.cfg

6 directories, 1 file

Activate the venv by source ./venv/local/bin/activate, then use the command pip list:

pip list
Package             Version
------------------- --------------
appdirs             1.4.4
asciinema           2.2.0
attrs               21.2.0
beautifulsoup4      4.11.1
Brlapi              0.8.3
Brotli              1.0.9
bs4                 0.0.1
certifi             2020.6.20
chardet             4.0.0
charset-normalizer  2.0.6
click               8.1.3
colorama            0.4.4
commonmark          0.9.1
cppman              0.5.3
cupshelpers         1.0
cycler              0.11.0
dbus-python         1.2.18
decorator           4.4.2
distlib             0.3.4
distro              1.7.0
distro-info         1.1
dlib                19.23.1
filelock            3.6.0
Flask               2.1.2
fonttools           4.32.0
fs                  2.4.12
fuse-python         1.0.5
gpg                 1.16.0-unknown
greenlet            1.1.2
gyp                 0.1
html5lib            1.1
idna                3.3
importlib-metadata  4.6.4
iniconfig           1.1.1
itsdangerous        2.1.2
Jinja2              3.1.2
jsonschema          3.2.0
kaggle              1.5.12
kiwisolver          1.3.2
louis               3.21.0
lxml                4.8.0
lz4                 4.0.0+dfsg
Mako                1.1.3
Markdown            3.3.7
MarkupSafe          2.1.1
matplotlib          3.5.1
memray              1.0.3
mercurial           6.1.2
more-itertools      8.10.0
mpmath              0.0.0
msgpack             1.0.3
mutagen             1.45.1
numpy               1.21.5
olefile             0.46
opencv-python       4.5.5.64
packaging           21.3
pbr                 5.9.0
perf                0.1
pexpect             4.8.0
Pillow              9.0.1
pip                 22.1.1
pip-review          1.1.1
pip-search          0.0.12
platformdirs        2.5.2
pluggy              1.0.0
psutil              5.9.0
ptyprocess          0.7.0
py                  1.11.0
PyAudio             0.2.11
pycairo             1.20.1
pycryptodomex       3.11.0
pycups              2.0.1
pycurl              7.44.1
Pygments            2.11.2
PyGObject           3.42.1
pylibacl            0.6.0
pynvim              0.4.2
pyparsing           3.0.7
PyQt5               5.15.6
PyQt5-sip           12.10.1
PyQtWebEngine       5.15.5
pyrsistent          0.18.1
pysmbc              1.0.23
pyte                0.8.0
pytest              7.1.2
pytest-memray       1.0.0
python-apt          2.3.0+b1
python-dateutil     2.8.1
python-debian       0.1.44
python-slugify      6.1.2
pytz                2022.1
pyxattr             0.7.2
pyxdg               0.27
PyYAML              5.4.1
requests            2.27.1
rich                10.16.2
scipy               1.8.1
screenkey           1.5
Send2Trash          1.8.1b0
setuptools          62.3.2
six                 1.16.0
soupsieve           2.3.2.post1
specan              0.0.0
stevedore           3.5.0
sympy               1.10.1
text-unidecode      1.3
tomli               2.0.1
tornado             6.1
tqdm                4.64.0
trash-cli           0.22.4.16
ufoLib2             0.13.1
unattended-upgrades 0.1
unicodedata2        14.0.0
urllib3             1.26.9
virtualenv          20.14.1
virtualenv-clone    0.5.7
virtualenvwrapper   4.8.4
wcwidth             0.2.5
webencodings        0.5.1
websockets          10.3
Werkzeug            2.1.2
wheel               0.37.1
xdg                 5.1.1
xxh-xxh             0.8.10
yt-dlp              2022.5.18
zipp                3.8.0

It is the result of the host pip list!!

I have found the same issue #2340.

It is easy to solve this by add export DEB_PYTHON_INSTALL_LAYOUT='deb' to ~/.bashrc to change sysconfig scheme from posix_local to deb_system, but I think a proper solution is needed ^_^

Environment

Provide at least:

  • OS: Debian testing bookworm
  • pip list of the host python where virtualenv is installed:
Package             Version
------------------- --------------
appdirs             1.4.4
asciinema           2.2.0
attrs               21.2.0
beautifulsoup4      4.11.1
Brlapi              0.8.3
Brotli              1.0.9
bs4                 0.0.1
certifi             2020.6.20
chardet             4.0.0
charset-normalizer  2.0.6
click               8.1.3
colorama            0.4.4
commonmark          0.9.1
cppman              0.5.3
cupshelpers         1.0
cycler              0.11.0
dbus-python         1.2.18
decorator           4.4.2
distlib             0.3.4
distro              1.7.0
distro-info         1.1
dlib                19.23.1
filelock            3.6.0
Flask               2.1.2
fonttools           4.32.0
fs                  2.4.12
fuse-python         1.0.5
gpg                 1.16.0-unknown
greenlet            1.1.2
gyp                 0.1
html5lib            1.1
idna                3.3
importlib-metadata  4.6.4
iniconfig           1.1.1
itsdangerous        2.1.2
Jinja2              3.1.2
jsonschema          3.2.0
kaggle              1.5.12
kiwisolver          1.3.2
louis               3.21.0
lxml                4.8.0
lz4                 4.0.0+dfsg
Mako                1.1.3
Markdown            3.3.7
MarkupSafe          2.1.1
matplotlib          3.5.1
memray              1.0.3
mercurial           6.1.2
more-itertools      8.10.0
mpmath              0.0.0
msgpack             1.0.3
mutagen             1.45.1
numpy               1.21.5
olefile             0.46
opencv-python       4.5.5.64
packaging           21.3
pbr                 5.9.0
perf                0.1
pexpect             4.8.0
Pillow              9.0.1
pip                 22.1.1
pip-review          1.1.1
pip-search          0.0.12
platformdirs        2.5.2
pluggy              1.0.0
psutil              5.9.0
ptyprocess          0.7.0
py                  1.11.0
PyAudio             0.2.11
pycairo             1.20.1
pycryptodomex       3.11.0
pycups              2.0.1
pycurl              7.44.1
Pygments            2.11.2
PyGObject           3.42.1
pylibacl            0.6.0
pynvim              0.4.2
pyparsing           3.0.7
PyQt5               5.15.6
PyQt5-sip           12.10.1
PyQtWebEngine       5.15.5
pyrsistent          0.18.1
pysmbc              1.0.23
pyte                0.8.0
pytest              7.1.2
pytest-memray       1.0.0
python-apt          2.3.0+b1
python-dateutil     2.8.1
python-debian       0.1.44
python-slugify      6.1.2
pytz                2022.1
pyxattr             0.7.2
pyxdg               0.27
PyYAML              5.4.1
requests            2.27.1
rich                10.16.2
scipy               1.8.1
screenkey           1.5
Send2Trash          1.8.1b0
setuptools          62.3.2
six                 1.16.0
soupsieve           2.3.2.post1
specan              0.0.0
stevedore           3.5.0
sympy               1.10.1
text-unidecode      1.3
tomli               2.0.1
tornado             6.1
tqdm                4.64.0
trash-cli           0.22.4.16
ufoLib2             0.13.1
unattended-upgrades 0.1
unicodedata2        14.0.0
urllib3             1.26.9
virtualenv          20.14.1
virtualenv-clone    0.5.7
virtualenvwrapper   4.8.4
wcwidth             0.2.5
webencodings        0.5.1
websockets          10.3
Werkzeug            2.1.2
wheel               0.37.1
xdg                 5.1.1
xxh-xxh             0.8.10
yt-dlp              2022.5.18
zipp                3.8.0

Output of the virtual environment creation

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

390 setup logging to NOTSET [DEBUG report:39]
397 find interpreter for spec PythonSpec(path=/usr/bin/python) [INFO builtin:62]
397 proposed PythonInfo(spec=CPython3.10.4.final.0-64, exe=/usr/bin/python, platform=linux, version='3.10.4 (main, Mar 24 2022, 13:07:27) [GCC 11.2.0]', encoding_fs_io=utf-8-utf-8) [INFO builtin:69]
397 accepted PythonInfo(spec=CPython3.10.4.final.0-64, exe=/usr/bin/python, platform=linux, version='3.10.4 (main, Mar 24 2022, 13:07:27) [GCC 11.2.0]', encoding_fs_io=utf-8-utf-8) [DEBUG builtin:71]
400 filesystem is case-sensitive [DEBUG info:29]
426 create virtual environment via CPython3Posix(dest=/home/yingmanwumen/Desktop/test/venv, clear=False, no_vcs_ignore=False, global=False) [INFO session:52]
426 create folder /home/yingmanwumen/Desktop/test/venv/lib/python3.10 [DEBUG _sync:24]
426 create folder /home/yingmanwumen/Desktop/test/venv/local/bin [DEBUG _sync:24]
427 create folder /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages [DEBUG _sync:24]
427 write /home/yingmanwumen/Desktop/test/venv/pyvenv.cfg [DEBUG pyenv_cfg:34]
428 	home = /usr [DEBUG pyenv_cfg:38]
428 	implementation = CPython [DEBUG pyenv_cfg:38]
428 	version_info = 3.10.4.final.0 [DEBUG pyenv_cfg:38]
428 	virtualenv = 20.14.1 [DEBUG pyenv_cfg:38]
428 	include-system-site-packages = false [DEBUG pyenv_cfg:38]
428 	base-prefix = /usr [DEBUG pyenv_cfg:38]
428 	base-exec-prefix = /usr [DEBUG pyenv_cfg:38]
428 	base-executable = /usr/bin/python [DEBUG pyenv_cfg:38]
428 symlink /usr/bin/python to /home/yingmanwumen/Desktop/test/venv/local/bin/python [DEBUG _sync:43]
428 create virtualenv import hook file /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/_virtualenv.pth [DEBUG api:95]
428 create /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/_virtualenv.py [DEBUG api:98]
429 ============================== target debug ============================== [DEBUG session:54]
429 debug via /home/yingmanwumen/Desktop/test/venv/local/bin/python /home/yingmanwumen/.local/lib/python3.10/site-packages/virtualenv/create/debug.py [DEBUG creator:224]
429 {
  "sys": {
    "executable": "/home/yingmanwumen/Desktop/test/venv/local/bin/python",
    "_base_executable": "/home/yingmanwumen/Desktop/test/venv/local/bin/python",
    "prefix": "/usr",
    "base_prefix": "/usr",
    "real_prefix": null,
    "exec_prefix": "/usr",
    "base_exec_prefix": "/usr",
    "path": [
      "/usr/lib/python310.zip",
      "/usr/lib/python3.10",
      "/usr/lib/python3.10/lib-dynload",
      "/home/yingmanwumen/.local/lib/python3.10/site-packages",
      "/usr/local/lib/python3.10/dist-packages",
      "/usr/lib/python3/dist-packages",
      "/usr/lib/python3.10/dist-packages"
    ],
    "meta_path": [
      "<class '_distutils_hack.DistutilsMetaFinder'>",
      "<class '_frozen_importlib.BuiltinImporter'>",
      "<class '_frozen_importlib.FrozenImporter'>",
      "<class '_frozen_importlib_external.PathFinder'>"
    ],
    "fs_encoding": "utf-8",
    "io_encoding": "utf-8"
  },
  "version": "3.10.4 (main, Mar 24 2022, 13:07:27) [GCC 11.2.0]",
  "makefile_filename": "/usr/lib/python3.10/config-3.10-x86_64-linux-gnu/Makefile",
  "os": "<module 'os' from '/usr/lib/python3.10/os.py'>",
  "site": "<module 'site' from '/usr/lib/python3.10/site.py'>",
  "datetime": "<module 'datetime' from '/usr/lib/python3.10/datetime.py'>",
  "math": "<module 'math' (built-in)>",
  "json": "<module 'json' from '/usr/lib/python3.10/json/__init__.py'>"
} [DEBUG session:55]
468 add seed packages via FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/yingmanwumen/.local/share/virtualenv) [INFO session:59]
470 got embed update of distribution wheel from /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/embed/3/wheel.json [DEBUG via_disk_folder:135]
470 got embed update of distribution setuptools from /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/embed/3/setuptools.json [DEBUG via_disk_folder:135]
470 got embed update of distribution pip from /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/embed/3/pip.json [DEBUG via_disk_folder:135]
473 got embed update of distribution pip from /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/embed/3/pip.json [DEBUG via_disk_folder:135]
473 got embed update of distribution setuptools from /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/embed/3/setuptools.json [DEBUG via_disk_folder:135]
474 got embed update of distribution wheel from /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/embed/3/wheel.json [DEBUG via_disk_folder:135]
474 install pip from wheel /home/yingmanwumen/.local/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/pip-22.0.4-py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:49]
474 install setuptools from wheel /home/yingmanwumen/.local/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/setuptools-62.1.0-py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:49]
474 install wheel from wheel /home/yingmanwumen/.local/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/wheel-0.37.1-py2.py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:49]
475 Attempting to acquire lock 139837408603792 on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any.lock [DEBUG _api:169]
475 Attempting to acquire lock 139837408607248 on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/pip-22.0.4-py3-none-any.lock [DEBUG _api:169]
475 Attempting to acquire lock 139837408607104 on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/wheel-0.37.1-py2.py3-none-any.lock [DEBUG _api:169]
475 Lock 139837408603792 acquired on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any.lock [DEBUG _api:173]
475 Lock 139837408607248 acquired on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/pip-22.0.4-py3-none-any.lock [DEBUG _api:173]
475 Lock 139837408607104 acquired on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/wheel-0.37.1-py2.py3-none-any.lock [DEBUG _api:173]
475 Attempting to release lock 139837408603792 on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any.lock [DEBUG _api:203]
475 Attempting to release lock 139837408607248 on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/pip-22.0.4-py3-none-any.lock [DEBUG _api:203]
475 Lock 139837408603792 released on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any.lock [DEBUG _api:206]
475 Attempting to release lock 139837408607104 on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/wheel-0.37.1-py2.py3-none-any.lock [DEBUG _api:203]
475 Lock 139837408607248 released on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/pip-22.0.4-py3-none-any.lock [DEBUG _api:206]
476 Lock 139837408607104 released on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/wheel-0.37.1-py2.py3-none-any.lock [DEBUG _api:206]
476 copy directory /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/pip-22.0.4-py3-none-any/pip to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/pip [DEBUG _sync:51]
476 copy directory /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any/setuptools-62.1.0.dist-info to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/setuptools-62.1.0.dist-info [DEBUG _sync:51]
476 copy /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/wheel-0.37.1-py2.py3-none-any/wheel-0.37.1.virtualenv to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/wheel-0.37.1.virtualenv [DEBUG _sync:51]
477 copy directory /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/wheel-0.37.1-py2.py3-none-any/wheel-0.37.1.dist-info to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/wheel-0.37.1.dist-info [DEBUG _sync:51]
478 copy directory /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any/setuptools to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/setuptools [DEBUG _sync:51]
479 copy directory /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/wheel-0.37.1-py2.py3-none-any/wheel to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/wheel [DEBUG _sync:51]
486 generated console scripts wheel wheel3.10 wheel-3.10 wheel3 [DEBUG base:45]
528 copy directory /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any/_distutils_hack to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/_distutils_hack [DEBUG _sync:51]
529 copy /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any/distutils-precedence.pth to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/distutils-precedence.pth [DEBUG _sync:51]
529 copy /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any/setuptools-62.1.0.virtualenv to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/setuptools-62.1.0.virtualenv [DEBUG _sync:51]
529 copy directory /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any/pkg_resources to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/pkg_resources [DEBUG _sync:51]
540 generated console scripts  [DEBUG base:45]
580 copy /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/pip-22.0.4-py3-none-any/pip-22.0.4.virtualenv to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/pip-22.0.4.virtualenv [DEBUG _sync:51]
580 copy directory /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/pip-22.0.4-py3-none-any/pip-22.0.4.dist-info to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/pip-22.0.4.dist-info [DEBUG _sync:51]
586 generated console scripts pip pip3 pip-3.10 pip3.10 [DEBUG base:45]
586 add activators for Bash, CShell, Fish, Nushell, PowerShell, Python [INFO session:64]
588 write /home/yingmanwumen/Desktop/test/venv/pyvenv.cfg [DEBUG pyenv_cfg:34]
588 	home = /usr [DEBUG pyenv_cfg:38]
588 	implementation = CPython [DEBUG pyenv_cfg:38]
588 	version_info = 3.10.4.final.0 [DEBUG pyenv_cfg:38]
588 	virtualenv = 20.14.1 [DEBUG pyenv_cfg:38]
588 	include-system-site-packages = false [DEBUG pyenv_cfg:38]
588 	base-prefix = /usr [DEBUG pyenv_cfg:38]
588 	base-exec-prefix = /usr [DEBUG pyenv_cfg:38]
588 	base-executable = /usr/bin/python [DEBUG pyenv_cfg:38]
588 created virtual environment CPython3.10.4.final.0-64 in 200ms
  creator CPython3Posix(dest=/home/yingmanwumen/Desktop/test/venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/yingmanwumen/.local/share/virtualenv)
    added seed packages: pip==22.0.4, setuptools==62.1.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator [WARNING __main__:19]

yingmanwumen avatar Jun 05 '22 04:06 yingmanwumen

PR addressing this is welcome.

gaborbernat avatar Jun 05 '22 08:06 gaborbernat

I have found the same issue https://github.com/pypa/virtualenv/issues/2340.

It is easy to solve this by add export DEB_PYTHON_INSTALL_LAYOUT='deb' to ~/.bashrc to change sysconfig scheme from posix_local to deb_system, but I think a proper solution is needed ^_^

Thank you so much for the solution! Sure it isn't a "proper" solution but it restores the behavior that I wanted and couldn't get to work! :see_no_evil: @yingmanwumen is it alright for you if I post this solution in AskUbuntu?

icezyclon avatar Jun 09 '22 08:06 icezyclon

I encounter the same problem with Python 3.10.4 on Ubuntu 22.04. It will result in poetry keeping recreating virtual environment on existing environment and prompting "The virtual environment found in [virtual environment path] seems to be broken". Moreover, when using poetry shell the virtual environment cannot be activated because poetry searches for /venv/bin/activate rather than /venv/local/bin/activate.

toto6038 avatar Jul 16 '22 06:07 toto6038

It seems that we have the same issue in Fedora. Strange is that even we have the same installation scheme for Python 3.10 (default) and 3.11 (beta) the result is different:

$ python3.11 -m sysconfig | head -n 15
Platform: "linux-x86_64"
Python version: "3.11"
Current installation scheme: "posix_prefix"

Paths: 
	data = "/usr/local"
	include = "/usr/include/python3.11"
	platinclude = "/usr/include/python3.11"
	platlib = "/usr/local/lib64/python3.11/site-packages"
	platstdlib = "/usr/lib64/python3.11"
	purelib = "/usr/local/lib/python3.11/site-packages"
	scripts = "/usr/local/bin"
	stdlib = "/usr/lib64/python3.11"

$ python3.10 -m sysconfig | head -n 15
Platform: "linux-x86_64"
Python version: "3.10"
Current installation scheme: "posix_prefix"

Paths: 
	data = "/usr/local"
	include = "/usr/include/python3.10"
	platinclude = "/usr/include/python3.10"
	platlib = "/usr/local/lib64/python3.10/site-packages"
	platstdlib = "/usr/lib64/python3.10"
	purelib = "/usr/local/lib/python3.10/site-packages"
	scripts = "/usr/local/bin"
	stdlib = "/usr/lib64/python3.10"

$ virtualenv --python /usr/bin/python3.11 test11
created virtual environment CPython3.11.0.beta.4-64 in 394ms
  creator CPython3Posix(dest=/tmp/test11, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(extra_search_dir=/usr/share/python-wheels,download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/lbalhar/.local/share/virtualenv)
    added seed packages: pip==22.1.2, setuptools==62.6.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

$ virtualenv --python /usr/bin/python3.10 test10
created virtual environment CPython3.10.5.final.0-64 in 320ms
  creator CPython3Posix(dest=/tmp/test10, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(extra_search_dir=/usr/share/python-wheels,download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/lbalhar/.local/share/virtualenv)
    added seed packages: pip==22.1.2, setuptools==62.3.2, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

$ tree -L 2 test11
test11
├── lib64
│   └── python3.11
├── local
│   ├── bin
│   ├── lib
│   └── lib64
└── pyvenv.cfg

$ tree -L 2 test10
test10
├── bin
│   ├── activate
│   ├── activate.csh
│   ├── activate.fish
│   ├── activate.nu
│   ├── activate.ps1
│   ├── activate_this.py
│   ├── deactivate.nu
│   ├── pip
│   ├── pip3
│   ├── pip-3.10
│   ├── pip3.10
│   ├── python -> /usr/bin/python3.10
│   ├── python3 -> python
│   ├── python3.10 -> python
│   ├── wheel
│   ├── wheel3
│   ├── wheel-3.10
│   └── wheel3.10
├── lib
│   └── python3.10
├── lib64
│   └── python3.10
└── pyvenv.cfg

frenzymadness avatar Jul 29 '22 08:07 frenzymadness

I don't know what I did but I'm no longer able to reproduce the issue. It works fine for me with Python 3.11 beta 4 and 5.

frenzymadness avatar Jul 29 '22 09:07 frenzymadness

I think Debian needs to adapt this change: https://github.com/deadsnakes/python3.10/commit/9b93d7313255aa00f018ab364d25719056386a12 -- what is the best channel to let them know?

More specifically:

_INSTALL_SCHEMES['venv'] = _INSTALL_SCHEMES['posix_prefix']

hroncok avatar Aug 02 '22 08:08 hroncok

I'm just going to cc @stefanor here and hope they will see it (the previous comment).

hroncok avatar Aug 02 '22 09:08 hroncok

More context in https://github.com/pypa/virtualenv/issues/2208

hroncok avatar Aug 02 '22 09:08 hroncok

Just ran into this as well and I have a few observations to add in case they're helpful. Firstly, I found #1663 which describes a different broken layout but a broken layout nonetheless and so maybe related? Secondly, the venv module works, including when used via the $ vritualenv --creator=... option:

rpatterson@rpatterson:~$ /usr/bin/python3 -m venv /tmp/venv1
rpatterson@rpatterson:~$ ls -al /tmp/venv1total 372
drwxrwxr-x  5 rpatterson rpatterson   4096 Aug 31 14:23 .
drwxrwxrwt 33 root       root       356352 Aug 31 14:23 ..
drwxrwxr-x  2 rpatterson rpatterson   4096 Aug 31 14:23 bin
drwxrwxr-x  2 rpatterson rpatterson   4096 Aug 31 14:23 include
drwxrwxr-x  3 rpatterson rpatterson   4096 Aug 31 14:23 lib
lrwxrwxrwx  1 rpatterson rpatterson      3 Aug 31 14:23 lib64 -> lib
-rw-rw-r--  1 rpatterson rpatterson     70 Aug 31 14:23 pyvenv.cfg
rpatterson@rpatterson:~$ /usr/bin/python3 -m virtualenv --creator venv /tmp/venv2                                                                                                                               
created virtual environment CPython3.10.4.final.0-64 in 94ms
  creator Venv(dest=/tmp/venv2, clear=False, no_vcs_ignore=False, global=False, describe=CPython3Posix)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/rpatterson/.local/share/virtualenv)
    added seed packages: pip==22.2.2, setuptools==65.3.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
rpatterson@rpatterson:~$ ls -al /tmp/venv2
total 380
drwxrwxr-x  6 rpatterson rpatterson   4096 Aug 31 14:23 .
drwxrwxrwt 34 root       root       356352 Aug 31 14:23 ..
drwxrwxr-x  2 rpatterson rpatterson   4096 Aug 31 14:23 bin
-rw-rw-r--  1 rpatterson rpatterson     40 Aug 31 14:23 .gitignore
drwxrwxr-x  2 rpatterson rpatterson   4096 Aug 31 14:23 include
drwxrwxr-x  3 rpatterson rpatterson   4096 Aug 31 14:23 lib
lrwxrwxrwx  1 rpatterson rpatterson      3 Aug 31 14:23 lib64 -> lib
drwxrwxr-x  4 rpatterson rpatterson   4096 Aug 31 14:23 local
-rw-rw-r--  1 rpatterson rpatterson    146 Aug 31 14:23 pyvenv.cfg

Finally for those running into this with tox, you may find tox-venv helpful.

rpatterson avatar Aug 31 '22 21:08 rpatterson

Besides what others in this thread have learned, I found that the problem exists when using an up to date setuptools but does not occur when using the python3-setuptools package provided by debian/ubuntu. This makes me think https://github.com/pypa/setuptools/issues/3278 is related to the problem.

What I'm unsure of is, doesn't virtualenv have a contract with its consumers that (regardless of the details of the Python it's creating an environment for) <env>/bin/activate, <env>/bin/python and so forth exist?

Edited to add: I guess this is not the case, since Windows uses "Scripts":

For a list of shells we provide activators see activators. The location of these is right alongside the python executables ( usually Scripts folder on Windows, bin on POSIX), and are named as activate (and some extension that’s specific per activator; no extension is bash). You can invoke them, usually by source-ing (the source command might vary by shell - e.g. bash is .):

jepler avatar Sep 07 '22 12:09 jepler

I'm just going to cc @stefanor here and hope they will see it (the previous comment).

Sorry, I missed this ping. I just found the bug via the commit in virtualenv. I was debugging this from the other end.

The ideal way to raise Debian issues is to file bugs in Debian's bugtracker. But also, feel free to email me / ping me on IRC / discord.

stefanor avatar Sep 15 '22 13:09 stefanor