Skip to content

feat: add support for uv #1631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2025
Merged

Conversation

akhilnarang
Copy link
Member

@akhilnarang akhilnarang commented May 8, 2025

Initial rough benchmarks

Some very rough benchmarks:

hyperfine --prepare "rm -rf env && python -m venv ./env && pip cache purge" --cleanup "rm -rf env && python -m venv ./env && pip cache purge" "./env/bin/pip install -e ./frappe" --show-output

Time (mean ± σ):     58.030 s ±  1.462 s    [User: 26.213 s, System: 4.352 s]
  Range (min … max):   55.937 s … 60.069 s    10 runs

hyperfine --prepare "rm -rf env && uv venv ./env && rm -rf ~/.cache/uv" --cleanup "rm -rf env && uv venv ./env && rm -rf ~/.cache/uv" "uv pip install -e ./frappe --python ./env/bin/python" --show-output

Time (mean ± σ):     10.848 s ±  0.362 s    [User: 9.305 s, System: 3.330 s]
  Range (min … max):   10.502 s … 11.645 s    10 runs

Probably a better way, just frappe app
FROM python:3.13-slim

RUN apt update -y

RUN apt install pkg-config libmariadb-dev build-essential -y

RUN pip install uv

COPY frappe /frappe

WORKDIR /

hyperfine --warmup 3 --runs 20 'docker run --rm benchmark pip install --no-cache-dir -e /frappe' 'docker run --rm benchmark uv pip install --no-cache -e /frappe --system'

Tool Mean Time (± σ) Time Range (min ... max) Runs
pip 54.701 s ± 3.145 s 47.724 s … 59.360 s 20
uv 17.640 s ± 1.729 s 14.448 s … 20.396 s 20

Summary:

uv ran 3.10 ± 0.35 times faster than pip.

frappe+erpnext
❯ hyperfine --warmup 2 --runs 10 'docker run --rm benchmark bash /pip.sh' 'docker run --rm benchmark bash /uv.sh'

Benchmark 1: docker run --rm benchmark bash /pip.sh
  Time (mean ± σ):     62.483 s ±  3.292 s    [User: 0.014 s, System: 0.018 s]
  Range (min … max):   59.350 s … 70.381 s    10 runs

Benchmark 2: docker run --rm benchmark bash /uv.sh
  Time (mean ± σ):     20.159 s ±  2.653 s    [User: 0.007 s, System: 0.011 s]
  Range (min … max):   17.383 s … 23.804 s    10 runs

Summary
  docker run --rm benchmark bash /uv.sh ran
    3.10 ± 0.44 times faster than docker run --rm benchmark bash /pip.sh

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
Copy link

@akhilnarang akhilnarang marked this pull request as ready for review June 12, 2025 08:06
@akhilnarang akhilnarang requested a review from Copilot June 12, 2025 10:23
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR integrates the uv installer as an optional, faster replacement for pip, controlled by the BENCH_USE_UV environment flag.

  • Adds uv as a dependency in pyproject.toml.
  • Wraps existing pip and venv commands across bench tooling to use uv when enabled.
  • Updates the bench CLI and related modules to conditionally exec uv-based commands.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pyproject.toml Added uv~=0.7.12 dependency
bench/utils/bench.py Branches dev-deps install, virtualenv and app install on BENCH_USE_UV
bench/commands/make.py Pip wrapper now exec’s uv pip when BENCH_USE_UV is set
bench/bench.py Uses uv for freeze, venv creation, and install flows
bench/app.py Uninstall and install flows updated to use uv pip
Comments suppressed due to low confidence (3)

pyproject.toml:31

  • [nitpick] Consider updating the project README or contributor guide to document the new uv dependency and how to enable BENCH_USE_UV mode.
"uv~=0.7.12"

bench/utils/bench.py:102

  • The new BENCH_USE_UV branches introduce alternate code paths that currently lack tests; add unit or integration tests to cover UV-based install and venv creation.
if os.environ.get("BENCH_USE_UV"):

bench/utils/bench.py:252

  • The variable pyenv is not defined here; it should likely be pvenv to reference the virtualenv path.
exec_cmd(f"uv pip install --upgrade {app_path} --python {pyenv}/bin/python")

@akhilnarang akhilnarang merged commit 24e45ba into frappe:develop Jun 12, 2025
13 checks passed
@akhilnarang akhilnarang deleted the uv-install branch June 12, 2025 10:28
Copy link

🎉 This PR is included in version 5.25.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@barredterra barredterra changed the title refactor: use uv feat: add support for uv Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant