|
|
|
|
|
by bb88
411 days ago
|
|
virtualenvs are great, but they're not great on their own. requirements.txt work sorta, but then any package with more than 50 requirements requires a non-trivial amount of manual labor to maintain. (Hell even 20 deps are a pain) Astral uv and poetry both maintain the pyproject.toml for you -- and as a bonus, they maintain the virtualenv underneath. Then for the complete python newbs, they can run 'uv sync' or 'poetry install' and they don't have to understand what a virtualenv is -- and they don't need root, and they don't have to worry about conflicts, or which virtualenv is which, etc. So the simple case: mkdir test
cd test
# init a new project with python 3.13
uv init -p 3.13
# Add project deps
uv add numpy
uv add ...
# Delete the venv
rm -rf .venv
# reinstall everything (with the exact versions)
uv sync
# Install a test package in your venv
uv pip install poetry
# force the virtualenv back into a sane state (removing poetry and all it's deps)
uv sync
# update all deps
rm uv.lock
uv lock
Now cat your pyproject.toml, and you'll see something like this: [project]
name = "test"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"numpy>=2.2.5",
"pillow>=11.2.1",
"scipy>=1.15.2",
]
|
|