Skip to content

Commit

Permalink
Fix for Issue 4588 (path to python improvements) (#5712)
Browse files Browse the repository at this point in the history
* Improve regex for python versions to handle hidden paths, and handle relative paths to python better as well.

* Check CI

* Attempt to remove make_posix call for windows

* Support pre-releases better.

* Vendor in latest pydantic as well and tempoarily patch the typing extensions with latest manually (next pip vendoring will bring it in).
  • Loading branch information
matteius authored Jun 2, 2023
1 parent be046bf commit 15c0ce0
Show file tree
Hide file tree
Showing 13 changed files with 938 additions and 342 deletions.
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

0 comments on commit 15c0ce0

Please sign in to comment.