Skip to content

Commit 90300cd

Browse files
committed
MAINT: remove workarounds for bugs fixed in pyproject-metadata 0.8.0
1 parent 15f03d0 commit 90300cd

File tree

4 files changed

+4
-26
lines changed

4 files changed

+4
-26
lines changed

mesonpy/__init__.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,12 @@ class MesonBuilderError(Error):
234234

235235
class Metadata(pyproject_metadata.StandardMetadata):
236236
def __init__(self, name: str, *args: Any, **kwargs: Any):
237-
super().__init__(name, *args, **kwargs)
238-
# Local fix for https://github.com/FFY00/python-pyproject-metadata/issues/60
239-
self.name = self._validate_name(name)
240-
241-
@staticmethod
242-
def _validate_name(name: str) -> str:
243237
# See https://packaging.python.org/en/latest/specifications/core-metadata/#name
244238
if not re.match(r'^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$', name, re.IGNORECASE):
245239
raise pyproject_metadata.ConfigurationError(
246240
f'Invalid project name "{name}". A valid name consists only of ASCII letters and '
247241
f'numbers, period, underscore and hyphen. It must start and end with a letter or number')
248-
return name
242+
super().__init__(name, *args, **kwargs)
249243

250244
@classmethod
251245
def from_pyproject(cls, data: Mapping[str, Any], project_dir: Path) -> Metadata: # type: ignore[override]
@@ -255,11 +249,6 @@ def from_pyproject(cls, data: Mapping[str, Any], project_dir: Path) -> Metadata:
255249

256250
metadata = super().from_pyproject(data, project_dir)
257251

258-
# Check for missing version field.
259-
if not metadata.version and 'version' not in metadata.dynamic:
260-
raise pyproject_metadata.ConfigurationError(
261-
'Required "project.version" field is missing and not declared as dynamic')
262-
263252
# Check for unsupported dynamic fields.
264253
unsupported_dynamic = set(metadata.dynamic) - {'version', }
265254
if unsupported_dynamic:
@@ -268,17 +257,6 @@ def from_pyproject(cls, data: Mapping[str, Any], project_dir: Path) -> Metadata:
268257

269258
return metadata # type: ignore[return-value]
270259

271-
# Local fix for a bug in pyproject-metadata. See
272-
# https://github.com/mesonbuild/meson-python/issues/454
273-
def _update_dynamic(self, value: Any) -> None:
274-
if value and 'version' in self.dynamic:
275-
self.dynamic.remove('version')
276-
277-
@property
278-
def canonical_name(self) -> str:
279-
# See https://packaging.python.org/en/latest/specifications/name-normalization/#normalization
280-
return packaging.utils.canonicalize_name(self.name)
281-
282260
@property
283261
def distribution_name(self) -> str:
284262
"""Name to be used in wheel and sdist file names."""

tests/packages/full-metadata/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ description = 'Some package with all of the PEP 621 metadata'
1313
readme = 'README.md'
1414
requires-python = '>=3.7'
1515
license = {file = 'LICENSE'}
16-
keywords = ['full', 'metadata']
16+
keywords = ['full', 'metadata', 'keyword with spaces']
1717
authors = [
1818
{email = '[email protected]'},
1919
{name = 'Jane Doe'}

tests/test_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ def test_missing_version(package_missing_version):
4848
pyproject = {'project': {
4949
'name': 'missing-version',
5050
}}
51-
with pytest.raises(pyproject_metadata.ConfigurationError, match='Required "project.version" field is missing'):
51+
with pytest.raises(pyproject_metadata.ConfigurationError, match='Field "project.version" missing'):
5252
Metadata.from_pyproject(pyproject, pathlib.Path())

tests/test_sdist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_pep621(sdist_full_metadata):
3535
Name: full-metadata
3636
Version: 1.2.3
3737
Summary: Some package with all of the PEP 621 metadata
38-
Keywords: full metadata
38+
Keywords: full,metadata,keyword with spaces
3939
Home-page: https://example.com
4040
Author: Jane Doe
4141
Author-Email: Unknown <[email protected]>

0 commit comments

Comments
 (0)