Skip to content

Commit

Permalink
Use "source" as python-version for sdist uploads
Browse files Browse the repository at this point in the history
Although not setting the "pyversion" field in the upload data works,
and despite it not being used for much, this is what PyPI (and most
likely other indexes) expects.

This will simplify follow-up patches.
  • Loading branch information
dnicolodi committed Dec 3, 2024
1 parent a723876 commit 21b1626
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions twine/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,18 @@ def from_filename(cls, filename: str, comment: Optional[str]) -> "PackageFile":
)
raise exceptions.InvalidDistribution(msg)

py_version: Optional[str]
if dtype == "bdist_egg":
(dist,) = importlib_metadata.Distribution.discover(path=[filename])
py_version = dist.metadata["Version"]
elif dtype == "bdist_wheel":
py_version = cast(wheel.Wheel, meta).py_version
elif dtype == "bdist_wininst":
py_version = cast(wininst.WinInst, meta).py_version
elif dtype == "sdist":
py_version = "source"
else:
py_version = None
# This should not be reached.
raise ValueError

return cls(
filename, comment, cast(CheckedDistribution, meta), py_version, dtype
Expand Down

0 comments on commit 21b1626

Please sign in to comment.