Skip to content

Commit

Permalink
ENH: do not generate build-time pins for pre-releases
Browse files Browse the repository at this point in the history
It is not possible to define a universally useful semantic for
build-time pins involving pre-releases. Do not generate them.
  • Loading branch information
dnicolodi committed Mar 22, 2023
1 parent e69f391 commit 58606b9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mesonpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Expand Down
26 changes: 26 additions & 0 deletions tests/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]

0 comments on commit 58606b9

Please sign in to comment.