Repository navigation
Description
Summary
Create a uv.lock file instead of requirements.lock on dagger init, with dependency to generated ./sdk library ready to go, and update documentation recommending new project management workflow using uv.
Motivation
uv 0.3.0 was released two weeks ago, finally stabilizing uv.lock and generally making end-to-end project management (and more) ready for production use.
This is a long time coming, and makes uv the best tool today for Python packaging! This will make end-user instructions for using Python Dagger Modules easier.
For example:
- You no longer even need to have Python installed in your host because uv will download and set it up automatically
- You can install other Python tools like
hatchorpoetryusing uv, without having to installpipxor a similar tool - You don’t need to think about the virtual environment, as uv will manage it automatically
- You don’t need to manually edit
pyproject.tomlto add dependencies because you can do it with the uv CLI - We can now
dagger init, withpyproject.tomlanduv.lockalready recognizing the generatedsdklibrary and installing it automatically in the virtual environment
Updates to documentation
With uv as the default, we can now recommend the following development workflow for a new module, without any pre-requisites except for having uv (i.e., no need to have Python, pipx, etc… installed before starting):
❯ dagger init --sdk=python my-module
❯ cd my-module
❯ uv run vim
As another example, after a clean clone of an existing module, and using VSCode:
❯ uv run code .
The above will:
- download Python if not found
- create
.venvand install dependencies - open VSCode with that virtual environment activated
- VSCode should detect the
.venvin the root of the workspace and use it automatically to provide autocompletion capabilities
Note
With VSCode, you don’t need to open the editor from the terminal with an activated environment, it’s just better to run one command instead of two:
❯ uv sync
❯ code .
Rationale
There’s other tools that also provide a project management workflow, like Poetry and PDM. Poetry is the most used, but doesn’t follow standards (more importantly PEP 621).
However, even with PDM, these tools require a Python interpreter installed (e.g., pyvenv), and come with Python dependencies that need to be isolated in their own virtual environment, which requires installing yet another tool to be able to install it (e.g., pipx install pdm), and that’s before being able to start developing your Module.
Uv is a single binary, it’s very fast, and simplifies tremendously setting up a Python development environment, especially for new users.
Activity