Skip to content

Commit

Permalink
Updated logic for determining available python version string.
Browse files Browse the repository at this point in the history
  • Loading branch information
matteius authored and oz123 committed Oct 22, 2024
1 parent b895476 commit 7826f21
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pipenv/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,12 @@ def safe_import(self, name: str) -> ModuleType:
def python_version(self) -> str | None:
with self.activated() as active:
if active:
sysconfig = self.safe_import("sysconfig")
py_version = sysconfig.get_python_version()
return py_version
from pipenv.patched.pip._vendor.packaging.version import Version

# Extract version parts
version_str = f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
python_version = Version(version_str) # Create PEP 440 compliant version
return str(python_version) # Return the string representation
else:
return None

Expand Down

0 comments on commit 7826f21

Please sign in to comment.