Skip to content

Commit

Permalink
feat: bump pyproject-metadata to 0.8.0 (#231)
Browse files Browse the repository at this point in the history
Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming authored Apr 18, 2024
1 parent d7d15fb commit 5f53873
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
27 changes: 12 additions & 15 deletions scripts/patches/pyproject_metadata.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
diff --git a/src/pdm/backend/_vendor/pyproject_metadata/__init__.py b/src/pdm/backend/_vendor/pyproject_metadata/__init__.py
index 796fa1e..e59e2d5 100644
index df826f8..7f69f3a 100644
--- a/src/pdm/backend/_vendor/pyproject_metadata/__init__.py
+++ b/src/pdm/backend/_vendor/pyproject_metadata/__init__.py
@@ -16,13 +16,13 @@ if typing.TYPE_CHECKING:
from collections.abc import Mapping
from typing import Any

- from packaging.requirements import Requirement
+ from pdm.backend._vendor.packaging.requirements import Requirement
@@ -24,11 +24,11 @@ if typing.TYPE_CHECKING:
else:
from typing import Self

-import packaging.markers
-import packaging.requirements
Expand All @@ -21,8 +18,8 @@ index 796fa1e..e59e2d5 100644
+import pdm.backend._vendor.packaging.version as pkg_version


__version__ = '0.8.0rc1'
@@ -169,11 +169,11 @@ class Readme(typing.NamedTuple):
__version__ = '0.8.0'
@@ -175,11 +175,11 @@ class Readme(typing.NamedTuple):
@dataclasses.dataclass
class StandardMetadata:
name: str
Expand All @@ -36,7 +33,7 @@ index 796fa1e..e59e2d5 100644
dependencies: list[Requirement] = dataclasses.field(default_factory=list)
optional_dependencies: dict[str, list[Requirement]] = dataclasses.field(default_factory=dict)
entrypoints: dict[str, dict[str, str]] = dataclasses.field(default_factory=dict)
@@ -196,7 +196,7 @@ class StandardMetadata:
@@ -202,7 +202,7 @@ class StandardMetadata:

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

@classmethod
def from_pyproject(
@@ -229,7 +229,7 @@ class StandardMetadata:
@@ -235,7 +235,7 @@ class StandardMetadata:

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

if version is None and 'version' not in dynamic:
msg = 'Field "project.version" missing and "version" not specified in "project.dynamic"'
@@ -251,7 +251,7 @@ class StandardMetadata:
@@ -256,7 +256,7 @@ class StandardMetadata:
description,
cls._get_license(fetcher, project_dir),
cls._get_readme(fetcher, project_dir),
Expand All @@ -63,7 +60,7 @@ index 796fa1e..e59e2d5 100644
cls._get_dependencies(fetcher),
cls._get_optional_dependencies(fetcher),
cls._get_entrypoints(fetcher),
@@ -353,15 +353,15 @@ class StandardMetadata:
@@ -358,15 +358,15 @@ class StandardMetadata:
requirement = copy.copy(requirement)
if requirement.marker:
if 'or' in requirement.marker._markers:
Expand All @@ -82,7 +79,7 @@ index 796fa1e..e59e2d5 100644
return requirement

@staticmethod
@@ -457,8 +457,8 @@ class StandardMetadata:
@@ -462,8 +462,8 @@ class StandardMetadata:
requirements: list[Requirement] = []
for req in requirement_strings:
try:
Expand All @@ -93,7 +90,7 @@ index 796fa1e..e59e2d5 100644
msg = (
'Field "project.dependencies" contains an invalid PEP 508 '
f'requirement string "{req}" ("{e}")'
@@ -497,8 +497,8 @@ class StandardMetadata:
@@ -502,8 +502,8 @@ class StandardMetadata:
)
raise ConfigurationError(msg)
try:
Expand Down
19 changes: 12 additions & 7 deletions src/pdm/backend/_vendor/pyproject_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os
import os.path
import pathlib
import sys
import typing


Expand All @@ -18,14 +19,19 @@

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

if sys.version_info < (3, 11):
from typing_extensions import Self
else:
from typing import Self

import pdm.backend._vendor.packaging.markers as pkg_markers
import pdm.backend._vendor.packaging.requirements as pkg_requirements
import pdm.backend._vendor.packaging.specifiers as pkg_specifiers
import pdm.backend._vendor.packaging.utils as pkg_utils
import pdm.backend._vendor.packaging.version as pkg_version


__version__ = '0.8.0rc1'
__version__ = '0.8.0'

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

Expand Down Expand Up @@ -204,7 +210,7 @@ def from_pyproject(
data: Mapping[str, Any],
project_dir: str | os.PathLike[str] = os.path.curdir,
metadata_version: str | None = None,
) -> StandardMetadata:
) -> Self:
fetcher = DataFetcher(data)
project_dir = pathlib.Path(project_dir)

Expand All @@ -219,7 +225,7 @@ def from_pyproject(

for field in dynamic:
if field in data['project']:
msg = f'Field "project.{field}" declared as dynamic in but is defined'
msg = f'Field "project.{field}" declared as dynamic in "project.dynamic" but is defined'
raise ConfigurationError(msg)

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

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

if metadata_version and metadata_version not in KNOWN_METADATA_VERSIONS:
msg = f'The metadata_version must be one of {KNOWN_METADATA_VERSIONS} or None (default)'
Expand Down
2 changes: 1 addition & 1 deletion src/pdm/backend/_vendor/vendor.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
packaging==24.0
tomli==2.0.1
tomli_w==1.0.0
pyproject-metadata==0.8.0rc1
pyproject-metadata==0.8.0

0 comments on commit 5f53873

Please sign in to comment.