-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Handle unsupported python versioning on Pipfile #6164
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Pipenv only supports absolute python version. If the user specifies a Python version with inequality signs like >=3.12, <3.12 in the [requires] field, the code has been modified to explicitly express in an error log that absolute versioning must be used. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import contextlib | ||
import os | ||
import re | ||
import shutil | ||
import sys | ||
from pathlib import Path | ||
|
@@ -237,6 +238,22 @@ def abort(msg=""): | |
# Find out which python is desired. | ||
if not python: | ||
python = project.required_python_version | ||
if python: | ||
range_pattern = r"^[<>]=?|!=" | ||
if re.search(range_pattern, python): | ||
click.echo( | ||
"{}: Python version range specifier '{}' is not supported. {}".format( | ||
click.style("Error", fg="red", bold=True), | ||
click.style(python, fg="cyan"), | ||
click.style( | ||
"Please use an absolute version number or specify the path to the Python executable on Pipfile.", | ||
fg="yellow", | ||
), | ||
), | ||
err=True, | ||
) | ||
abort() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @matteius I'll think about it more about how to handle the runtime errors in another ways. It would be glad for me for you to recommend some references if it's available! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about |
||
|
||
if not python: | ||
python = project.s.PIPENV_DEFAULT_PYTHON_VERSION | ||
path_to_python = find_a_system_python(python) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have been migrating away from click.echo to use the rich console -- you can find other examples in the code of how to print the equivalent thing using that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matteius Thanks for guidance. I'll check and modify it to the convention.