Skip to content

Rendre uv indispensable pour le développement#5843

Merged
francoisfreitag merged 1 commit intomasterfrom
ff/uv
Apr 1, 2025
Merged

Rendre uv indispensable pour le développement#5843
francoisfreitag merged 1 commit intomasterfrom
ff/uv

Conversation

@francoisfreitag
Copy link
Copy Markdown
Member

🤔 Pourquoi ?

Unifier les environnements développeurs et éviter des problèmes spécifiques à la machine (distribution différente, versions de dépendances différentes, ...).

🍰 Comment ?

Using uv ensures developers use the same version of Python. uv uses the python-build-standalone [1], so requirements are built against a common set of dependencies (shipped with uv python), reducing discrepancies across developer environment.

The Python version is deduced by uv from the requires-python in pyproject.toml, so it doesn’t need to be specified again in the Makefile.
https://docs.astral.sh/uv/concepts/python-versions/#project-python-versions

uv picks the first Python version that is compatible with the requirement, so with requires-python = ">=3.13":

  • a 3.12 install is upgraded
  • a 3.13 install is kept
  • a 3.14 install is downgraded

[1] https://github.com/astral-sh/python-build-standalone

@francoisfreitag francoisfreitag self-assigned this Mar 27, 2025
@francoisfreitag francoisfreitag requested review from a team and rsebille March 27, 2025 11:04
@francoisfreitag francoisfreitag force-pushed the ff/uv branch 2 times, most recently from 1aa4594 to 95844f0 Compare March 27, 2025 11:13
Comment thread Makefile
$(PYTHON_VERSION) -m venv $@
$@/bin/pip install uv
$@/bin/uv pip sync --require-hashes $^
uv venv
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

On ne peut donc plus spécifier un venv créé séparément ?
Il faudrait peut être retirer la possibilité de modifier VIRTUAL_ENV

Copy link
Copy Markdown
Member Author

@francoisfreitag francoisfreitag Mar 28, 2025

Choose a reason for hiding this comment

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

Exact, ce n’était pas un retrait intentionnel. Est-ce que je re-spécifie $(VIRTUALENV) à uv pour qu’il le crée à l’endroit indiqué. Qui aurait besoin de cette option ?
@celine-m-s ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Je l'utilise actuellement pour créer mon venv avec virtualenvwrapper, mais je peux m'en passer en vrai, j'ai juste jamais pris la peine de changer d'outils depuis il y a 10 ans ^^'
Du coup je n'en ai plus besoin avec uv qui le fait à ma place

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Est-ce que je re-spécifie $(VIRTUALENV) à uv pour qu’il le crée à l’endroit indiqué.

Je dirais que oui, ça coûte pas grand chose pour permettre aux gens de faire comme il le souhaite.


Par contre de mon coté j'ai besoin de spécifier -p $(PYTHON_VERSION) sinon ça ne semble pas prendre le bon binaire, peut-être une histoire de system vs full-local 🤷, mais j'ai pas encore eu le temps de regarder en détail la chose.

Copy link
Copy Markdown
Contributor

@xavfernandez xavfernandez left a comment

Choose a reason for hiding this comment

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

👍

Comment thread Makefile
$(PYTHON_VERSION) -m venv $@
$@/bin/pip install uv
$@/bin/uv pip sync --require-hashes $^
uv venv
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Est-ce que je re-spécifie $(VIRTUALENV) à uv pour qu’il le crée à l’endroit indiqué.

Je dirais que oui, ça coûte pas grand chose pour permettre aux gens de faire comme il le souhaite.


Par contre de mon coté j'ai besoin de spécifier -p $(PYTHON_VERSION) sinon ça ne semble pas prendre le bon binaire, peut-être une histoire de system vs full-local 🤷, mais j'ai pas encore eu le temps de regarder en détail la chose.

Comment thread README.md

La commande `make` suivante crée un
[`virtualenv`](https://docs.python.org/3/library/venv.html) et installe les
[`virtualenv`](https://docs.astral.sh/uv/pip/environments/) et installe les
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Peut-être diriger vers une doc générique sur les virtualenv plutôt que l'outil utilisé ?

Suggested change
[`virtualenv`](https://docs.astral.sh/uv/pip/environments/) et installe les
[`virtualenv`](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#create-and-use-virtual-environments) et installe les

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Nope. Assez rapidement, la doc de packaging.python.org dit d’installer des paquets avec pip (python -m pip install ...). Hors, uv n’installe pas pip.

$ cd $(mktemp -d)
$ uv venv
Using CPython 3.12.9
Creating virtual environment at: .venv
Activate with: source .venv/bin/activate
$ source .venv/bin/activate
$ python -m pip install django
/tmp/tmp.pTFGPE2beB/.venv/bin/python: No module named pip

Using uv ensures developers use the same version of Python. uv uses the
python-build-standalone [1], so requirements are built against a common
set of dependencies (shipped with uv python), reducing discrepancies
across developer environment.

The Python version is deduced by `uv` from the `requires-python` in
`pyproject.toml`, so it doesn’t need to be specified again in the
Makefile.
https://docs.astral.sh/uv/concepts/python-versions/#project-python-versions

uv picks the first Python version that is compatible with the
requirement, so with requires-python = ">=3.13":
- a 3.12 install is upgraded
- a 3.13 install is kept
- a 3.14 install is downgraded

[1] https://github.com/astral-sh/python-build-standalone
@francoisfreitag francoisfreitag added this pull request to the merge queue Apr 1, 2025
Merged via the queue into master with commit fb40638 Apr 1, 2025
11 checks passed
@francoisfreitag francoisfreitag deleted the ff/uv branch April 1, 2025 15:20
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.

5 participants