-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[BUG] setuptools>=60.0.0 causes virtualenv to create abnormal tree structure on ubuntu 22.04 #3278
Comments
Workaround / fixI have verified with 62.1.0 that changing
to
Solves the problem. See also |
Thank you very much @danielhoherd for reporting this. I did a quick experiment with Fedora: > docker run --rm -it fedora:35
python3 -VV
# Python 3.10.2 (main, Jan 17 2022, 00:00:00) [GCC 11.2.1 20211203 (Red Hat 11.2.1-7)]
dnf install -y tree python3-pip python3-virtualenv
dnf remove -y python3-setuptools
pip --version
# pip 21.2.3 from /usr/lib/python3.10/site-packages/pip (python 3.10)
virtualenv --version
# virtualenv 20.8.1 from /usr/lib/python3.10/site-packages/virtualenv/__init__.py
python3 -m pip install setuptools==62.1.0 ; \
virtualenv venv ; \
tree -L 3 venv ; \
. venv/bin/activate And this seems to be working fine (unless there is something wrong with the script above, or something I did not manage to reproduce quite right): venv
├── bin
│ ├── activate
│ ├── activate.csh
│ ├── activate.fish
│ ├── activate.nu
│ ├── activate.ps1
│ ├── activate_this.py
│ ├── deactivate.nu
│ ├── pip
│ ├── pip-3.10
│ ├── pip3
│ ├── pip3.10
│ ├── python -> /usr/bin/python3
│ ├── python3 -> python
│ ├── python3.10 -> python
│ ├── wheel
│ ├── wheel-3.10
│ ├── wheel3
│ └── wheel3.10
├── lib
│ └── python3.10
│ └── site-packages
├── lib64
│ └── python3.10
│ └── site-packages
└── pyvenv.cfg If this behaviour is specific to debian based distributions... Is there any chance it is being caused by the customisations enabled by the _distutils_system_mod hook? Regarding the suggested fix, I don't think the The way best going forward would be finding out how the latest changes in https://github.com/pypa/disutils are affecting the installation schemas/templates used by virtualenv and think how we can fix that while still keeping the latest improvements. |
@abravalheri I was able to replicate your fedora experiment. You may be right that this is specific to debian distros, but it seems only new distros. I was not able to recreate the issue on:
But I was able to recreate my original report using the following images:
Here's a quick snip to test out the original condition:
I was unable to reproduce this on fedora 35, 36, 37 |
Hi @danielhoherd, I also checked it with Alpine Linux and could not reproduce the error: > docker run --rm -it alpine:3.15.4
apk add --update python3 py3-pip tree
python3 -m pip install -U setuptools==62.1.0 virtualenv
python3 -m virtualenv venv
tree -L 3 venv
venv
├── bin
│ ├── activate
│ ├── activate.csh
│ ├── activate.fish
│ ├── activate.nu
│ ├── activate.ps1
│ ├── activate_this.py
│ ├── deactivate.nu
│ ├── pip
│ ├── pip-3.9
│ ├── pip3
│ ├── pip3.9
│ ├── python -> /usr/bin/python3
│ ├── python3 -> python
│ ├── python3.9 -> python
│ ├── wheel
│ ├── wheel-3.9
│ ├── wheel3
│ └── wheel3.9
├── lib
│ └── python3.9
│ └── site-packages
└── pyvenv.cfg There seems to be a chance the potential fix requires some coordination between _distutils_system_mod and the usage @jaraco do you have any thoughts about this issue? |
I just upgraded multiple computers to Ubuntu 22.04 and all of them have this problem. Replacing |
Having this issue on WSL Ubuntu 22.04. This |
The following snip passes on every failing debian based image listed above:
|
Yes, I think you're right. The fact that the workarounds above happen to work around the issue is because they're disabling the transitional codepath where setuptools supplies distutils. I observe the issue does not occur when using |
I used this dockerfile: from ubuntu:22.04
RUN apt update
RUN apt install -y python3 python3-pip python3-virtualenv tree
RUN pip install -U setuptools
RUN virtualenv venv
CMD tree -L 3 venv Because it allows me to see the failed expectation but also replace it and inspect the environment. The problem can be observed by adding a breakpoint to
And inspecting the value:
The fact that My guess is that something about the assumptions made between Probably what we need is someone from virtualenv to analyze what expectation is being missed here and determine what's the best way to meet that expectation. @gaborbernat Do you have any advice here? I also observe that virtualenv has a codepath that bypasses distutils if a @doko42, It does appear to me you authored the patch. Will you be able to help work through this issue? |
Yes, the easiest way to fix this would be for Debian to provide a cc @stefanor |
*** Tests (all manual so far): - Ubuntu 22.04 / python3 3.10 / NO python3-distutils: ** problem fixed - Ubuntu 22.04 / python3 3.10 / WITH python3-distutils: ** still working - Debian 11 / python3 3.10 / WITH python3-distutils: ** still working - Debian 11 / python3 3.10 / WITHOUT python3-distutils: ** ok error msg *** Bugs in previous code: - Deb 11 w/o python3-distutils fails to install bootstrap pip, prints a message, and should stop, but instead goes on with "Installing bootstrap virtualenv". - Also separate commit to add commented-out "head-of-main" thing below. *** Changes since last good commit (some need to be moved to other commits) - pactivate: - Add commented-out "head of main" package for virtualenv - XXX move to a separate commit - add DEB_PYTHON_INSTALL_LAYOUT workaround - cont-test: - remove the debugging - XXX keep a check for pactivate failure: (. ./$pactivate) || fail "pactivate failed: return code $?" - XXX keep large comment about system python 3.10.x *** Stuff to document print(sysconfig.get_default_scheme()) [2350]: pypa/virtualenv#2350 [au 1415153]: https://askubuntu.com/a/1415153/354600 [2415]: https://github.com/pypa/virtualenv/pull/2415/files?diff=unified&w=0 *** Maybe document pypa/setuptools#3278
*** Tests (all manual so far): - Ubuntu 22.04 / python3 3.10 / NO python3-distutils: ** problem fixed - Ubuntu 22.04 / python3 3.10 / WITH python3-distutils: ** still working - Debian 11 / python3 3.10 / WITH python3-distutils: ** still working - Debian 11 / python3 3.10 / WITHOUT python3-distutils: ** ok error msg *** To-do: - Discuss what we want to do for testing of the workaround. Currently we test only in debian:11, which confirms that the workaround does not affect that (where it's not needed) but does _not_ confirm that the workaround does work where it is needed (ubuntu:22.04 w/o python3-distutils). *** Bugs in previous code: - Deb 11 w/o python3-distutils fails to install bootstrap pip, prints a message, and should stop, but instead goes on with "Installing bootstrap virtualenv". - Also separate commit to add commented-out "head-of-main" thing below. *** Changes since last good commit (some need to be moved to other commits) - pactivate: - Add commented-out "head of main" package for virtualenv - XXX move to a separate commit - add DEB_PYTHON_INSTALL_LAYOUT workaround - cont-test: - remove the debugging - XXX keep a check for pactivate failure: (. ./$pactivate) || fail "pactivate failed: return code $?" - XXX keep large comment about system python 3.10.x *** Stuff to document print(sysconfig.get_default_scheme()) [2350]: pypa/virtualenv#2350 [au 1415153]: https://askubuntu.com/a/1415153/354600 [2415]: https://github.com/pypa/virtualenv/pull/2415/files?diff=unified&w=0 *** Maybe document pypa/setuptools#3278
*** Tests (all manual so far): - Ubuntu 22.04 / python3 3.10 / NO python3-distutils: ** problem fixed - Ubuntu 22.04 / python3 3.10 / WITH python3-distutils: ** still working - Debian 11 / python3 3.10 / WITH python3-distutils: ** still working - Debian 11 / python3 3.10 / WITHOUT python3-distutils: ** ok error msg *** To-do: - Discuss what we want to do for testing of the workaround. Currently we test only in debian:11, which confirms that the workaround does not affect that (where it's not needed) but does _not_ confirm that the workaround does work where it is needed (ubuntu:22.04 w/o python3-distutils). *** Bugs in previous code: - Deb 11 w/o python3-distutils fails to install bootstrap pip, prints a message, and should stop, but instead goes on with "Installing bootstrap virtualenv". - Also separate commit to add commented-out "head-of-main" thing below. *** Changes since last good commit (some need to be moved to other commits) - pactivate: - Add commented-out "head of main" package for virtualenv - XXX move to a separate commit - add DEB_PYTHON_INSTALL_LAYOUT workaround - cont-test: - remove the debugging - XXX keep a check for pactivate failure: (. ./$pactivate) || fail "pactivate failed: return code $?" - XXX keep large comment about system python 3.10.x *** Stuff to document print(sysconfig.get_default_scheme()) [2350]: pypa/virtualenv#2350 [au 1415153]: https://askubuntu.com/a/1415153/354600 [2415]: https://github.com/pypa/virtualenv/pull/2415/files?diff=unified&w=0 *** Maybe document pypa/setuptools#3278
*** Tests (all manual so far): ----- Debian package ------ Tested on python3 python3-distutils result after fix ────────────────────────────────────────────────────────────────────── Ubuntu 22.04 3.10 NO problem fixed Ubuntu 22.04 3.10 YES still working Debian 11 3.9 YES still working Debian 11 3.9 NO fails with clear message *** To-do: - Discuss what we want to do for testing of the workaround. Currently we test only in debian:11, which confirms that the workaround does not affect that (where it's not needed) but does _not_ confirm that the workaround does work where it is needed (ubuntu:22.04 w/o python3-distutils). *** Bugs in previous code: - Deb 11 w/o python3-distutils fails to install bootstrap pip, prints a message, and should stop, but instead goes on with "Installing bootstrap virtualenv". - Also separate commit to add commented-out "head-of-main" thing below. *** Changes since last good commit (some need to be moved to other commits) - pactivate: - Add commented-out "head of main" package for virtualenv - XXX move to a separate commit - add DEB_PYTHON_INSTALL_LAYOUT workaround - cont-test: - remove the debugging - XXX keep a check for pactivate failure: (. ./$pactivate) || fail "pactivate failed: return code $?" - XXX keep large comment about system python 3.10.x *** Stuff to document print(sysconfig.get_default_scheme()) [2350]: pypa/virtualenv#2350 [au 1415153]: https://askubuntu.com/a/1415153/354600 [2415]: https://github.com/pypa/virtualenv/pull/2415/files?diff=unified&w=0 *** Maybe document pypa/setuptools#3278
I've filed a bug with Debian about this problem, since as far as I can tell nobody explicitly informed them that there is a problem: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1022749 |
Ran into the same bug under Linux Mint 21 with Python 3.10
This "work-a-round" works for me, e.g.:
|
Create .venv, so that Poetry will use it. See: pypa/setuptools#3278 (comment)
I saw a setuptools CVE today so I came back to revisit this, and it appears that this is no longer an issue on ubuntu 22.04 with all the latest packages. I'm not sure what solved the issue though. I just ran a several tests with setuptools==65.6.3 (which required me to install python3.10-venv, which was version 3.10.6-1~22.04.2) and was unable to reproduce the original problem. This is also not a problem with the current ubuntu 22.04 system setuptools, which is 59.6.0-1.2 and likely never had the problem. |
Likely due to this pypa/virtualenv#2415 as I can easily recreate this when using an older virtualenv version. |
any progress with this? I tried almost everything... even doing I am in Ubuntu Mantic (23.10) |
@khaled4vokalz please check the comments above, specially #3278 (comment), #3278 (comment). Please note that the problem might not have an official solution for the specific combination of Python/OS/ |
setuptools 60 didn't ship in Ubuntu 22.04, it came later in 23.04. The setuptools solution to this problem is the addition of the I suggest leaving your system setuptools as shipped by Ubuntu, and using the system Or use |
As I review this, I believe there's nothing more for Setuptools to do here, so I'm closing the ticket. Happy to re-open if that's not the case. |
thank you |
setuptools version
setuptools 60, 61, 62
59.x was the last version I found to not cause trouble. This also happens to be the default version installed with ubuntu 22.04 via apt.
Python version
Python 3.10
OS
Ubuntu 22.04
Also, I was unable to reproduce this on python:3.10-buster
Additional environment information
No response
Description
Installing setuptools==62.1.0 causes
virtualenv venv
to create an abnormal directory structure. Uninstalling setuptools solves the problem. This is 100% reproducible inubuntu:22.04
docker image (ubuntu@sha256:06b5d30fabc1fc574f2ecab87375692299d45f8f190d9b71f512deb494114e1f
)The failure of virtualenv also affects poetry, which has no error checking for venv activate and will attempt to modify system packages when it thinks the venv is activated but it is not.
Without setuptools,
venv/bin
exists. With setuptools,venv/local/bin
exists and novenv/bin
dir exists.Expected behavior
Setuptools does not interfere with virtualenv directory structure.
How to Reproduce
Output
The text was updated successfully, but these errors were encountered: