Skip to content

Using UV Package Manager

├── apps/
│ ├── my-app-1/
│ │ ├── tests/
│ │ │ ├── __init__.py
│ │ │ └── test_main.py
│ │ ├── main.py
│ │ ├── pyproject.toml
│ │ └── README.md
│ └── my-app-2/
│ └── ...
├── components/
│ ├── my-component-1/
│ │ ├── src/
│ │ │ └── my_component_1/
│ │ │ ├── __init__.py
│ │ │ ├── py.typed
│ │ │ └── my_module.py
│ │ ├── tests/
│ │ │ └── test_my_module.py
│ │ ├── pyproject.toml
│ │ └── README.md
│ └── my-component-2/
│ └── ...
├── pyproject.toml
├── uv.lock
└── ...
Terminal window
uv init --package --lib components/my-component-1
uv init --app apps/my-app-1
uv add --package my-app-1 my-component-1
Terminal window
uv init hello-world # if outside dir, else uv init
uv run hello.py # runs a python file
Terminal window
uv add 'requests==2.31.0'
uv add pytest --dev
uv remove requests
# upgrade dependency
uv lock --upgrade-package requests
Terminal window
uv python install 3.8
uv venv
source .venv/bin/activate

Dev dependencies installed by default

To build, simply uv build

[tool.setuptools]
packages = ["jenkinsapi", "jenkinsapi_utils", "jenkinsapi_tests"]
Terminal window
uv lock # to generate uv.lock file
uv python uninstall --all # removes existing installs
uv cache clean
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: |
**/setup.cfg
**/pyproject.toml
- name: Install python
run: uv python install
- name: Lint with flake8
run: |
uv run flake8 jenkinsapi/
- name: Test with pytest
env:
JENKINS_VERSION: ${{ matrix.token }}
run: |
uv run pytest -sv jenkinsapi_tests

polylith example of uv and a monorepo