Skip to content

Commit 7826f21

Browse files
matteiusoz123
authored andcommitted
Updated logic for determining available python version string.
1 parent b895476 commit 7826f21

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pipenv/environment.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,12 @@ def safe_import(self, name: str) -> ModuleType:
101101
def python_version(self) -> str | None:
102102
with self.activated() as active:
103103
if active:
104-
sysconfig = self.safe_import("sysconfig")
105-
py_version = sysconfig.get_python_version()
106-
return py_version
104+
from pipenv.patched.pip._vendor.packaging.version import Version
105+
106+
# Extract version parts
107+
version_str = f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
108+
python_version = Version(version_str) # Create PEP 440 compliant version
109+
return str(python_version) # Return the string representation
107110
else:
108111
return None
109112

0 commit comments

Comments
 (0)