diff --git a/src/poetry/core/masonry/metadata.py b/src/poetry/core/masonry/metadata.py index d34d8f664..9670cb126 100644 --- a/src/poetry/core/masonry/metadata.py +++ b/src/poetry/core/masonry/metadata.py @@ -6,15 +6,13 @@ if TYPE_CHECKING: - from packaging.utils import NormalizedName - from poetry.core.packages.package import Package class Metadata: metadata_version = "2.1" # version 1.0 - name: NormalizedName | None = None + name: str | None = None version: str platforms: tuple[str, ...] = () supported_platforms: tuple[str, ...] = () @@ -51,7 +49,7 @@ def from_package(cls, package: Package) -> Metadata: meta = cls() - meta.name = package.name + meta.name = package.pretty_name meta.version = package.version.to_string() meta.summary = package.description if package.readmes: diff --git a/tests/masonry/builders/fixtures/Pretty.Name/README.rst b/tests/masonry/builders/fixtures/Pretty.Name/README.rst new file mode 100644 index 000000000..a8d6edc4c --- /dev/null +++ b/tests/masonry/builders/fixtures/Pretty.Name/README.rst @@ -0,0 +1,2 @@ +Pretty.Name +=========== diff --git a/tests/masonry/builders/fixtures/Pretty.Name/pretty_name.py b/tests/masonry/builders/fixtures/Pretty.Name/pretty_name.py new file mode 100644 index 000000000..2e706b5c4 --- /dev/null +++ b/tests/masonry/builders/fixtures/Pretty.Name/pretty_name.py @@ -0,0 +1 @@ +"""Example module""" diff --git a/tests/masonry/builders/fixtures/Pretty.Name/pyproject.toml b/tests/masonry/builders/fixtures/Pretty.Name/pyproject.toml new file mode 100644 index 000000000..a903fde1b --- /dev/null +++ b/tests/masonry/builders/fixtures/Pretty.Name/pyproject.toml @@ -0,0 +1,12 @@ +[tool.poetry] +name = "Pretty.Name" +version = "1.0" +description = "Some description." +authors = [ + "Sébastien Eustace " +] +license = "MIT" + +readme = "README.rst" + +homepage = "https://python-poetry.org/" diff --git a/tests/masonry/builders/test_builder.py b/tests/masonry/builders/test_builder.py index 5e3fd6eae..f74b9d4e6 100644 --- a/tests/masonry/builders/test_builder.py +++ b/tests/masonry/builders/test_builder.py @@ -127,6 +127,16 @@ def test_get_metadata_content() -> None: ] +def test_metadata_pretty_name() -> None: + builder = Builder( + Factory().create_poetry(Path(__file__).parent / "fixtures" / "Pretty.Name") + ) + + metadata = Parser().parsestr(builder.get_metadata_content()) + + assert metadata["Name"] == "Pretty.Name" + + def test_metadata_homepage_default() -> None: builder = Builder( Factory().create_poetry(Path(__file__).parent / "fixtures" / "simple_version")