Skip to content
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

virtualenv silently ignores requested pip version if not available #2485

Open
ericriff opened this issue Jan 12, 2023 · 5 comments
Open

virtualenv silently ignores requested pip version if not available #2485

ericriff opened this issue Jan 12, 2023 · 5 comments

Comments

@ericriff
Copy link

ericriff commented Jan 12, 2023

Issue
I'm trying to pin the version of pip my virtual envs will have, regardless of the version of virtualenv being used. I realized that if the requested pip version is not available then virtualenv just picks the latets, silently.

Check the following example where I request an older pip version, 20.0.1, but I end up with 22.3.1. On the other hand, if I request 20.0.2 it works as expected.

$ virtualenv /tmp/.venv --python 3.8 --verbose --pip==20.0.1           
find interpreter for spec PythonSpec(major=3, minor=8)
proposed PythonInfo(spec=CPython3.8.10.final.0-64, exe=/usr/bin/python3, platform=linux, version='3.8.10 (default, Nov 14 2022, 12:59:47) \n[GCC 9.4.0]', encoding_fs_io=utf-8-utf-8)
create virtual environment via CPython3Posix(dest=/tmp/.venv, clear=False, global=False)
add seed packages via FromAppData(download=False, pip==20.0.1, setuptools=latest, wheel=latest, pkg_resources=latest, via=copy, app_data_dir=/home/eriff/.local/share/virtualenv/seed-app-data/v1.0.1.debian.1)
changing mode of /tmp/.venv/bin/wheel to 775
changing mode of /tmp/.venv/bin/wheel-3.8 to 775
changing mode of /tmp/.venv/bin/wheel3 to 775
changing mode of /tmp/.venv/bin/easy_install3 to 775
changing mode of /tmp/.venv/bin/easy_install to 775
changing mode of /tmp/.venv/bin/easy_install-3.8 to 775
add activators for Bash, CShell, Fish, PowerShell, Python, Xonsh
created virtual environment CPython3.8.10.final.0-64 in 57ms
  creator CPython3Posix(dest=/tmp/.venv, clear=False, global=False)
  seeder FromAppData(download=False, pip==20.0.1, setuptools=latest, wheel=latest, pkg_resources=latest, via=copy, app_data_dir=/home/eriff/.local/share/virtualenv/seed-app-data/v1.0.1.debian.1)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator


$ source /tmp/.venv/bin/activate
$ pip --version
pip 22.3.1 from /home/eriff/.local/lib/python3.8/site-packages/pip (python 3.8)

Environment

Provide at least:

  • OS: Ubuntu 20.04
  • pip list of the host python where virtualenv is installed:
appdirs                 1.4.3
apturl                  0.5.2
attrs                   19.3.0
backcall                0.1.0
bcrypt                  3.1.7
bleach                  3.1.1
blinker                 1.4
bottle                  0.12.23
Brlapi                  0.7.0
certifi                 2019.11.28
chardet                 3.0.4
charset-normalizer      2.1.1
chrome-gnome-shell      0.0.0
Click                   7.0
cmake                   3.24.1.1
cmakelang               0.6.13
cmakelint               1.4.2
colorama                0.4.3
command-not-found       0.3
conan                   1.55.0
cppclean                0.13
cryptography            2.8
cupshelpers             1.0
dbus-python             1.2.16
decorator               4.4.2
deepdiff                6.2.3
defer                   1.0.6
defusedxml              0.6.0
distlib                 0.3.0
distro                  1.4.0
distro-info             0.23ubuntu1
duplicity               0.8.12.0
entrypoints             0.3
exceptiongroup          1.0.0
fasteners               0.14.1
filelock                3.0.12
fire                    0.3.1
future                  0.18.2
html5lib                1.0.1
httplib2                0.14.0
idna                    2.8
importlib-metadata      1.5.0
iniconfig               1.1.1
ipykernel               5.2.0
ipython                 7.13.0
ipython_genutils        0.2.0
ipywidgets              6.0.0
jedi                    0.15.2
Jinja2                  3.1.2
jsonschema              3.2.0
jupyter-client          6.1.2
jupyter-console         6.0.0
jupyter-core            4.6.3
keyring                 18.0.1
language-selector       0.1
launchpadlib            1.10.13
lazr.restfulclient      0.14.2
lazr.uri                1.0.3
lockfile                0.12.2
louis                   3.12.0
macaroonbakery          1.3.1
Mako                    1.1.0
MarkupSafe              2.1.1
meld                    3.20.2
mistune                 0.8.4
monotonic               1.5
more-itertools          4.2.0
nbconvert               5.6.1
nbformat                5.0.4
netifaces               0.10.4
ninja                   1.11.1
node-semver             0.6.1
notebook                6.0.3
numpy                   1.21.0
oauthlib                3.1.0
olefile                 0.46
ordered-set             4.1.0
orjson                  3.8.5
packaging               21.3
pandocfilters           1.4.2
paramiko                2.6.0
parso                   0.5.2
patch-ng                1.17.4
pdfcrowd                5.8.0
pexpect                 4.6.0
pickleshare             0.7.5
Pillow                  7.0.0
pip                     22.3.1
pluggy                  1.0.0
pluginbase              1.0.1
prometheus-client       0.7.1
prompt-toolkit          2.0.10
protobuf                3.6.1
pycairo                 1.16.2
pycups                  1.9.73
Pygments                2.3.1
PyGObject               3.36.0
PyJWT                   2.4.0
pymacaroons             0.13.0
PyNaCl                  1.3.0
pyparsing               3.0.9
pyRFC3339               1.1
pyrsistent              0.15.5
pytest                  7.2.0
python-apt              2.0.0+ubuntu0.20.4.8
python-dateutil         2.7.3
python-debian           0.1.36ubuntu1
pytz                    2019.3
pyxdg                   0.26
PyYAML                  5.3.1
pyzmq                   18.1.1
reportlab               3.5.34
requests                2.28.1
requests-unixsocket     0.2.0
screen-resolution-extra 0.0.0
SecretStorage           2.3.1
Send2Trash              1.5.0
setuptools              45.2.0
Shapely                 1.7.1
simplejson              3.16.0
six                     1.14.0
termcolor               2.1.0
terminado               0.8.2
testpath                0.4.4
tomli                   2.0.1
tornado                 5.1.1
tqdm                    4.64.1
traitlets               4.3.3
ubuntu-advantage-tools  27.12
ubuntu-drivers-common   0.0.0
ufw                     0.36
unattended-upgrades     0.1
urllib3                 1.26.12
usb-creator             0.3.7
virtualenv              20.0.17
wadllib                 1.3.3
wcwidth                 0.1.8
webencodings            0.5.1
wheel                   0.34.2
widgetsnbextension      2.0.0
xkit                    0.0.0
zipp                    1.0.0

Output of the virtual environment creation

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

virtualenv /tmp/.venv --python 3.8 --verbose --pip==20.0.1 --with-traceback
find interpreter for spec PythonSpec(major=3, minor=8)
proposed PythonInfo(spec=CPython3.8.10.final.0-64, exe=/usr/bin/python3, platform=linux, version='3.8.10 (default, Nov 14 2022, 12:59:47) \n[GCC 9.4.0]', encoding_fs_io=utf-8-utf-8)
create virtual environment via CPython3Posix(dest=/tmp/.venv, clear=False, global=False)
add seed packages via FromAppData(download=False, pip==20.0.1, setuptools=latest, wheel=latest, pkg_resources=latest, via=copy, app_data_dir=/home/eriff/.local/share/virtualenv/seed-app-data/v1.0.1.debian.1)
changing mode of /tmp/.venv/bin/wheel-3.8 to 775
changing mode of /tmp/.venv/bin/wheel3 to 775
changing mode of /tmp/.venv/bin/wheel to 775
changing mode of /tmp/.venv/bin/easy_install to 775
changing mode of /tmp/.venv/bin/easy_install-3.8 to 775
changing mode of /tmp/.venv/bin/easy_install3 to 775
add activators for Bash, CShell, Fish, PowerShell, Python, Xonsh
created virtual environment CPython3.8.10.final.0-64 in 98ms
  creator CPython3Posix(dest=/tmp/.venv, clear=False, global=False)
  seeder FromAppData(download=False, pip==20.0.1, setuptools=latest, wheel=latest, pkg_resources=latest, via=copy, app_data_dir=/home/eriff/.local/share/virtualenv/seed-app-data/v1.0.1.debian.1)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
@ericriff ericriff added the bug label Jan 12, 2023
@gaborbernat
Copy link
Contributor

PR welcome.

@jalajk24
Copy link

Can I work on this one? I am pretty new to this

@kemzeb
Copy link

kemzeb commented May 10, 2023

Found this issue and after trying to reproduce the problem I seem to retrieve the expected pip version on my machine (using Ubuntu 22.04 on WSL and virtualenv 20.23.0). Note that I also used pyenv to install version 3.8.10.

Using the same command (added --with-traceback) and Python/pip versions:

➜  prac pip -V
pip 21.1.1 from /home/kemzeb/.pyenv/versions/3.8.10/lib/python3.8/site-packages/pip (python 3.8)
➜  prac virtualenv /tmp/.venv --python 3.8 --verbose --pip==20.0.1 --with-traceback
find interpreter for spec PythonSpec(major=3, minor=8)
proposed PythonInfo(spec=CPython3.8.10.final.0-64, exe=/home/kemzeb/.pyenv/versions/3.8.10/bin/python3.8, platform=linux, version='3.8.10 (default, May 10 2023, 11:35:41) \n[GCC 11.3.0]', encoding_fs_io=utf-8-utf-8)
create virtual environment via CPython3Posix(dest=/tmp/.venv, clear=False, no_vcs_ignore=False, global=False)
add seed packages via FromAppData(download=False, pip==20.0.1, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/kemzeb/.local/share/virtualenv)
pip-20.0.1-py2.py3-none-any.whl already present in /home/kemzeb/.local/share/virtualenv/wheel/3.8/embed/3/pip.json
add activators for Bash, CShell, Fish, Nushell, PowerShell, Python
created virtual environment CPython3.8.10.final.0-64 in 1527ms
  creator CPython3Posix(dest=/tmp/.venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip==20.0.1, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/kemzeb/.local/share/virtualenv)
    added seed packages: pip==20.0.1, setuptools==67.7.2, wheel==0.40.0
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
➜  prac source /tmp/.venv/bin/activate
(.venv) ➜  prac pip -V
pip 20.0.1 from /tmp/.venv/lib/python3.8/site-packages/pip (python 3.8)
(.venv) ➜  prac

I also upgraded my global pip to 23.1.2 to see if that somehow has changed anything but got the same results.

I don't have knowledge of how virtualenv works, but my educated guess is your printout looks weird as when you used pip --version during your virtualenv session the path provided points to your global pip instead of an installed seed package version of pip. I did install the version of virtualenv that you were using at the time (20.0.17) and ran right into this problem.

On virtualenv 20.23.0, this seems to be no longer an issue (at least on my machine).

@gaborbernat
Copy link
Contributor

PR welcome.

@kemzeb
Copy link

kemzeb commented May 10, 2023

I apologize as I must have not worded my comment in a better way. I ran the version of virtualenv that the author used (20.0.17) and using the same command and Python/pip version given I was able to reproduce this problem. But when I ran using virtualenv 20.23.0, I was given the expected pip version when running pip --version within a virtualenv session. At least on my machine, this doesn't appear to be a problem anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
@gaborbernat @jalajk24 @ericriff @kemzeb and others