1. Initialise A New Python Project
1.1 Download and Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
mkdir NameOfNewProject && cd $_
1.2 Create Project
uv init
1.3 Check Project Initialisations
Inside pyproject.toml
:
requires-python = ">=3.13"
dependencies = []
These can be updated later.
1.4 Check Python Version
uv run python --version
The first time uv run
is executed, two files are created:
.venv
anduv.lock
Responsible for keeping track of python package dependencies and versions.
2. Add Dependencies
2.1 Add a project dependency via terminal
uv add typer
Adds typer
to dependencies
list in .toml
file and resolves all dependencies.
2.2 Add dev-dependency via terminal
uv add pytest --dev
Adds pytest
to dev
dependencies
list in .toml
file and resolves all dependencies.
3. Create pytest
Tests
3.1 Create Test Folder & File
code tests/test_main.py
def test_main(): assert True
3.2 Run Test
uv run pytest
Note: I wrote the equivalent thing but in bash
[TBA] Updating Python versions
[TBA] Updating Redudencies .toml
[TBA] DEV DEP VIA UVX OR UV TOOL RUN
[TBA] ADD COMPLEX PKGS