Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/6425.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure the requested Python version is installed when it differs from the one used with Pipenv.
64 changes: 29 additions & 35 deletions pipenv/utils/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,43 +324,37 @@ def abort(msg=""):
if not (project.s.PIPENV_YES or Confirm.ask("".join(s), default=True)):
abort()
elif not project.s.PIPENV_YES:
# Non-interactive session without PIPENV_YES, proceed with installation
# Non-interactive session without PIPENV_YES, aborting installation
abort()
else:
# Tell the user we're installing Python.
console.print(
f"[bold]Installing [green]CPython[/green] {version} with {installer.cmd}[/bold]"
)
console.print("(this may take a few minutes)[bold]...[/bold]")
with console.status(
"Installing python...", spinner=project.s.PIPENV_SPINNER
):
try:
c = installer.install(version)
except InstallerError as e:
err.print(
environments.PIPENV_SPINNER_FAIL_TEXT.format("Failed...")
)
err.print("Something went wrong...")
err.print(f"[cyan]{e.err}[/cyan]")
else:
console.print(
environments.PIPENV_SPINNER_OK_TEXT.format("Success!")
)
# Print the results, in a beautiful blue...
err.print(f"[cyan]{c.stdout}[/cyan]")
# Find the newly installed Python, hopefully.
version = str(version)
path_to_python = find_a_system_python(version)

# Tell the user we're installing Python.
console.print(
f"[bold]Installing [green]CPython[/green] {version} with {installer.cmd}[/bold]"
)
console.print("(this may take a few minutes)[bold]...[/bold]")
with console.status("Installing python...", spinner=project.s.PIPENV_SPINNER):
try:
assert python_version(path_to_python) == version
except AssertionError:
err.print(
"[bold][red]Warning:[/red][/bold]"
" The Python you just installed is not available "
"on your [bold]PATH[/bold], apparently."
)
sys.exit(1)
c = installer.install(version)
except InstallerError as e:
err.print(environments.PIPENV_SPINNER_FAIL_TEXT.format("Failed..."))
err.print("Something went wrong...")
err.print(f"[cyan]{e.err}[/cyan]")
else:
console.print(environments.PIPENV_SPINNER_OK_TEXT.format("Success!"))
# Print the results, in a beautiful blue...
err.print(f"[cyan]{c.stdout}[/cyan]")
# Find the newly installed Python, hopefully.
version = str(version)
path_to_python = find_a_system_python(version)
try:
assert python_version(path_to_python) == version
except AssertionError:
err.print(
"[bold][red]Warning:[/red][/bold]"
" The Python you just installed is not available "
"on your [bold]PATH[/bold], apparently."
)
sys.exit(1)
return path_to_python


Expand Down
Loading