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

Fixes installing versions with pyenv-win #4949

Merged
merged 3 commits into from
Feb 14, 2022
Merged

Fixes installing versions with pyenv-win #4949

merged 3 commits into from
Feb 14, 2022

Conversation

Jendoliver
Copy link
Contributor

@Jendoliver Jendoliver commented Feb 7, 2022

This fixes #4525

This issue has two parts:

  1. How pipenv calls pipenv-win.bat as mentioned by @uranusjr here.
  2. pyenv-win not supporting the -s/--skip-existing flags while pyenv does, as mentioned by @i3v here. Luckily this is done automatically in pyenv-win, and it does not ask for user input which I guess it's why it was added in the first place. I initially opened a PR in pyenv-win to add support for it but then realized more differences between the original vs the Windows versions which made me finally close it and go for this path.
  3. (extra) Pyenv support broken #3551 used to pop up after fixing 1 and 2, but now that it's fixed it doesn't happen anymore and pipenv correctly detects the installed Python version.

To fix it, I have ensured that shell=True is passed to subprocess_run when running the pyenv install code under Windows, and I've removed the -s from the pyenv install -s <version> command under the same conditions, since the final behaviour will be the same (no prompts and skip installation if it already exists).

My local tests, on Windows 10 and Ubuntu 20.04:

Test Pipfile:

[dev-packages]
click = "*"

[packages]

[requires]
python_version = "3.9.5"

pipenv output (with PIPENV_YES=1)

Windows 10
(pipenv-hqjmwcWy) pipenvC:\Users\JANDOL\PycharmProjects\pipenv\test_env>pipenv install
Warning: Python 3.9.5 was not found on your system...
Installing CPython 3.9.5 with C:\Users\JANDOL\.pyenv\pyenv-win\bin\pyenv (this may take a few minutes)...
Success!
:: [Info] ::  Mirror: https://www.python.org/ftp/python
:: [Installing] ::  3.9.5 ...
:: [Info] :: completed! 3.9.5

Creating a virtualenv for this project...
Pipfile: C:\Users\JANDOL\PycharmProjects\pipenv\test_env\Pipfile
Using C:/Users/JANDOL/.pyenv/pyenv-win/versions/3.9.5/python3.exe (3.9.5) to create virtualenv...
[=== ] Creating virtual environment...created virtual environment CPython3.9.5.final.0-64 in 887ms
  creator CPython3Windows(dest=C:\Users\JANDOL\.virtualenvs\test_env-H1w2rDID, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\JANDOL\AppData\Local\pypa\virtualenv)
    added seed packages: pip==21.3.1, setuptools==60.5.0, wheel==0.37.1
  activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

Successfully created virtual environment!
Virtualenv location: C:\Users\JANDOL\.virtualenvs\test_env-H1w2rDID
Installing dependencies from Pipfile.lock (04419a)...
  ================================ 0/0 - 00:00:00


(pipenv-hqjmwcWy) pipenvC:\Users\JANDOL\PycharmProjects\pipenv\test_env>pipenv install
Installing dependencies from Pipfile.lock (04419a)...
  ================================ 0/0 - 00:00:00
Ubuntu 20.04
((pipenv) ) aalvarez@aalvarez-Precision-7550:~/src/personal/pipenv/test_env (main)$ pipenv install
Warning: Python 3.9.5 was not found on your system...
Installing CPython 3.9.5 with /home/aalvarez/.pyenv/bin/pyenv (this may take a few minutes)...
✔ Success! 

Creating a virtualenv for this project...
Pipfile: /home/aalvarez/src/personal/pipenv/test_env/Pipfile
Using /home/aalvarez/.pyenv/versions/3.9.5/bin/python3.9 (3.9.5) to create virtualenv...
⠸ Creating virtual environment...created virtual environment CPython3.9.5.final.0-64 in 228ms
  creator CPython3Posix(dest=/home/aalvarez/.local/share/virtualenvs/test_env-6zfULtvW, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/aalvarez/.local/share/virtualenv)
    added seed packages: pip==21.3.1, setuptools==60.5.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
✔ Successfully created virtual environment! 
Virtualenv location: /home/aalvarez/.local/share/virtualenvs/test_env-6zfULtvW
Installing dependencies from Pipfile.lock (04419a)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.


((pipenv) ) aalvarez@aalvarez-Precision-7550:~/src/personal/pipenv/test_env (main)$ pipenv install
Installing dependencies from Pipfile.lock (04419a)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.

Thank you very much for your time, I'll be happy to change/update things if required 😄

@Jendoliver Jendoliver changed the title Pass shell=True to subprocess_run for pyenv commands under Windows Fixes installing versions with pyenv-win Feb 7, 2022
@oz123 oz123 self-requested a review February 10, 2022 10:11
Copy link
Contributor

@oz123 oz123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I don't have windows to test myself, but it seems reasonable.

@oz123 oz123 merged commit 9e1e758 into pypa:main Feb 14, 2022
@oz123 oz123 added the OS: Windows This issue affects the Windows Operating System. label Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS: Windows This issue affects the Windows Operating System.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add pyenv-win support
2 participants