Skip to content

Switch from venv/pip to uv #3148

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

Draft
wants to merge 5 commits into
base: dev
Choose a base branch
from
Draft

Switch from venv/pip to uv #3148

wants to merge 5 commits into from

Conversation

JohnStrunk
Copy link
Member

@JohnStrunk JohnStrunk commented May 5, 2025

Summary
This switches from using venv and pip for managing the python dependencies to using uv

Benefits

  • uv is much faster
  • uv maintains a lockfile (uv.lock) that includes the exact versions of all dependencies for the project, not just direct ones. This ensures that the environment is reproducible.
  • We now get consistent versions of all dependencies (previously, the order in which the setup.py scripts were called led to different package versions being installed)

Changes

  • Project direct dependencies are now in pyproject.toml, and all setup.py files have been removed. I did my best to migrate the metadata across where possible. setuptools is still used for the actual install.
  • The python version is now locked for the project via .python-version. uv will install this version of python when it creates the environment, so it no longer matters what python version is installed on the user's machine.
  • The "sub-packages" from augur/tasks/data_analysis have been pulled into the main project. I suspect this may be controversial, and I can separate them back out if necessary.
  • Backend Dockerfile has been updated to use uv based on uv's best-practices docs.

Assuming you all are good w/ this change, I'd like to update the docs prior to merge.

To try this out, the docker version should work as before, but if you're running outside of docker, you should:

  • Install uv: $ pip install --user uv
  • Prefix your "augur" commands w/ uv run, e.g., $ uv run augur backend start.

It's no longer necessary to manage the virtual environment or use pip directly, though you probably want to delete your old venv prior to starting w/ uv.

To do

  • GH action to ensure the lockfile is up-to-date
  • Documentation

JohnStrunk added 4 commits May 5, 2025 11:49
- Replaces setup.py with pyproject.toml
- Creates .python-version file that will control the python version that
  uv uses in the virtualenv

Signed-off-by: John Strunk <jstrunk@redhat.com>
Signed-off-by: John Strunk <jstrunk@redhat.com>
Signed-off-by: John Strunk <jstrunk@redhat.com>
Update GitHub workflow to include a new job that checks the uv lockfile,
ensuring it is up to date by installing uv and running the lock check
command.

Signed-off-by: John Strunk <jstrunk@redhat.com>
Added post_create_environment job to generate requirements.txt using uv,
and updated python install method to use the generated requirements file.

Signed-off-by: John Strunk <jstrunk@redhat.com>
@JohnStrunk
Copy link
Member Author

@sgoggins @Ulincsys Please take a look when you get a chance. If you're good w/ it, I'll get to work on revising the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant