From 01b7a27be42b3673f25e0ab64dfe1a6cebcc3a2f Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 22 Mar 2024 16:07:31 -0400 Subject: [PATCH] Add top-level benchmark to the README (#2622) ## Summary Steps involved in creating this: - Open the raw data in [Vega-Lite](https://vega.github.io/editor/#/url/vega-lite/N4IgJAzgxgFgpgWwIYgFwhgF0wBwqgegIDc4BzJAOjIEtMYBXAI0poHsDp5kTykBaADZ04JAKyUAVhDYA7EABoQAEySYUqUMSSCGcCGgDaoTGzaC0IHAwBmNmvKVQksOJYDuSAE4JFIJnCysMheANaWXvrmpH6YNAhuqAAMlEkAjADMACwA7GIAbBn5AJw5ABxiYlkATGn5SnEJAGJsPmqWKekGAL4KJmYW6NZ2Dn7Orh7evkoBQTAh4egOEOqCFg3xiZ1iOfnVZcXFSWUbza3ImB2p+T19IKbmlsP2jiDj8JZQ5sp+s8HeixAkRkghipy2lDESSSWQyOSSxXye3BLTal3QKSht36jyGbDgmC8AE8xi4PuhPD5foF-mEIlFQW5wWgUvkktVyvDqvkcllodDqijzu0MZQ2dj7gMnrYXqSJugvoIfjMafMAZZlqt1vdNizKDkjjk0pk0sU6vz0kK0VcDRKHoMrPjCSSnGTEiBKdN-KqFhrZCsdNrGhDimUcrUykUxEcLWkrRcroc7VKhjQcPwvggcDRBEy3m7JlSVXNfehgdE88G0GlIQU6vkxGUEVl4yKQDWCsncVZlF73u7PdSS+qlv6tbFdagawcSvk0tUsmbDsviq30e3KEcuw6cE7iXLyW9vkPaYDNYGJwk0NVKPOF-kso3o-UdWdregb-Pt09ewf3YrlW9Yc6VHAM1kvRIbyyMMkiKNI+SSF9g1RBMP0oRdvyGX9XXlD0phPNUQKBBkwVfRIMkoOE+SyWEMmOBDoQyNdLAouFMMdAl9xww8AII0tiJBUiq1QLJKGqYoCgqaFigyQUyJQttRLo9js3TTNs1zP9PmPYtT3pQTK0nUTKjEDJSjSMosnnZj0GMm4QF6HEdzTfgICJIItIpfDdMIs8xwv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Emgki4aCAgHAFpaBumCCULgvhgjhFyRFqEUGTyXlfJMQABW+hs-6aQkhKGUOcpAoxUDArgN-Vo6IPlDTGfXJAZAQl8FmpYH+Xpyn7PQFWBoxz3QAEcGCjWrmoGgpEbnIIUe8tpxiI560oedFaXs4BrQANS7QgAdDYUBQjazCeiJiOoJWaK2KCiOEKfpJNQC+G+YthBkHkAqGJGclVCwZgq7R4rJVKKBGQQJAAKecOQFB2odRyBQKRqhiAAJR+HucoNhlqbWOoDc611Hq-DwuQEilFO8hrwGgeiI4Sh3APPoGgBCoKiQZzBqAfigT5pKBpOstVoAIC-Mzvy6sGQhqKg9vXL44S6DsF1SYfQ9S1AXXtDdXazwHBipAGW+OhQ+Ri01ovPtIAfYDqSEOhyvSTAjTGhNTNIBjoZpUK2la7aACEW1O0ym7cnJQe97hUoOWPa52rdVZ1hijfwSAXmk3dBcn6mk4XYpfBAk1U45LTQdAnROi981QszrNfO48l17KyZsBSlcZ2RPnVSRdy6Z5rsoO2rat0u2yEeinQ9mBj3ktPUoHQ-cL25hsNewJd6HAPoecoZ9KhX3gJ+Voz9jHkZQMYZYJgx4hoAcLfcU9ZTwMHMg6VRe37M61t+nEOQQHm0LWQ6h9Du7MOe1ju6X9gcnFqd9onJOUbBrdCAA). - Download as SVG. - Manually edit to: (1) remove all class names, (2) change the width and height to match the view box, (3) change puffin to uv, (4) make uv bold. - Copy to create the dark-mode variant, and replace `#333333` with `#C9D1D9`. --- .github/workflows/build-binaries.yml | 20 ++++ README.md | 14 ++- assets/svg/Benchmark-Dark.svg | 147 +++++++++++++++++++++++++++ assets/svg/Benchmark-Light.svg | 147 +++++++++++++++++++++++++++ scripts/transform_readme.py | 64 ++++++++++++ 5 files changed, 391 insertions(+), 1 deletion(-) create mode 100644 assets/svg/Benchmark-Dark.svg create mode 100644 assets/svg/Benchmark-Light.svg create mode 100644 scripts/transform_readme.py diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index e5e216293..8df6ce0d0 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -43,6 +43,8 @@ jobs: - uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} + - name: "Prep README.md" + run: python scripts/transform_readme.py --target pypi - name: "Build sdist" uses: PyO3/maturin-action@v1 with: @@ -70,6 +72,8 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 + - name: "Prep README.md" + run: python scripts/transform_readme.py --target pypi - name: "Build wheels - x86_64" uses: PyO3/maturin-action@v1 with: @@ -109,6 +113,8 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 + - name: "Prep README.md" + run: python scripts/transform_readme.py --target pypi - name: "Build wheels - universal2" uses: PyO3/maturin-action@v1 with: @@ -159,6 +165,8 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: ${{ matrix.platform.arch }} + - name: "Prep README.md" + run: python scripts/transform_readme.py --target pypi - name: "Build wheels" uses: PyO3/maturin-action@v1 with: @@ -206,6 +214,8 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 + - name: "Prep README.md" + run: python scripts/transform_readme.py --target pypi - name: "Build wheels" uses: PyO3/maturin-action@v1 with: @@ -282,6 +292,8 @@ jobs: - uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} + - name: "Prep README.md" + run: python scripts/transform_readme.py --target pypi - name: "Build wheels" uses: PyO3/maturin-action@v1 with: @@ -347,6 +359,8 @@ jobs: - uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} + - name: "Prep README.md" + run: python scripts/transform_readme.py --target pypi - name: "Build wheels" uses: PyO3/maturin-action@v1 with: @@ -414,6 +428,8 @@ jobs: - uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} + - name: "Prep README.md" + run: python scripts/transform_readme.py --target pypi - name: "Build wheels" uses: PyO3/maturin-action@v1 with: @@ -484,6 +500,8 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 + - name: "Prep README.md" + run: python scripts/transform_readme.py --target pypi - name: "Build wheels" uses: PyO3/maturin-action@v1 with: @@ -546,6 +564,8 @@ jobs: - uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} + - name: "Prep README.md" + run: python scripts/transform_readme.py --target pypi - name: "Build wheels" uses: PyO3/maturin-action@v1 with: diff --git a/README.md b/README.md index 1e3540ef0..80be6c057 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,17 @@ An extremely fast Python package installer and resolver, written in Rust. Designed as a drop-in replacement for common `pip` and `pip-tools` workflows. -uv is backed by [Astral](https://astral.sh), the creators of [Ruff](https://github.com/astral-sh/ruff). +

+ + + + Shows a bar chart with benchmark results. + +

+ +

+ Installing the Trio dependencies with a warm cache. +

## Highlights @@ -29,6 +39,8 @@ uv is backed by [Astral](https://astral.sh), the creators of [Ruff](https://gith dependencies, direct URL dependencies, local dependencies, constraints, source distributions, HTML and JSON indexes, and more. +uv is backed by [Astral](https://astral.sh), the creators of [Ruff](https://github.com/astral-sh/ruff). + ## Getting Started Install uv with our standalone installers, or from [PyPI](https://pypi.org/project/uv/): diff --git a/assets/svg/Benchmark-Dark.svg b/assets/svg/Benchmark-Dark.svg new file mode 100644 index 000000000..cf61643e1 --- /dev/null +++ b/assets/svg/Benchmark-Dark.svg @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + 0s + + 2s + + 4s + + + + + + + + + + + + uv + + poetry + + pdm + + pip-sync + + + + + + + + + + + + + + 0.99s + + 1.90s + + 4.63s + + + + 0.06s + + + + + + + + + + + + diff --git a/assets/svg/Benchmark-Light.svg b/assets/svg/Benchmark-Light.svg new file mode 100644 index 000000000..aa878563e --- /dev/null +++ b/assets/svg/Benchmark-Light.svg @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + 0s + + 2s + + 4s + + + + + + + + + + + + uv + + poetry + + pdm + + pip-sync + + + + + + + + + + + + + + 0.99s + + 1.90s + + 4.63s + + + + 0.06s + + + + + + + + + + + + diff --git a/scripts/transform_readme.py b/scripts/transform_readme.py new file mode 100644 index 000000000..6708c1725 --- /dev/null +++ b/scripts/transform_readme.py @@ -0,0 +1,64 @@ +"""Transform the README.md to support a specific deployment target. + +By default, we assume that our README.md will be rendered on GitHub. However, different +targets have different strategies for rendering light- and dark-mode images. This script +adjusts the images in the README.md to support the given target. +""" + +from __future__ import annotations + +import argparse +from pathlib import Path + +URL = "https://github.com/astral-sh/uv/assets/1309177/{}" +URL_LIGHT = URL.format("629e59c0-9c6e-4013-9ad4-adb2bcf5080d") +URL_DARK = URL.format("03aa9163-1c79-4a87-a31d-7a9311ed9310") + +# https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#specifying-the-theme-an-image-is-shown-to +GITHUB = f""" +

+ + + + Shows a bar chart with benchmark results. + +

+""" + +# https://github.com/pypi/warehouse/issues/11251 +PYPI = f""" +

+ Shows a bar chart with benchmark results. +

+""" + + +def main(target: str) -> None: + """Modify the README.md to support the given target.""" + with Path("README.md").open(encoding="utf8") as fp: + content = fp.read() + if GITHUB not in content: + msg = "README.md is not in the expected format." + raise ValueError(msg) + + if target == "pypi": + with Path("README.md").open("w", encoding="utf8") as fp: + fp.write(content.replace(GITHUB, PYPI)) + else: + msg = f"Unknown target: {target}" + raise ValueError(msg) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + description="Modify the README.md to support a specific deployment target.", + ) + parser.add_argument( + "--target", + type=str, + required=True, + choices=("pypi", "mkdocs"), + ) + args = parser.parse_args() + + main(target=args.target)