2.1 KiB
Development Guide
Quick Start
uv and pyproject.toml are used for Python package setup and dependency management.
- Clone the project using git
- Create the venv:
uv sync. This will create a virtual environment in the.venvdirectory, using python specified in the.python-versionfile. By default, this will include thedevdependencies. - Activate the venv:
source .venv/bin/activate(Linux or MacOS) - Install the project in editable mode:
uv pip install -e . - Install the pre-commit hooks:
pre-commit install
Processes
Environment Management
python-dotenv is used to manage environment variables. These are stored in a .env file in the project root.
.env.example is provided as a template for the .env file.
Dependency Management
Dependencies are defined within requirements.in and requirements-dev.in files.
These are then compiled into requirements.txt and requirements-dev.txt files using compile-reqs command.
For best compatibility with and without uv, dependencies from requirements.txt and requirements-dev.txt are also
added to the pyproject.toml file using uv add -r requirements.txt and uv add -r requirements-dev.txt --dev.
This allows us to use uv sync to install the dependencies from the pyproject.toml file into the virtual environment.
As the uv ecosystem matures, the requirements.txt files may be phased out in favor of the pyproject.toml file.
Adding or Updating Dependencies
- Add the package to the relevant
.infile - Run
compile-reqs(installed as project script) to compile the requirements files - Run
uv add -r requirements.txtand/oruv add -r requirements-dev.txt --dev, to update thepyproject.tomlfile with the new dependencies. - Run
uv syncto update the virtual environment with the new dependencies.
The complete list of installed packages can be shown using uv tree.
Pre-commit Hooks
Pre-commit hooks are used to enforce code quality and style standards.
These are defined in the .pre-commit-config.yaml file.
To install the pre-commit hooks, run pre-commit install.