Skip to content

Commit 5f53873

Browse files
authored
feat: bump pyproject-metadata to 0.8.0 (#231)
Signed-off-by: Frost Ming <me@frostming.com>
1 parent d7d15fb commit 5f53873

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

scripts/patches/pyproject_metadata.patch

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
diff --git a/src/pdm/backend/_vendor/pyproject_metadata/__init__.py b/src/pdm/backend/_vendor/pyproject_metadata/__init__.py
2-
index 796fa1e..e59e2d5 100644
2+
index df826f8..7f69f3a 100644
33
--- a/src/pdm/backend/_vendor/pyproject_metadata/__init__.py
44
+++ b/src/pdm/backend/_vendor/pyproject_metadata/__init__.py
5-
@@ -16,13 +16,13 @@ if typing.TYPE_CHECKING:
6-
from collections.abc import Mapping
7-
from typing import Any
8-
9-
- from packaging.requirements import Requirement
10-
+ from pdm.backend._vendor.packaging.requirements import Requirement
5+
@@ -24,11 +24,11 @@ if typing.TYPE_CHECKING:
6+
else:
7+
from typing import Self
118

129
-import packaging.markers
1310
-import packaging.requirements
@@ -21,8 +18,8 @@ index 796fa1e..e59e2d5 100644
2118
+import pdm.backend._vendor.packaging.version as pkg_version
2219

2320

24-
__version__ = '0.8.0rc1'
25-
@@ -169,11 +169,11 @@ class Readme(typing.NamedTuple):
21+
__version__ = '0.8.0'
22+
@@ -175,11 +175,11 @@ class Readme(typing.NamedTuple):
2623
@dataclasses.dataclass
2724
class StandardMetadata:
2825
name: str
@@ -36,7 +33,7 @@ index 796fa1e..e59e2d5 100644
3633
dependencies: list[Requirement] = dataclasses.field(default_factory=list)
3734
optional_dependencies: dict[str, list[Requirement]] = dataclasses.field(default_factory=dict)
3835
entrypoints: dict[str, dict[str, str]] = dataclasses.field(default_factory=dict)
39-
@@ -196,7 +196,7 @@ class StandardMetadata:
36+
@@ -202,7 +202,7 @@ class StandardMetadata:
4037

4138
@property
4239
def canonical_name(self) -> str:
@@ -45,7 +42,7 @@ index 796fa1e..e59e2d5 100644
4542

4643
@classmethod
4744
def from_pyproject(
48-
@@ -229,7 +229,7 @@ class StandardMetadata:
45+
@@ -235,7 +235,7 @@ class StandardMetadata:
4946

5047
version_string = fetcher.get_str('project.version')
5148
requires_python_string = fetcher.get_str('project.requires-python')
@@ -54,7 +51,7 @@ index 796fa1e..e59e2d5 100644
5451

5552
if version is None and 'version' not in dynamic:
5653
msg = 'Field "project.version" missing and "version" not specified in "project.dynamic"'
57-
@@ -251,7 +251,7 @@ class StandardMetadata:
54+
@@ -256,7 +256,7 @@ class StandardMetadata:
5855
description,
5956
cls._get_license(fetcher, project_dir),
6057
cls._get_readme(fetcher, project_dir),
@@ -63,7 +60,7 @@ index 796fa1e..e59e2d5 100644
6360
cls._get_dependencies(fetcher),
6461
cls._get_optional_dependencies(fetcher),
6562
cls._get_entrypoints(fetcher),
66-
@@ -353,15 +353,15 @@ class StandardMetadata:
63+
@@ -358,15 +358,15 @@ class StandardMetadata:
6764
requirement = copy.copy(requirement)
6865
if requirement.marker:
6966
if 'or' in requirement.marker._markers:
@@ -82,7 +79,7 @@ index 796fa1e..e59e2d5 100644
8279
return requirement
8380

8481
@staticmethod
85-
@@ -457,8 +457,8 @@ class StandardMetadata:
82+
@@ -462,8 +462,8 @@ class StandardMetadata:
8683
requirements: list[Requirement] = []
8784
for req in requirement_strings:
8885
try:
@@ -93,7 +90,7 @@ index 796fa1e..e59e2d5 100644
9390
msg = (
9491
'Field "project.dependencies" contains an invalid PEP 508 '
9592
f'requirement string "{req}" ("{e}")'
96-
@@ -497,8 +497,8 @@ class StandardMetadata:
93+
@@ -502,8 +502,8 @@ class StandardMetadata:
9794
)
9895
raise ConfigurationError(msg)
9996
try:

src/pdm/backend/_vendor/pyproject_metadata/__init__.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import os
1010
import os.path
1111
import pathlib
12+
import sys
1213
import typing
1314

1415

@@ -18,14 +19,19 @@
1819

1920
from pdm.backend._vendor.packaging.requirements import Requirement
2021

22+
if sys.version_info < (3, 11):
23+
from typing_extensions import Self
24+
else:
25+
from typing import Self
26+
2127
import pdm.backend._vendor.packaging.markers as pkg_markers
2228
import pdm.backend._vendor.packaging.requirements as pkg_requirements
2329
import pdm.backend._vendor.packaging.specifiers as pkg_specifiers
2430
import pdm.backend._vendor.packaging.utils as pkg_utils
2531
import pdm.backend._vendor.packaging.version as pkg_version
2632

2733

28-
__version__ = '0.8.0rc1'
34+
__version__ = '0.8.0'
2935

3036
KNOWN_METADATA_VERSIONS = {'2.1', '2.2', '2.3'}
3137

@@ -204,7 +210,7 @@ def from_pyproject(
204210
data: Mapping[str, Any],
205211
project_dir: str | os.PathLike[str] = os.path.curdir,
206212
metadata_version: str | None = None,
207-
) -> StandardMetadata:
213+
) -> Self:
208214
fetcher = DataFetcher(data)
209215
project_dir = pathlib.Path(project_dir)
210216

@@ -219,7 +225,7 @@ def from_pyproject(
219225

220226
for field in dynamic:
221227
if field in data['project']:
222-
msg = f'Field "project.{field}" declared as dynamic in but is defined'
228+
msg = f'Field "project.{field}" declared as dynamic in "project.dynamic" but is defined'
223229
raise ConfigurationError(msg)
224230

225231
name = fetcher.get_str('project.name')
@@ -235,11 +241,10 @@ def from_pyproject(
235241
msg = 'Field "project.version" missing and "version" not specified in "project.dynamic"'
236242
raise ConfigurationError(msg)
237243

238-
# Description can't be multiline
244+
# Description fills Summary, which cannot be multiline
245+
# However, throwing an error isn't backward compatible,
246+
# so leave it up to the users for now.
239247
description = fetcher.get_str('project.description')
240-
if description and '\n' in description:
241-
msg = 'The description must be a single line'
242-
raise ConfigurationError(msg)
243248

244249
if metadata_version and metadata_version not in KNOWN_METADATA_VERSIONS:
245250
msg = f'The metadata_version must be one of {KNOWN_METADATA_VERSIONS} or None (default)'

src/pdm/backend/_vendor/vendor.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
packaging==24.0
22
tomli==2.0.1
33
tomli_w==1.0.0
4-
pyproject-metadata==0.8.0rc1
4+
pyproject-metadata==0.8.0

0 commit comments

Comments
 (0)