Skip to content

Commit 09a82a0

Browse files
chore: Simplify toolchain to use UV for build and environment management (#293)
* chore: convert project over to uv from pipenv * chore: clean up pip and pipfile artifacts * chore: update pyproject with classifiers - remove setup.py as the last bit of information is moved over * chore: update docs to remove superfluous information and update for uv * chore: update workflows * chore: update other github workflows * chore: update pyproject.toml to add missing variables
1 parent 7043726 commit 09a82a0

17 files changed

+746
-1552
lines changed

.github/workflows/advanced-prechecks-unix.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ jobs:
1515
if: ${{ github.event.label.name == 'ci' }}
1616
strategy:
1717
matrix:
18-
python-version: [ '3.7', '3.8', '3.9', '3.10' ]
18+
python-version: [ '3.10', '3.11', '3.12', '3.13' ]
1919
name: Ubuntu prechecks - Python ${{ matrix.python-version }}
2020
steps:
21-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v5
2222

23-
- uses: actions/setup-python@v3
23+
- uses: actions/setup-python@v6
2424
with:
2525
python-version: ${{ matrix.python-version }}
2626
architecture: x64
@@ -42,15 +42,15 @@ jobs:
4242
if: ${{ github.event.label.name == 'ci' }}
4343
strategy:
4444
matrix:
45-
python-version: [ '3.6', '3.8', '3.9', '3.10' ]
45+
python-version: [ '3.10', '3.11', '3.12', '3.13' ]
4646
env:
4747
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
4848
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
4949
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEPLOYMENT_REGION }}
5050

5151
name: RHEL8 prechecks - Python ${{ matrix.python-version }}
5252
steps:
53-
- uses: actions/checkout@v3
53+
- uses: actions/checkout@v5
5454

5555
- name: Install packer
5656
uses: hashicorp-contrib/setup-packer@v1

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939

4040
steps:
4141
- name: Checkout repository
42-
uses: actions/checkout@v2
42+
uses: actions/checkout@v5
4343

4444
# Initializes the CodeQL tools for scanning.
4545
- name: Initialize CodeQL

.github/workflows/default-prechecks-unix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
- uses: actions/setup-python@v3
1919
with:
20-
python-version: 3.8
20+
python-version: "3.10"
2121
architecture: x64
2222

2323
- name: Install pipenv

.github/workflows/pypi-upload.yml

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,22 @@ jobs:
1313
working-directory: unix
1414

1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v5
1717

1818
- uses: actions/setup-python@v6
1919
with:
2020
python-version: "3.10"
2121
architecture: x64
2222

23-
- name: Autobump version
24-
run: |
25-
# from refs/tags/v1.2.3 get 1.2.3
26-
VERSION=${GITHUB_REF/refs\/tags\//}
27-
PLACEHOLDER='__version__ = "v0.1.0"'
28-
VERSION_FILE='src/machine_stats/_version.py'
29-
30-
# grep ensures the placeholder is there. If grep doesn't find the placeholder
31-
# it exits with exit code 1 and github actions aborts the build.
32-
grep "$PLACEHOLDER" "$VERSION_FILE"
33-
34-
sed -i "s/$PLACEHOLDER/__version__ = \"${VERSION}\"/g" "$VERSION_FILE"
35-
36-
- name: Install pypa/build and twine
37-
run: |
38-
python -m pip install build twine
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v6
25+
with:
26+
enable-cache: true
3927

40-
- name: Build a binary wheel and a source tarball
41-
run: |
42-
python -m build --sdist --wheel --outdir dist/ .
28+
- name: Install the project
29+
run: uv build
4330

44-
- name: Upload to PyPI via Twine
31+
- name: Publish
4532
env:
46-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
47-
run: |
48-
twine upload --verbose -u '__token__' dist/*
33+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
34+
run: uv publish

.github/workflows/python-tests.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,21 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.10", "3.11"]
14+
python-version: ["3.10", "3.11", "3.12", "3.13"]
1515

1616
steps:
17-
- uses: actions/checkout@v3
18-
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v4
17+
steps:
18+
- uses: actions/checkout@v5
19+
20+
- name: Install uv and set the Python version
21+
uses: astral-sh/setup-uv@v6
2022
with:
2123
python-version: ${{ matrix.python-version }}
22-
- name: Install dependencies
23-
run: |
24-
cd ./unix
25-
python -m pip install --upgrade pip
26-
pip install -r requirements.txt
27-
pip install -r dev-requirements.txt
28-
- name: Test with pytest
29-
run: |
30-
pytest
24+
enable-cache: true
25+
26+
- name: Install the project
27+
run: uv sync --locked --all-extras --dev
28+
29+
- name: Run tests
30+
# For example, using `pytest`
31+
run: uv run pytest tests

unix/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ hosts
33
build/
44
dist/
55
machine_stats.egg-info
6+
.devenv/
7+
.direnv/

unix/CONTRIBUTING.md

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,27 @@ Under the hood Machine Stats relies on the awesome [Ansible SDK](https://docs.an
88

99
## Technicalities
1010

11-
Development on the latest version of Python is preferred. As of this writing
12-
it's 3.9. You can use any operating system.
11+
Development on the latest version of Python is preferred. As of this
12+
writing it's 3.14. You can use any operating system. We use the
13+
wonder [uv tool](https://docs.astral.sh/uv/) for a modern take on
14+
python package management. If you don't have it installed follow the
15+
appropriate instructions for your OS/package manager of choice.
1316

1417
Install all development dependencies using:
1518

1619
```console
17-
pipenv install --dev
18-
```
19-
20-
If you haven't used `pipenv` before but are comfortable with virtualenvs, just
21-
run `pip install pipenv` in the virtualenv you're already using and invoke the
22-
command above from the `unix` directory of the cloned _Machine Stats_ repo. It
23-
will do the correct thing.
24-
25-
Make changes in the source code (e.g in `src/machine_stats/__init__.py`) and
26-
run `pipenv run machine_stats` to run it locally.
27-
28-
Non `pipenv` install works too:
29-
30-
```console
31-
pip install -r requirements.txt
32-
pip install -r dev-requirements.txt
33-
pip install -e .
20+
uv sync
3421
```
3522

3623
### Tools
3724

3825
We use the following tools:
3926

40-
* `black` for code formatting (`pipenv run black .`)
41-
* `isort` to sort imports (`pipenv run isort .`)
42-
* `flake8` or `pylint` for code linting (`pipenv run flake8
43-
src/machine_stats/*` or `pipenv run pylint src`)
44-
* `bump2version` for version bumps (`pipenv run bump2version`)
27+
* uv for modern python project management
28+
* `black` for code formatting (`uv run black .`)
29+
* `isort` to sort imports (`uv run isort .`)
30+
* `flake8` or `pylint` for code linting (`uv run flake8
31+
src/machine_stats/*` or `uv run pylint src`)
4532

4633
### Testing
4734

@@ -56,7 +43,7 @@ pytest
5643
or
5744

5845
```console
59-
pipenv run pytest
46+
uv run pytest
6047
```
6148

6249
### How to release a new Machine Stats version
@@ -75,7 +62,7 @@ To deploy a new version of Machine Stats, you will need to create a release. The
7562

7663
When you create a PR, the GitHub workflows check for the linting and CodeQL. However, if you think you're introducing breaking changes, then please add the label `ci` with your PR. This will run the Advanced Prechecks workflow that checks Machine Stats' working in the following system environments:
7764

78-
* Ubuntu 20.04 - Python 3.7 to 3.10
65+
* Ubuntu 24.04 - Python 3.7 to 3.10
7966
* RHEL 8 - Python 3.6, 3.8 to 3.10
8067

8168
## Finally

unix/Pipfile

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

0 commit comments

Comments
 (0)