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

Updated logic for determining available python version string. #6278

Merged
merged 1 commit into from
Oct 22, 2024
Merged
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
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
Loading