-
-
Notifications
You must be signed in to change notification settings - Fork 142
Replace pip
with uv
#579
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
base: master
Are you sure you want to change the base?
Replace pip
with uv
#579
Conversation
requirements_prod.txt
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been moved to a UV dependency group instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that UV specific or an accepted Python PEP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it was left out of scope when PEP-0621 was proposed. Poetry and UV move dependencies into groups, a default one that is always installed, along with optional groups of dependencies that we can install.
uv sync
installs dependencies + dev dependencies
uv sync --no-dev
install project dependencies without any development
uv sync --group prod
installs dependencies + prod dependencies
etc.
This makes it easy for us to manage different scope of dependencies within the project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Digging through UV's documentation a little more, dependencies are specified using Python dependency specification, and it follows PEP-621 standard, but it seems the dependency grouping spec is mainly UV-specific from what I understood.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I'll have to give this a test spin. I am not entirely sure if I'll like uv (never used it before).
This also calls for us switching to dependabot, but not sure if that can bump the uv version in the github actions workflow.
.python-version
Outdated
@@ -0,0 +1 @@ | |||
3.13.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't this be part of pyproject.toml?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can. uv
creates this by default, given some Python toolings read this file. I will remove this and keep it in pyproject.toml
, then update workflow
to revert to its original version selection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 6634c9b
(#579)
requirements_prod.txt
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that UV specific or an accepted Python PEP?
"pytest>=8.4.1", | ||
"pytest-cov>=6.2.1", | ||
"pytest-django>=4.11.1", | ||
"ruff>=0.12.11", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
venv managed ruff :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will still be in venv
. uv
will only install this when we install dev
dependencies (enabled by default). Before, we had to install this separately with pip
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but I prefer system linters ;-)
from django.core.files.base import ContentFile | ||
from django.utils.encoding import smart_str | ||
|
||
import cssmin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ruff check .
is happy for me, why is the uv used ruff not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it be that you are running a different version of ruff
? We are installing the latest in the CI:
archweb/.github/workflows/main.yml
Line 19 in 59229f2
pip install -r requirements.txt && pip install -r requirements_test.txt && pip install ruff |
This is one of the benefits of managing dependencies with uv
, since we are now locking a particular version and making sure we always run that version, without having a separate requirements
for each group.
|
||
lint: | ||
flake8 --extend-exclude "*/migrations/,local_settings.py" devel main mirrors news packages releng templates todolists visualize *.py | ||
uv run flake8 --extend-exclude "*/migrations/,local_settings.py" devel main mirrors news packages releng templates todolists visualize *.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should re-evaluate if ruff already has the formatting rules, or ugh ruff format
I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ruff
actually replaces flake8
, so we can technically get rid of this and have one tool to handle formatting/linting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"replaces", not entirely most of the E1 rules are not yet implemented and if implemented are preview rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, this will be handled in a follow up by moving to ruff format
On August 30, 2025 2:41:12 PM UTC, Ben Mezger ***@***.***> wrote:
benmezger left a comment (archlinux/archweb#579)
> This also calls for us switching to dependabot, but not sure if that can bump the uv version in the github actions workflow.
@jelly it [can](https://github.blog/changelog/2025-03-13-dependabot-version-updates-now-support-uv-in-general-availability/):
```yaml
version: 2
enable-beta-ecosystems: true
updates:
- package-ecosystem: "uv"
directory: "/"
schedule:
interval: "daily"
```
Can dependabot run on gitlab though?
|
@benmezger renovate should already support |
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.13 | ||
python-version: "3.13.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
lint: | ||
flake8 --extend-exclude "*/migrations/,local_settings.py" devel main mirrors news packages releng templates todolists visualize *.py | ||
uv run flake8 --extend-exclude "*/migrations/,local_settings.py" devel main mirrors news packages releng templates todolists visualize *.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"replaces", not entirely most of the E1 rules are not yet implemented and if implemented are preview rules.
|
||
lint: | ||
flake8 --extend-exclude "*/migrations/,local_settings.py" devel main mirrors news packages releng templates todolists visualize *.py | ||
uv run flake8 --extend-exclude "*/migrations/,local_settings.py" devel main mirrors news packages releng templates todolists visualize *.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, this will be handled in a follow up by moving to ruff format
desc = cursor.description | ||
return [ | ||
dict(zip([col[0] for col in desc], row)) | ||
dict(zip([col[0] for col in desc], row, strict=False)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be a place where strict=True
seems fine to use.
[project] | ||
name = "archweb" | ||
version = "0.1.0" | ||
description = "Archlinux website code" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arch Linux ;-)
"pytest>=8.4.1", | ||
"pytest-cov>=6.2.1", | ||
"pytest-django>=4.11.1", | ||
"ruff>=0.12.11", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but I prefer system linters ;-)
I've been using
UV
inarchweb
to handle dependencies andvenv
management a little easier. Given that, I am opening a PR with the changes I made, in case you want to migrate frompip
toUV
.I will take care of the infrastructure PR, so if one wants to merge this, it's better to wait for the infra PR.