New virtualenvs contain unwanted libraries
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python-pip (Ubuntu) |
Fix Released
|
Medium
|
Unassigned | ||
Focal |
Fix Released
|
Medium
|
Unassigned | ||
python-virtualenv (Ubuntu) |
Fix Released
|
Medium
|
Unassigned | ||
Focal |
Fix Committed
|
Medium
|
Unassigned |
Bug Description
[Impact]
* Virtualenvs created on Ubuntu 20.04 are not as empty as they are
expected to be. They are expected to contain pip and setuptools.
But the way pip's vendored dependencies were de-vendored resulted
in the libraries being exposed in the new virtualenv.
This was a side-effect of packaging the (rewritten) virtualenv 20.
It should have been resolved pre-release, but wasn't.
* The behaviour is radically different to upstream virtualenv and
not what was expected by Python developers.
[Test Case]
# apt install python3 virtualenv
$ virtualenv -p python3 foo
$ foo/bin/python -m pip freeze
Should output nothing. In Ubuntu 20.04, it lists 24 packages.
[Where problems could occur]
* Anyone who has discovered this change and now expects it will be in
for a surprise. I'd expect this to be rare, as there are workarounds
instead (e.g. venv or upstream virtualenv).
* The patch could have issues too. It is close to what is currently in
Debian unstable & later Ubuntu releases, and seems to be working
correctly.
[Other Info]
* See also LP: #1880749 which is fixed in the same patch.
[Original Report]
Since updating to ubuntu 20.04, whenever I create a virtual environment with `virtualenv` it contains many unwanted libraries. Unsetting PYTHONPATH, setting the `--python` flag to a different version, etc does not fix the issue. I could run it with `--no-seed` but then the new venv doesn't even have pip.
I found another user who has the exact same issue posting about it on stackoverflow and the list of packages which were installed by default is the same, this leads me to believe that something is wrong with the package itself and not a local config issue.
`https:/
This is the output from creating a virtualenv:
```
➜ virtualenv --python=
created virtual environment CPython3.
creator CPython3Posix(
seeder FromAppData(
activators BashActivator,
```
And these exact package versions are what get installed by default.
```
appdirs==1.4.3
CacheControl=
certifi==2019.11.28
chardet==3.0.4
colorama==0.4.3
contextlib2==0.6.0
distlib==0.3.0
distro==1.4.0
html5lib==1.0.1
idna==2.8
ipaddr==2.2.0
lockfile==0.12.2
msgpack==0.6.2
packaging==20.3
pep517==0.8.2
progress==1.5
pyparsing==2.4.6
pytoml==0.1.21
requests==2.22.0
retrying==1.3.3
six==1.14.0
urllib3==1.25.8
webencodings==0.5.1
```
All of the packages above are in the folder `~/.local/
Creating a venv with `python3 -m venv path/to/venv` gives me a clean environment with no extra packages which is my current workaround.
System Info:
lsb_release -rd
Description: Ubuntu 20.04.1 LTS
Release: 20.04
apt-cache policy python3-virtualenv
python3-virtualenv:
Installed: 20.0.17-1
Candidate: 20.0.17-1
Version table:
*** 20.0.17-1 500
500 http://
500 http://
100 /var/lib/
ProblemType: Bug
DistroRelease: Ubuntu 20.04
Package: python3-virtualenv 20.0.17-1
ProcVersionSign
Uname: Linux 5.4.0-53-generic x86_64
NonfreeKernelMo
ApportVersion: 2.20.11-
Architecture: amd64
CasperMD5CheckR
CurrentDesktop: ubuntu:GNOME
Date: Thu Nov 19 18:54:36 2020
InstallationDate: Installed on 2020-05-11 (192 days ago)
InstallationMedia: Ubuntu 20.04 LTS "Focal Fossa" - Release amd64 (20200423)
PackageArchitec
ProcEnviron:
TERM=xterm-
PATH=(custom, no user)
XDG_RUNTIME_
LANG=en_US.UTF-8
SHELL=/usr/bin/zsh
SourcePackage: python-virtualenv
UpgradeStatus: No upgrade log present (probably fresh install)
description: | updated |
Changed in python-pip (Ubuntu): | |
importance: | Undecided → Medium |
Changed in python-pip (Ubuntu Focal): | |
importance: | Undecided → Medium |
Changed in python-virtualenv (Ubuntu): | |
importance: | Undecided → Medium |
Changed in python-virtualenv (Ubuntu Focal): | |
importance: | Undecided → Medium |
The issue is a result of devendoring the pip dependencies. See the discussion in #1880749. It was improved in Ubuntu 20.10, but too late for Focal.