Skip to content

Commit ed1a994

Browse files
committed
Update fine-grained versioning for CPython distributions
1 parent 1d9e002 commit ed1a994

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

docs/plugins/environment/virtual.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ If a Python version has been chosen then each resolver will try to find an inter
4545
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.
4646

4747
!!! note
48-
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.
48+
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.
4949

5050
!!! note
5151
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.

src/hatch/python/resolve.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,12 @@ class CPythonStandaloneDistribution(Distribution):
7878
def version(self) -> Version:
7979
from packaging.version import Version
8080

81-
*_, remaining = self.source.partition('/download/')
82-
version, *_ = remaining.partition('/')
81+
# .../cpython-3.12.0%2B20231002-...
82+
# .../cpython-3.7.9-...
83+
_, _, remaining = self.source.partition('/cpython-')
84+
# 3.12.0%2B20231002-...
85+
# 3.7.9-...
86+
version = remaining.split('%2B')[0] if '%2B' in remaining else remaining.split('-')[0]
8387
return Version(f'0!{version}')
8488

8589
@cached_property

tests/python/test_resolve.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_cpython_standalone(self):
2525
version = dist.version
2626

2727
assert version.epoch == 0
28-
assert version.base_version == '20230507'
28+
assert version.base_version == '3.11.3'
2929

3030
def test_pypy(self):
3131
url = 'https://downloads.python.org/pypy/pypy3.10-v7.3.12-aarch64.tar.bz2'

0 commit comments

Comments
 (0)