diff --git a/mesonpy/__init__.py b/mesonpy/__init__.py index e583e2fee..adcc04577 100644 --- a/mesonpy/__init__.py +++ b/mesonpy/__init__.py @@ -665,6 +665,9 @@ def _compute_build_time_dependencies( version = packaging.version.parse(importlib_metadata.version(name)) except importlib_metadata.PackageNotFoundError as exc: raise ConfigError(f'package "{name}" specified in "build-time-pins" not found: {template!r}') from exc + if version.is_devrelease or version.is_prerelease: + print('meson-python: build-time pin for pre-release version "{version}" of "{name}" not generared: {template!r}') + continue pin = packaging.requirements.Requirement(template.format(v=version)) if pin.marker: raise ConfigError(f'requirements in "build-time-pins" cannot contain markers: {template!r}') diff --git a/tests/test_wheel.py b/tests/test_wheel.py index 84844eaa8..b7b0e62c5 100644 --- a/tests/test_wheel.py +++ b/tests/test_wheel.py @@ -264,3 +264,29 @@ def test_build_time_pins(wheel_dynamic_dependencies): Requires-Dist: meson-python>=0.13.0 Requires-Dist: packaging~={packaging_version.major}.{packaging_version.minor} ''') + + +def test_compute_build_time_dependencies(monkeypatch): + versions = { + 'aaa': '1.2.3', + 'bbb': '4.5.6', + 'ddd': '1.0.0rc1', # pre-release will not be added to build-time dependencies + } + monkeypatch.setattr(importlib_metadata, 'version', lambda package: versions.get(package)) + deps = [ + 'bbb>=0.1', + 'ccc>=0.2', + 'ddd>=0.3', + ] + pins = [ + 'aaa>={v}', + 'bbb~={v.major}.{v.minor}', + 'ddd=={v}', + ] + r = mesonpy._compute_build_time_dependencies([packaging.requirements.Requirement(x) for x in deps], pins) + assert sorted(str(x) for x in r) == [ + 'aaa>=1.2.3', + 'bbb>=0.1,~=4.5', + 'ccc>=0.2', + 'ddd>=0.3', + ]