Skip to content

Instantly share code, notes, and snippets.

@jaraco
Created June 26, 2024 14:33
Show Gist options
  • Save jaraco/9c94c5c4a6b4626fc7bca6459264d8ec to your computer and use it in GitHub Desktop.
Save jaraco/9c94c5c4a6b4626fc7bca6459264d8ec to your computer and use it in GitHub Desktop.
diff --git a/pyproject.toml b/pyproject.toml
index 8434a08..b067201 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -39,7 +39,6 @@ dependencies = [
"keyring >= 15.1",
"rfc3986 >= 1.4.0",
"rich >= 12.0.0",
- "packaging",
]
dynamic = ["version"]
diff --git a/twine/package.py b/twine/package.py
index 99a826a..62db10a 100644
--- a/twine/package.py
+++ b/twine/package.py
@@ -33,7 +33,6 @@ from typing import (
)
import importlib_metadata
-import packaging.version
import pkginfo
from rich import print
@@ -134,22 +133,11 @@ class PackageFile:
"Make sure the distribution is using a supported Metadata-Version: "
f"{', '.join(supported_metadata)}."
)
- # If pkginfo <1.11 encounters a metadata version it doesn't support, it may give
- # back empty metadata. At the very least, we should have a name and version,
- # which could also be empty if, for example, a MANIFEST.in doesn't include
- # setup.cfg.
missing_fields = [
f.capitalize() for f in ["name", "version"] if not getattr(meta, f)
]
if missing_fields:
msg = f"Metadata is missing required fields: {', '.join(missing_fields)}."
- if cls._pkginfo_before_1_11():
- msg += (
- "\n"
- "Make sure the distribution includes the files where those fields "
- "are specified, and is using a supported Metadata-Version: "
- f"{', '.join(supported_metadata)}."
- )
raise exceptions.InvalidDistribution(msg)
py_version: Optional[str]
@@ -174,11 +162,6 @@ class PackageFile:
NMV = getattr(pkginfo.distribution, "NewMetadataVersion", None)
return any(warning.category is NMV for warning in captured)
- @staticmethod
- def _pkginfo_before_1_11() -> bool:
- ver = packaging.version.Version(importlib_metadata.version("pkginfo"))
- return ver < packaging.version.Version("1.11")
-
def metadata_dictionary(self) -> Dict[str, MetadataValue]:
"""Merge multiple sources of metadata into a single dictionary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment