Skip to content

Commit c370be2

Browse files
authored
project: migrate from setup.cfg to pyproject.toml (#270)
- bump to python 3.12 as minimal requirement (and use it in all CI workflows) - migrate from setup.cfg to pyproject.toml - delete `bin/stack-config` in favour of `[project.scripts]` - setuptools: drop MANIFEST.in (in favour of `pyprojects.toml`) - add `dev` group of dependencies for development - drop `test_stackinator` custom script - adapt the github workflow accordingly - currently just `pytest`, but we can add other stuff, e.g. static checking, ... - add `docs` group of dependencies - adapt the github workflow accordingly - github workflows: took the chance to update and modernize with `uv` - minor: - add documentation url - add `license-file` reference - drop `requirements*.txt` files (migrated to dependency-groups) - update `.gitignore` With `uv tool install .` you get it installed as an editable package and the `stack-config` command is available without doing anything (no manual PATH update required). TODO: - [ ] check that packaging and publishing works correctly
1 parent b30a3fa commit c370be2

File tree

14 files changed

+111
-110
lines changed

14 files changed

+111
-110
lines changed

.github/workflows/docs.yaml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v3
15-
- uses: actions/setup-python@v4
15+
- name: Set up Python
16+
uses: actions/setup-python@v6
1617
with:
17-
python-version: 3.x
18-
- run: pip install --upgrade pip
19-
- run: |
20-
pip install -r requirements-docs.txt
18+
python-version: 3.12
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v6
21+
- name: Install Dependencies
22+
run: uv sync --group docs
23+
# TODO is it needed to cleanup site folder?
2124
- run: rm -rf site
22-
- run: mkdocs gh-deploy --force
23-
- run: mkdocs --version
25+
- name: Deploy Docs
26+
run: |
27+
uv run mkdocs gh-deploy --force
28+
uv run mkdocs --version

.github/workflows/lint.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v3
10+
- name: Set up Python
11+
uses: actions/setup-python@v6
12+
with:
13+
python-version: 3.12
1014
- name: Install uv
11-
run: |
12-
curl -LsSf https://astral.sh/uv/install.sh | sh
13-
- name: ruff
14-
run: |
15-
uvx ruff format --check
16-
uvx ruff check
15+
uses: astral-sh/setup-uv@v6
16+
- run: uvx ruff format --check
17+
- run: uvx ruff check

.github/workflows/main.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v3
10+
- name: Set up Python
11+
uses: actions/setup-python@v6
12+
with:
13+
python-version: 3.12
1014
- name: Install uv
11-
run: |
12-
curl -LsSf https://astral.sh/uv/install.sh | sh
15+
uses: astral-sh/setup-uv@v6
1316
- name: Validate Schemas
1417
run: |
1518
errors=0
@@ -19,6 +22,7 @@ jobs:
1922
errors=$(($errors + $?))
2023
done
2124
exit $errors
22-
- name: Generic Unittests
23-
run: |
24-
./test_stackinator.py
25+
- name: Install Dependencies
26+
run: uv sync --group dev
27+
- name: Run Unit Tests
28+
run: uv run pytest

.github/workflows/publish.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,18 @@ on:
77
jobs:
88
publish:
99
if: github.repository == 'eth-cscs/stackinator'
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v3
13-
- name: Setup up Python 3.6
14-
uses: actions/setup-python@v4
13+
- name: Set up Python
14+
uses: actions/setup-python@v6
1515
with:
16-
python-version: 3.6
16+
python-version: 3.12
1717
- name: Generate dist packages
1818
run: |
1919
python -m pip install --upgrade pip setuptools build
2020
python -m build
2121
- name: Publish Stackinator to PyPI
22-
uses: pypa/gh-action-pypi-publish@release/v1
23-
with:
24-
verbose: true
25-
user: __token__
26-
password: ${{ secrets.PYPI_API_TOKEN }}
22+
run: uv publish
23+
env:
24+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ log_config*
1414

1515
# generated by mkdocs
1616
site
17+
18+
# distribution/packaging files
19+
*.egg-info/
20+
build/

MANIFEST.in

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

bin/stack-config

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,4 @@
1-
#!/usr/bin/env -S uv run --script
2-
# /// script
3-
# requires-python = ">=3.12"
4-
# dependencies = [
5-
# "jinja2",
6-
# "jsonschema",
7-
# "pyYAML",
8-
# ]
9-
# ///
1+
#!/usr/bin/env bash
102

11-
import pathlib
12-
import sys
13-
14-
prefix = pathlib.Path(__file__).parent.parent.resolve()
15-
sys.path = [prefix.as_posix()] + sys.path
16-
17-
from stackinator.main import main
18-
19-
# Once we've set up the system path, run the tool's main method
20-
if __name__ == "__main__":
21-
sys.exit(main())
3+
STACKINATOR_ROOT=$(dirname `realpath $0`)/..
4+
uv run --directory $STACKINATOR_ROOT --with . python -m stackinator.main $@

pyproject.toml

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,73 @@
11
[build-system]
2-
requires = ["setuptools", "wheel"]
2+
requires = ["setuptools>=61.2"]
33
build-backend = "setuptools.build_meta"
44

5+
[project]
6+
name = "Stackinator"
7+
authors = [{name = "Swiss National Supercomputing Center (CSCS/ETH Zurich)"}]
8+
description = "Stackinator is a tool for building a scientific software stack from a recipe for vClusters on CSCS' Alps infrastructure"
9+
license = "BSD-3-Clause"
10+
license-files = ["LICENSE"]
11+
dynamic = ["version"]
12+
requires-python = ">=3.12"
13+
dependencies = [
14+
"Jinja2",
15+
"jsonschema",
16+
"PyYAML",
17+
]
18+
classifiers = [
19+
"Development Status :: 5 - Production/Stable",
20+
"Programming Language :: Python :: 3.12",
21+
"Programming Language :: Python :: 3.13",
22+
"Programming Language :: Python :: 3.14",
23+
"Operating System :: POSIX :: Linux",
24+
"Environment :: Console",
25+
]
26+
27+
[project.readme]
28+
file = "README.md"
29+
content-type = "text/markdown"
30+
31+
[project.urls]
32+
homepage = "https://github.com/eth-cscs/stackinator"
33+
documentation = "https://eth-cscs.github.io/stackinator/"
34+
35+
[project.scripts]
36+
stack-config = "stackinator.main:main"
37+
38+
[dependency-groups]
39+
dev = [
40+
"pytest",
41+
]
42+
docs = [
43+
"mkdocs",
44+
"mkdocs-material",
45+
"mkdocs-autorefs",
46+
]
47+
48+
[tool.setuptools]
49+
packages = ["stackinator"]
50+
include-package-data = false
51+
52+
[tool.setuptools.package-data]
53+
stackinator = ["schema/*.json", "templates/*", "etc/*"]
54+
55+
[tool.setuptools.exclude-package-data]
56+
"*" = ["__pycache__/*", "*.pyc"]
57+
58+
[tool.setuptools.dynamic]
59+
version = {attr = "stackinator.VERSION"}
60+
561
[tool.ruff]
662
line-length = 120
7-
extend-exclude = ["external/", "unittests/recipes"]
8-
exclude = ["unittests/recipes/with-repo/repo/packages"]
63+
extend-exclude = [
64+
"unittests/recipes/**/scripts/**/*.py",
65+
"unittests/recipes/**/repo/packages/*/*.py",
66+
]
967

1068
[tool.ruff.lint]
1169
select = ["E", "F"]
1270
ignore = ["E203"]
71+
72+
[tool.pytest.ini_options]
73+
testpaths = ["unittests"]

requirements-docs.txt

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

requirements.txt

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

0 commit comments

Comments
 (0)