Skip to content

Commit b5233e2

Browse files
committed
use pyproject.toml instead of setup.cfg
1 parent 7b0b90c commit b5233e2

File tree

11 files changed

+3074
-154
lines changed

11 files changed

+3074
-154
lines changed

.github/workflows/release.yml

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
tags:
66
- v*
77

8+
permissions:
9+
contents: read
10+
811
jobs:
912

1013
wait:
@@ -25,13 +28,12 @@ jobs:
2528
if: steps.wait-for-tests.outputs.conclusion != 'success'
2629

2730
build:
28-
name: Build package
2931
runs-on: ubuntu-latest
30-
needs: [wait]
3132

3233
strategy:
3334
matrix:
34-
python-version: ['3.12']
35+
python-version:
36+
- "3.12"
3537

3638
steps:
3739
- name: Checkout code
@@ -42,50 +44,39 @@ jobs:
4244
with:
4345
python-version: ${{ matrix.python-version }}
4446

45-
- name: Cache pip
46-
uses: actions/cache@v3
47-
with:
48-
path: ~/.cache/pip
49-
key: ${{ runner.os }}-python-${{ matrix.python }}-pip-${{ hashFiles('**/requirements*.txt') }}-git-${{ github.sha }}
50-
restore-keys: |
51-
${{ runner.os }}-python-${{ matrix.python }}-pip-${{ hashFiles('**/requirements*.txt') }}
52-
${{ runner.os }}-python-${{ matrix.python }}-pip-
53-
${{ runner.os }}-python
54-
${{ runner.os }}-
55-
56-
- name: Upgrade pip and install dependencies
47+
- name: Install uv
5748
run: |
58-
python -m pip install --upgrade pip
59-
python -m pip install --upgrade setuptools wheel
60-
python -m pip install -r requirements.txt
61-
python -m pip install -r requirements-dev.txt
62-
63-
- name: Build package
64-
run: python -m build
49+
pip install uv
6550
66-
- name: Check package
67-
run: twine check dist/*
68-
69-
- name: Publish package
70-
env:
71-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
72-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
51+
- name: Build release distributions
7352
run: |
74-
twine upload --skip-existing dist/*
53+
uv pip install --system build
54+
python -m build
7555
76-
release:
77-
name: Release version
56+
- name: Upload distributions
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: release-dists
60+
path: dist/
61+
62+
pypi-publish:
7863
runs-on: ubuntu-latest
7964
needs: [wait, build]
65+
permissions:
66+
id-token: write
67+
68+
environment:
69+
name: pypi
70+
url: https://pypi.org/project/otp-mcp-server/
8071

8172
steps:
82-
- name: Create release
83-
id: create_release
84-
uses: actions/create-release@v1
85-
env:
86-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
- name: Retrieve release distributions
74+
uses: actions/download-artifact@v4
75+
with:
76+
name: release-dists
77+
path: dist/
78+
79+
- name: Publish release distributions to PyPI
80+
uses: pypa/gh-action-pypi-publish@release/v1
8781
with:
88-
tag_name: ${{ github.ref }}
89-
release_name: ${{ github.ref }}
90-
draft: false
91-
prerelease: false
82+
packages-dir: dist/

.github/workflows/tests.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ jobs:
1111
strategy:
1212
matrix:
1313
python:
14-
- "3.8"
1514
- "3.9"
1615
- "3.10"
1716
- "3.11"
@@ -26,17 +25,17 @@ jobs:
2625
uses: actions/checkout@v4
2726

2827
- name: Set up Python
29-
uses: actions/setup-python@v4
28+
uses: actions/setup-python@v5
3029
with:
3130
python-version: ${{ matrix.python }}
3231

3332
- name: Cache pip
3433
uses: actions/cache@v3
3534
with:
3635
path: ~/.cache/pip
37-
key: ${{ runner.os }}-python-${{ matrix.python }}-pip-${{ hashFiles('**/requirements*.txt') }}-git-${{ github.sha }}
36+
key: ${{ runner.os }}-python-${{ matrix.python }}-pip-${{ hashFiles('**/pyproject.toml') }}-git-${{ github.sha }}
3837
restore-keys: |
39-
${{ runner.os }}-python-${{ matrix.python }}-pip-${{ hashFiles('**/requirements*.txt') }}
38+
${{ runner.os }}-python-${{ matrix.python }}-pip-${{ hashFiles('**/pyproject.toml') }}
4039
${{ runner.os }}-python-${{ matrix.python }}-pip-
4140
${{ runner.os }}-python-${{ matrix.python }}-
4241
${{ runner.os }}-python
@@ -45,9 +44,7 @@ jobs:
4544
- name: Upgrade pip and install dependencies
4645
run: |
4746
python -m pip install --upgrade pip
48-
python -m pip install --upgrade setuptools wheel
49-
python -m pip install -r requirements.txt
50-
python -m pip install pytest
47+
pip install -e .[test]
5148
5249
- name: Run tests
5350
run: pytest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ nosetests.xml
4141
pyvenv.cfg
4242
site/
4343
__pycache__
44+
.venv

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

Makefile

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
SHELL=/bin/bash -e
2+
VERSION := $(shell grep '__version__ = ' cstruct/__init__.py | sed 's/__version__ = "\(.*\)"/\1/')
23

34
help:
4-
@echo - make black ------ Format code
5-
@echo - make isort ------ Sort imports
5+
@echo - make ruff ------- Format code and sort imports
66
@echo - make clean ------ Clean virtual environment
77
@echo - make coverage --- Run tests coverage
88
@echo - make docs ------- Make docs
@@ -12,44 +12,49 @@ help:
1212
@echo - make typecheck -- Typecheck
1313
@echo - make venv ------- Create virtual environment
1414

15-
.PHONY: isort
15+
.PHONY: codespell
1616
codespell:
17-
@codespell -w cstruct tests examples setup.py
17+
uv run codespell -w cstruct tests examples
1818

19-
.PHONY: isort
20-
isort:
21-
@isort --profile black cstruct tests examples setup.py
22-
23-
.PHONY: black
24-
black: isort
25-
@black -S cstruct tests examples setup.py
19+
.PHONY: ruff
20+
ruff:
21+
uv run ruff format cstruct tests examples
2622

23+
.PHONY: clean
2724
clean:
28-
-rm -rf build dist
29-
-rm -rf *.egg-info
30-
-rm -rf bin lib lib64 share include pyvenv.cfg
25+
-rm -rf build dist pyvenv.cfg *.egg-info .venv
3126

27+
.PHONY: coverage
3228
coverage:
33-
@pytest --cov --cov-report=term-missing
29+
uv run pytest --cov --cov-report=term-missing
3430

3531
.PHONY: docs
3632
docs:
37-
@mkdocs build
38-
@mkdocs gh-deploy
33+
uv run mkdocs build
34+
uv run mkdocs gh-deploy
3935

36+
.PHONY: lint
4037
lint:
41-
flake8 cstruct tests
38+
uv run ruff check cstruct tests
4239

40+
.PHONY: test
4341
test:
44-
pytest
42+
uv run pytest
4543

44+
.PHONY: test-32bit
4645
test-32bit:
47-
@make -C docker/i386 test
46+
make -C docker/i386 test
4847

48+
.PHONY: typecheck
4949
typecheck:
50-
mypy --strict --no-warn-unused-ignores cstruct
50+
uv run mypy --strict --no-warn-unused-ignores cstruct
51+
52+
.PHONY: tag
53+
tag:
54+
git tag v${VERSION}
5155

56+
.PHONY: venv
5257
venv:
53-
python3 -m venv . || python3 -m virtualenv .
54-
. bin/activate; pip install -Ur requirements.txt
55-
. bin/activate; pip install -Ur requirements-dev.txt
58+
uv venv
59+
uv pip install -e .
60+
uv pip install -e ".[dev]"

pyproject.toml

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

5-
[tool.black]
5+
[project]
6+
name = "cstruct"
7+
dynamic = ["version"]
8+
description = "C-style structs for Python"
9+
readme = "README.md"
10+
license = "MIT"
11+
license-files = ["LICENSE"]
12+
authors = [
13+
{ name = "Andrea Bonomi", email = "andrea.bonomi@gmail.com" }
14+
]
15+
keywords = ["struct", "cstruct", "enum", "binary", "pack", "unpack"]
16+
requires-python = ">=3.7"
17+
18+
classifiers = [
19+
"Development Status :: 5 - Production/Stable",
20+
"Environment :: Console",
21+
"Intended Audience :: Developers",
22+
"Operating System :: OS Independent",
23+
"Programming Language :: Python",
24+
"Topic :: Software Development :: Libraries :: Python Modules",
25+
"Programming Language :: Python :: 3",
26+
]
27+
28+
[project.urls]
29+
Homepage = "http://github.com/andreax79/python-cstruct"
30+
Source = "http://github.com/andreax79/python-cstruct"
31+
Issues = "http://github.com/andreax79/python-cstruct/issues"
32+
Documentation = "https://python-cstruct.readthedocs.io/en/latest/"
33+
34+
[project.optional-dependencies]
35+
dev = [
36+
"pytest",
37+
"pytest-cov",
38+
"codespell",
39+
"coverage[toml]",
40+
"ruff",
41+
"markdown_include",
42+
"mkdocs",
43+
"mkdocs-material",
44+
"mkdocstrings",
45+
"mkdocstrings-python",
46+
"mypy"
47+
]
48+
test = [
49+
"pytest",
50+
"pytest-cov",
51+
"coverage[toml]"
52+
]
53+
54+
[tool.setuptools]
55+
zip-safe = true
56+
include-package-data = true
57+
58+
[tool.setuptools.dynamic]
59+
version = { attr = "cstruct.__version__" }
60+
61+
[tool.setuptools.packages.find]
62+
include = ["cstruct*"]
63+
exclude = ["ez_setup", "examples", "tests"]
64+
65+
[tool.ruff]
666
line-length = 132
767

68+
[tool.ruff.lint]
69+
ignore = [ "E731", "E711" ]
70+
871
[tool.coverage.run]
972
source = ["cstruct"]
1073

@@ -13,3 +76,6 @@ exclude_lines = [ "# pragma: no cover", "if TYPE_CHECKING:" ]
1376

1477
[tool.isort]
1578
profile = "black"
79+
80+
[tool.black]
81+
line-length = 132

requirements-dev.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
1-
black
2-
build
3-
codespell
4-
coverage[toml]
5-
flake8
6-
isort
71
markdown_include
82
mkdocs
93
mkdocs-material
104
mkdocstrings[python]
11-
mypy
12-
pytest
13-
pytest-cov
14-
setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability
15-
tox
16-
twine<3.4

requirements.txt

Whitespace-only changes.

setup.cfg

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

0 commit comments

Comments
 (0)