Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ jobs:
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: "Prep README.md"
run: python scripts/transform_readme.py
- name: "Build sdist"
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
with:
Expand Down Expand Up @@ -76,6 +78,8 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: x64
- name: "Prep README.md"
run: python scripts/transform_readme.py
- name: "Build wheels - x86_64"
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
with:
Expand Down Expand Up @@ -116,6 +120,8 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: arm64
- name: "Prep README.md"
run: python scripts/transform_readme.py
- name: "Build wheels - aarch64"
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
with:
Expand Down Expand Up @@ -170,6 +176,8 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: ${{ matrix.platform.arch }}
- name: "Prep README.md"
run: python scripts/transform_readme.py
- name: "Build wheels"
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
with:
Expand Down Expand Up @@ -222,6 +230,8 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: x64
- name: "Prep README.md"
run: python scripts/transform_readme.py
- name: "Build wheels"
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
with:
Expand Down Expand Up @@ -295,6 +305,8 @@ jobs:
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: "Prep README.md"
run: python scripts/transform_readme.py
- name: "Build wheels"
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
with:
Expand Down Expand Up @@ -359,6 +371,8 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: x64
- name: "Prep README.md"
run: python scripts/transform_readme.py
- name: "Build wheels"
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
with:
Expand Down Expand Up @@ -422,6 +436,8 @@ jobs:
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: "Prep README.md"
run: python scripts/transform_readme.py
- name: "Build wheels"
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
with:
Expand Down
45 changes: 45 additions & 0 deletions scripts/transform_readme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""Transform the README.md to support a specific deployment target.

By default, we assume that our README.md will be rendered on GitHub. However,
PyPI includes the README with different rendering.
"""

from __future__ import annotations

import re
import urllib.parse
from pathlib import Path

import tomllib


def main() -> None:
"""Modify the README.md to support PyPI."""
# Read the current version from the `dist-workspace.toml`.
with Path("dist-workspace.toml").open(mode="rb") as fp:
# Parse the TOML.
dist_workspace = tomllib.load(fp)
if "workspace" in dist_workspace and "version" in dist_workspace["workspace"]:
version = dist_workspace["workspace"]["version"]
else:
raise ValueError("Version not found in dist-workspace.toml")

# 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"):
url = urllib.parse.urljoin(
f"https://github.com/astral-sh/uv/blob/{version}/README.md", url
)
return f"]({url})"

content = re.sub(
r"]\(([^)]+)\)", replace, Path("README.md").read_text(encoding="utf8")
)

with Path("README.md").open("w", encoding="utf8") as fp:
fp.write(content)


if __name__ == "__main__":
main()