diff --git a/docs/plugins/environment/virtual.md b/docs/plugins/environment/virtual.md index a5270d754..3bc34f516 100644 --- a/docs/plugins/environment/virtual.md +++ b/docs/plugins/environment/virtual.md @@ -45,7 +45,7 @@ If a Python version has been chosen then each resolver will try to find an inter If no version has been chosen, then each resolver will try to find a version that matches the version of Python that Hatch is currently running on. If not found then each resolver will try to find the highest compatible version. !!! note - Some external Python paths are considered unstable and are ignored during resolution. For example, if Hatch if installed via Homebrew then `sys.executable` will be ignored because the interpreter could change or be removed at any time. + Some external Python paths are considered unstable and are ignored during resolution. For example, if Hatch is installed via Homebrew then `sys.executable` will be ignored because the interpreter could change or be removed at any time. !!! note When resolution finds a match using an [internally managed distribution](#internal-distributions) and an update is available, the latest distribution will automatically be downloaded before environment creation. diff --git a/src/hatch/python/resolve.py b/src/hatch/python/resolve.py index 680a22412..b91be9dc1 100644 --- a/src/hatch/python/resolve.py +++ b/src/hatch/python/resolve.py @@ -78,8 +78,12 @@ class CPythonStandaloneDistribution(Distribution): def version(self) -> Version: from packaging.version import Version - *_, remaining = self.source.partition('/download/') - version, *_ = remaining.partition('/') + # .../cpython-3.12.0%2B20231002-... + # .../cpython-3.7.9-... + _, _, remaining = self.source.partition('/cpython-') + # 3.12.0%2B20231002-... + # 3.7.9-... + version = remaining.split('%2B')[0] if '%2B' in remaining else remaining.split('-')[0] return Version(f'0!{version}') @cached_property diff --git a/tests/python/test_resolve.py b/tests/python/test_resolve.py index b6deb4fbd..a24183641 100644 --- a/tests/python/test_resolve.py +++ b/tests/python/test_resolve.py @@ -25,7 +25,7 @@ def test_cpython_standalone(self): version = dist.version assert version.epoch == 0 - assert version.base_version == '20230507' + assert version.base_version == '3.11.3' def test_pypy(self): url = 'https://downloads.python.org/pypy/pypy3.10-v7.3.12-aarch64.tar.bz2'