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

Fix for Issue 4588 (path to python improvements) #5712

Merged
merged 7 commits into from
Jun 2, 2023
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/4588.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve regex for python versions to handle hidden paths; handle relative paths to python better as well.
9 changes: 7 additions & 2 deletions pipenv/installers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@ def __str__(self):

@classmethod
def parse(cls, name):
"""Parse an X.Y.Z or X.Y string into a version tuple."""
match = re.match(r"^(\d+)\.(\d+)(?:\.(\d+))?$", name)
"""Parse an X.Y.Z, X.Y, or pre-release version string into a version tuple."""
match = re.match(r"^(\d+)\.(\d+)(?:\.(\d+))?(a|b|rc)?(\d+)?$", name)
if not match:
raise ValueError(f"invalid version name {name!r}")
major = int(match.group(1))
minor = int(match.group(2))
patch = match.group(3)
# prerelease = match.group(4) # Not used
# prerelease_num = match.group(5)

if patch is not None:
patch = int(patch)

# Return prerelease tag and number if they exist
return cls(major, minor, patch)

@property
Expand Down
Loading