Skip to content

Commit b14c575

Browse files
DonDebonairFizzadar
authored andcommitted
feat: use uv for project and dependency management
This commit replaces setuptools with uv, standardizing on pyproject.toml to define project metadata Major changes include: - All metadata has been moved from `setup.py` to `pyproject.toml` - `pyinfra` and `pyinfra_cli` packages now reside inside a `src` folder. The big advantage of this is that this separates the code from tests and other files and prevents accidentally referencing files that are not packaged when building the project See: https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/ - All development commands for testing and linting are now run through `uv run` - Dependency versions have been redefined using broader version ranges, but are kept to one version through a lock file - Python 3.9 support has been dropped (it will reach EOL 2025-10) - Python 3.13 support has been added - Github workflows have been rewritten to use uv - Package version is now generated from git, using uv-dynamic-versioning
1 parent eb0e683 commit b14c575

File tree

175 files changed

+2044
-335
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+2044
-335
lines changed

.flake8

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[flake8]
2+
exclude = .git,.venv,build
3+
ignore = W503,C815,C816,E704,E203,SC
4+
max-line-length = 100
5+
6+
# flake8-quotes
7+
inline-quotes = double
8+
multiline-quotes = double
9+
docstring-quotes = double
10+
11+
# flake8-import-order
12+
import-order-style = edited
13+
application-import-names = pyinfra,pyinfra_cli,docs
14+
15+
# flake8-spellcheck
16+
whitelist = tests/words.txt
17+
dictionaries=en_US,python,technical,django

.github/workflows/docs.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ jobs:
1515
if: github.repository == 'pyinfra-dev/pyinfra'
1616
steps:
1717
- name: Clone Source Repository
18-
uses: actions/checkout@v4
18+
uses: actions/checkout@v5
1919

2020
- name: Fetch git tags
2121
run: git fetch --tags origin
2222

2323
- name: Clone Generated Repository
24-
uses: actions/checkout@v4
24+
uses: actions/checkout@v5
2525
with:
2626
token: ${{ secrets.ACCESS_TOKEN }}
27-
repository: fizzadar/docs.pyinfra.com
27+
repository: pyinfra-dev/docs.pyinfra.com
2828
path: docs/public/
2929

3030
- name: Set up Python
3131
uses: actions/setup-python@v5
3232

3333
- name: Install
3434
run: |
35-
pip install '.[docs]'
36-
pip install 'jinja2<3.1'
35+
uv sync --group docs --no-default-groups
36+
uv pip install 'jinja2<3.1'
3737
3838
- name: Generate documentation
3939
run: scripts/build-public-docs.sh

.github/workflows/test.yml

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,67 +16,54 @@ jobs:
1616
lint:
1717
runs-on: ubuntu-24.04
1818
steps:
19-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@v5
2020
- uses: actions/setup-python@v5
2121
with:
22-
python-version: "3.12"
23-
- run: pip install '.[test]'
24-
- run: flake8
22+
python-version: "3.13"
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v6
25+
- run: uv sync --group test --no-default-groups
26+
- run: uv run flake8
2527

2628
type-check:
2729
runs-on: ubuntu-24.04
2830
steps:
29-
- uses: actions/checkout@v4
31+
- uses: actions/checkout@v5
3032
- uses: actions/setup-python@v5
3133
with:
32-
python-version: "3.12"
33-
- run: pip install '.[test]'
34-
- run: mypy
34+
python-version: "3.13"
35+
- name: Install uv
36+
uses: astral-sh/setup-uv@v6
37+
- run: uv sync --group test --no-default-groups
38+
- run: uv run mypy
3539

3640
spell-check:
3741
runs-on: ubuntu-24.04
3842
steps:
39-
- uses: actions/checkout@v4
43+
- uses: actions/checkout@v5
4044
- name: Check spelling
4145
uses: crate-ci/[email protected]
4246

43-
# Test instal works on untestable Python versions. This came about because click decided to drop
44-
# Python 3.9 support before EOL, so 3.9 was dropped from the unit test matrix. Still need to test
45-
# that pyinfra can be built on 3.9.
46-
build-legacy-versions:
47-
strategy:
48-
matrix:
49-
python-version: ["3.9"]
50-
runs-on: ubuntu-24.04
51-
steps:
52-
- uses: actions/checkout@v4
53-
- uses: actions/setup-python@v5
54-
with:
55-
python-version: ${{ matrix.python-version }}
56-
- run: pip install '.'
57-
- run: pyinfra --help
58-
59-
# Unit tests
60-
#
61-
6247
unit-test:
6348
needs:
6449
- lint
6550
- type-check
6651
strategy:
6752
matrix:
6853
os: [ubuntu-22.04, ubuntu-24.04, macos-13, macos-14, macos-15,windows-2022, windows-2025]
69-
python-version: ["3.10", "3.11", "3.12"]
54+
python-version: ["3.10", "3.11", "3.12", "3.13"]
7055
runs-on: ${{ matrix.os }}
7156
steps:
72-
- uses: actions/checkout@v4
57+
- uses: actions/checkout@v5
7358
- uses: actions/setup-python@v5
7459
with:
7560
python-version: ${{ matrix.python-version }}
76-
- run: pip install '.[test]'
77-
- run: pytest --cov --disable-warnings
61+
- name: Install uv
62+
uses: astral-sh/setup-uv@v6
63+
- run: uv sync --group test --no-default-groups --python=${{ matrix.python-version }}
64+
- run: uv run pytest --cov --disable-warnings
7865
- name: Upload coverage report to codecov
79-
if: ${{ matrix.os == 'ubuntu-24.04' && matrix.python-version == '3.12' }}
66+
if: ${{ matrix.os == 'ubuntu-24.04' && matrix.python-version == '3.13' }}
8067
uses: codecov/codecov-action@v5
8168

8269
# End-to-end tests
@@ -90,28 +77,29 @@ jobs:
9077
matrix:
9178
os: [ubuntu-22.04, ubuntu-24.04]
9279
test-name: [local, ssh, docker, podman]
93-
python-version: ["3.10", "3.11", "3.12"]
80+
python-version: ["3.10", "3.11", "3.12", "3.13"]
9481
include:
9582
- os: macos-13
9683
test-name: local
97-
python-version: "3.12"
84+
python-version: "3.13"
9885
- os: macos-14
9986
test-name: local
100-
python-version: "3.12"
87+
python-version: "3.13"
10188
- os: macos-15
10289
test-name: local
103-
python-version: "3.12"
90+
python-version: "3.13"
10491
runs-on: ${{ matrix.os }}
10592
steps:
106-
- uses: actions/checkout@v4
93+
- uses: actions/checkout@v5
10794
- uses: actions/setup-python@v5
10895
with:
10996
python-version: ${{ matrix.python-version }}
110-
- run: pip install '.[test]'
111-
- run: pytest -m end_to_end_${{ matrix.test-name }}
97+
- name: Install uv
98+
uses: astral-sh/setup-uv@v6
99+
- run: uv sync --group test --no-default-groups --python=${{ matrix.python-version }}
100+
- run: uv run pytest -m end_to_end_${{ matrix.test-name }}
112101

113102
# Finally, single jon to check if all completed, for use in protected branch
114-
#
115103

116104
tests-done:
117105
if: ${{ always() }}

MANIFEST.in

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/contributing.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@ Third party pull requests help expand pyinfra's functionality and are essential
1818

1919
## Dev Setup
2020

21+
First, install [uv](https://docs.astral.sh/uv/).
22+
23+
Then, set up a development environment:
24+
2125
```sh
22-
# Create a virtualenv with your tool of choice
23-
# python -m venv / pyenv virtualenv / virtualenv
26+
# There is no need to create a virtualenv, uv will do that for you
2427

2528
# Clone the repo
2629
git clone [email protected]:pyinfra-dev/pyinfra.git
2730

2831
# Install the package in editable mode with development requirements
2932
cd pyinfra
30-
pip install -e '.[dev]'
33+
uv sync
3134
```
3235

3336
### Code Style & Type Checking
@@ -54,10 +57,10 @@ To limit the pytests to a specific fact or operation:
5457

5558
```sh
5659
# Only run fact tests for facts.efibootmgr.EFIBootMGR
57-
pytest tests/test_facts.py -k "efibootmgr.EFIBootMGR"
60+
uv run pytest tests/test_facts.py -k "efibootmgr.EFIBootMGR"
5861

5962
# Only run operation tests for operations.selinux
60-
pytest tests/test_operations.py -k "selinux."
63+
uv run pytest tests/test_operations.py -k "selinux."
6164
```
6265

6366
#### End to End Tests
@@ -69,11 +72,11 @@ The end to end tests are also executed via `pytest` but not selected by default,
6972
scripts/dev-test-e2e.sh
7073

7174
# Run local e2e tests (works on Linux / MacOS, no Windows yet)
72-
pytest -m end_to_end_local
75+
uv run pytest -m end_to_end_local
7376

7477
# Run Docker and SSH e2e tests (Linux / MacOS with Docker installed)
75-
pytest -m end_to_end_ssh
76-
pytest -m end_to_end_docker
78+
uv run pytest -m end_to_end_ssh
79+
uv run pytest -m end_to_end_docker
7780
```
7881

7982
## Documentation

pyinfra/__main__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

pyinfra_cli/__main__.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)