Use versioned bages when uploading to PyPI (#5039)

This commit is contained in:
Charlie Marsh 2024-07-13 14:12:45 -04:00 committed by GitHub
parent b629ab89c5
commit b5f0e0729e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -62,7 +62,26 @@ def main(target: str) -> None:
else:
raise ValueError("Version not found in pyproject.toml")
# Replace any relative URLs with absolute URLs.
# Replace the badges with versioned URLs.
for existing, replacement in [
(
"https://img.shields.io/pypi/v/uv.svg",
f"https://img.shields.io/pypi/v/uv/{version}.svg",
),
(
"https://img.shields.io/pypi/l/uv.svg",
f"https://img.shields.io/pypi/l/uv/{version}.svg",
),
(
"https://img.shields.io/pypi/pyversions/uv.svg",
f"https://img.shields.io/pypi/pyversions/uv/{version}.svg",
),
]:
if existing not in content:
raise ValueError(f"Badge not found in README.md: {existing}")
content = content.replace(existing, replacement)
# Replace any relative URLs (e.g., `[PIP_COMPATIBILITY.md`) with absolute URLs.
def replace(match: re.Match) -> str:
url = match.group(1)
if not url.startswith("http"):