Skip to content

Commit a14c59e

Browse files
cmnemoiofek
andauthored
fix: Fixed Environment default is incompatible: Unknown distribution source error (#2086)
Co-authored-by: Ofek Lev <[email protected]>
1 parent 0636e7b commit a14c59e

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

src/hatch/python/resolve.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,11 @@ def _get_default_variant_gil() -> str:
280280

281281

282282
def _get_distribution_class(source: str) -> type[Distribution]:
283-
if source.startswith('https://github.com/astral-sh/python-build-standalone/releases/download/'):
283+
if source.startswith((
284+
'https://github.com/astral-sh/python-build-standalone/releases/download/',
285+
# TODO: Remove compatibility for the old source
286+
'https://github.com/indygreg/python-build-standalone/releases/download/',
287+
)):
284288
return CPythonStandaloneDistribution
285289

286290
if source.startswith('https://downloads.python.org/pypy/'):

tests/python/test_resolve.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ def test_unknown_distribution(self):
1919
reason='No variants for this platform and architecture combination',
2020
)
2121
def test_resolution_error(self, platform):
22-
with EnvVars({'HATCH_PYTHON_VARIANT_CPU': 'foo'}), pytest.raises(
23-
PythonDistributionResolutionError,
24-
match=f"Could not find a default source for name='3.11' system='{platform.name}' arch=",
22+
with (
23+
EnvVars({'HATCH_PYTHON_VARIANT_CPU': 'foo'}),
24+
pytest.raises(
25+
PythonDistributionResolutionError,
26+
match=f"Could not find a default source for name='3.11' system='{platform.name}' arch=",
27+
),
2528
):
2629
get_distribution('3.11')
2730

@@ -35,6 +38,14 @@ def test_cpython_standalone(self):
3538
assert version.epoch == 0
3639
assert version.base_version == '3.11.3'
3740

41+
def test_cpython_standalone_from_legacy_link(self) -> None:
42+
url = 'https://github.com/indygreg/python-build-standalone/releases/download/20230507/cpython-3.11.3%2B20230507-aarch64-unknown-linux-gnu-install_only.tar.gz'
43+
dist = get_distribution('3.11', url)
44+
version = dist.version
45+
46+
assert version.epoch == 0
47+
assert version.base_version == '3.11.3'
48+
3849
def test_cpython_standalone_custom(self):
3950
name = '3.11'
4051
dist = get_distribution(name)
@@ -151,8 +162,11 @@ def test_compatible(self):
151162
assert 'freethreaded' in dist.source
152163

153164
def test_incompatible(self, platform):
154-
with EnvVars({'HATCH_PYTHON_VARIANT_GIL': 'freethreaded'}), pytest.raises(
155-
PythonDistributionResolutionError,
156-
match=f"Could not find a default source for name='3.12' system='{platform.name}' arch=",
165+
with (
166+
EnvVars({'HATCH_PYTHON_VARIANT_GIL': 'freethreaded'}),
167+
pytest.raises(
168+
PythonDistributionResolutionError,
169+
match=f"Could not find a default source for name='3.12' system='{platform.name}' arch=",
170+
),
157171
):
158172
get_distribution('3.12')

0 commit comments

Comments
 (0)