Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare release 0.17.1 #697

Merged
merged 7 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,13 @@ jobs:
- os: windows-latest
python: '3.12'
meson: '@git+https://github.com/mesonbuild/meson.git'
# Test with oldest supported pyproject-metadata
# Test with older supported pyproject-metadata
- os: ubuntu-latest
python: '3.12'
pyproject_metadata: '==0.7.1'
- os: ubuntu-latest
python: '3.12'
pyproject_metadata: '==0.8.0'

steps:
- name: Checkout
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
Changelog
+++++++++

0.17.1
======

- Update tests to work with newly released ``pyproject-metadata`` 0.9.0.
- Fix tests to work when not executed in a git work tree.

Daniele Nicolodi --- 23-10-2024.

0.17.0
======

Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: MIT

project('meson-python', version: '0.17.0')
project('meson-python', version: '0.17.1')

py = import('python').find_installation()

Expand Down
6 changes: 3 additions & 3 deletions mesonpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
MesonArgs = Mapping[MesonArgsKeys, List[str]]


__version__ = '0.17.0.dev0'
__version__ = '0.17.1'


_NINJA_REQUIRED_VERSION = '1.8.2'
Expand Down Expand Up @@ -246,7 +246,7 @@ def _validate_name(name: str) -> str:
return name

@classmethod
def from_pyproject(
def from_pyproject( # type: ignore[override]
cls,
data: Mapping[str, Any],
project_dir: Path = os.path.curdir,
Expand Down Expand Up @@ -367,7 +367,7 @@ def _libs_dir(self) -> str:
@property
def _license_file(self) -> Optional[pathlib.Path]:
license_ = self._metadata.license
if license_:
if license_ and isinstance(license_, pyproject_metadata.License):
return license_.file
return None

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ dynamic = [
[project.optional-dependencies]
test = [
'build',
'packaging >= 23.1',
'pytest >= 6.0',
'pytest-cov[toml]',
'pytest-mock',
Expand Down
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from venv import EnvBuilder

import packaging.metadata
import packaging.version
import pytest

Expand All @@ -24,6 +25,12 @@
from mesonpy._util import chdir


def metadata(data):
meta, other = packaging.metadata.parse_email(data)
assert not other
return meta


def adjust_packaging_platform_tag(platform: str) -> str:
if platform.startswith(('manylinux', 'musllinux')):
# The packaging module generates overly specific platforms tags on
Expand Down
2 changes: 2 additions & 0 deletions tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def test_missing_version(package_missing_version):
re.escape('Required "project.version" field is missing'),
# pyproject-metatadata 0.8.0 and later
re.escape('Field "project.version" missing and "version" not specified in "project.dynamic"'),
# pyproject-metatadata 0.9.0 and later
re.escape('Field "project.version" missing and \'version\' not specified in "project.dynamic"'),
))
with pytest.raises(pyproject_metadata.ConfigurationError, match=match):
Metadata.from_pyproject(pyproject, pathlib.Path())
65 changes: 37 additions & 28 deletions tests/test_sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,66 @@
#
# SPDX-License-Identifier: MIT

import os
import pathlib
import re
import stat
import sys
import tarfile
import textwrap
import time

from itertools import chain

import pytest

import mesonpy

from .conftest import in_git_repo_context
from .conftest import in_git_repo_context, metadata


def test_no_pep621(sdist_library):
with tarfile.open(sdist_library, 'r:gz') as sdist:
sdist_pkg_info = sdist.extractfile('library-1.0.0/PKG-INFO').read().decode()
sdist_pkg_info = sdist.extractfile('library-1.0.0/PKG-INFO').read()

assert sdist_pkg_info == textwrap.dedent('''\
assert metadata(sdist_pkg_info) == metadata(textwrap.dedent('''\
Metadata-Version: 2.1
Name: library
Version: 1.0.0
''')
'''))


def test_pep621(sdist_full_metadata):
with tarfile.open(sdist_full_metadata, 'r:gz') as sdist:
sdist_pkg_info = sdist.extractfile('full_metadata-1.2.3/PKG-INFO').read().decode()
sdist_pkg_info = sdist.extractfile('full_metadata-1.2.3/PKG-INFO').read()

meta = metadata(sdist_pkg_info)

# pyproject-metadata prior to 0.8.0 uses spaces to join keywords
meta['keywords'] = list(chain(*(v.split(' ') for v in meta['keywords'])))

# pyproject-metadata prior to 0.9.0 strips trailing newlines
meta['license'] = meta['license'].rstrip()

metadata = re.escape(textwrap.dedent('''\
# pyproject-metadata 0.9.0 and later does not emit Home-Page
meta.pop('home_page', None)
# nor normalizes Project-URL keys
meta['project_urls'] = {k.lower(): v for k, v in meta['project_urls'].items()}

assert meta == metadata(textwrap.dedent('''\
Metadata-Version: 2.1
Name: full-metadata
Version: 1.2.3
Summary: Some package with all of the PEP 621 metadata
Keywords: full metadata
Home-page: https://example.com
Keywords: full,metadata
Author: Jane Doe
Author-Email: Unknown <[email protected]>
Maintainer-Email: Jane Doe <[email protected]>
License: some license
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Project-URL: Homepage, https://example.com
Project-URL: Documentation, https://readthedocs.org
Project-URL: Repository, https://github.com/mesonbuild/meson-python
Project-URL: Changelog, https://github.com/mesonbuild/meson-python/blob/master/CHANGELOG.rst
Project-URL: homepage, https://example.com
Project-URL: documentation, https://readthedocs.org
Project-URL: repository, https://github.com/mesonbuild/meson-python
Project-URL: changelog, https://github.com/mesonbuild/meson-python/blob/master/CHANGELOG.rst
Requires-Python: >=3.7
Requires-Dist: a
Requires-Dist: b>1
Expand All @@ -70,20 +82,16 @@ def test_pep621(sdist_full_metadata):
An example package with all of the PEP 621 metadata!
'''))

# pyproject-metadata 0.8.0 and later uses a comma to separate keywords
expr = metadata.replace(r'Keywords:\ full\ metadata', r'Keywords:\ full[ ,]metadata')
assert re.fullmatch(expr, sdist_pkg_info)


def test_dynamic_version(sdist_dynamic_version):
with tarfile.open(sdist_dynamic_version, 'r:gz') as sdist:
sdist_pkg_info = sdist.extractfile('dynamic_version-1.0.0/PKG-INFO').read().decode()
sdist_pkg_info = sdist.extractfile('dynamic_version-1.0.0/PKG-INFO').read()

assert sdist_pkg_info == textwrap.dedent('''\
assert metadata(sdist_pkg_info) == metadata(textwrap.dedent('''\
Metadata-Version: 2.1
Name: dynamic-version
Version: 1.0.0
''')
'''))


def test_contents(sdist_library):
Expand Down Expand Up @@ -135,7 +143,7 @@ def bar():
try:
pathlib.Path('pure.py').write_text(new)
pathlib.Path('other.py').touch()
sdist_path = mesonpy.build_sdist(os.fspath(tmp_path))
sdist_path = mesonpy.build_sdist(tmp_path)
finally:
pathlib.Path('pure.py').write_text(old)
pathlib.Path('other.py').unlink()
Expand Down Expand Up @@ -209,12 +217,13 @@ def test_long_path(sdist_long_path):


def test_reproducible(package_pure, tmp_path):
t1 = time.time()
sdist_path_a = mesonpy.build_sdist(tmp_path / 'a')
t2 = time.time()
# Ensure that the two sdists are build at least one second apart.
time.sleep(max(t1 + 1.0 - t2, 0.0))
sdist_path_b = mesonpy.build_sdist(tmp_path / 'b')
with in_git_repo_context():
t1 = time.time()
sdist_path_a = mesonpy.build_sdist(tmp_path / 'a')
t2 = time.time()
# Ensure that the two sdists are build at least one second apart.
time.sleep(max(t1 + 1.0 - t2, 0.0))
sdist_path_b = mesonpy.build_sdist(tmp_path / 'b')

assert sdist_path_a == sdist_path_b
assert tmp_path.joinpath('a', sdist_path_a).read_bytes() == tmp_path.joinpath('b', sdist_path_b).read_bytes()
Loading