Skip to content

Conversation

benmezger
Copy link
Contributor

@benmezger benmezger commented Aug 30, 2025

I've been using UV in archweb to handle dependencies and venv management a little easier. Given that, I am opening a PR with the changes I made, in case you want to migrate from pip to UV.

I will take care of the infrastructure PR, so if one wants to merge this, it's better to wait for the infra PR.

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

Copy link
Member

@jelly jelly left a 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
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 6634c9b (#579)

Copy link
Member

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",
Copy link
Member

Choose a reason for hiding this comment

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

venv managed ruff :(

Copy link
Contributor Author

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.

Copy link
Member

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
Copy link
Member

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?

Copy link
Contributor Author

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:

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
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

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

@benmezger
Copy link
Contributor Author

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:

version: 2
enable-beta-ecosystems: true
updates:
  - package-ecosystem: "uv"
    directory: "/"
    schedule:
      interval: "daily"

@lahwaacz
Copy link
Contributor

lahwaacz commented Aug 31, 2025 via email

@benmezger
Copy link
Contributor Author

benmezger commented Aug 31, 2025

@lahwaacz I think Arch's Gitlab uses renovate, but I don't think it supports uv yet. But it seems Gitlab does support Dependabot.

@lahwaacz
Copy link
Contributor

@benmezger renovate should already support uv: renovatebot/renovate#34494

uses: actions/setup-python@v5
with:
python-version: 3.13
python-version: "3.13.0"
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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))
Copy link
Member

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"
Copy link
Member

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",
Copy link
Member

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 ;-)

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.

3 participants