Skip to content

Commit d70e8d2

Browse files
authored
Update GitHub Actions and Python support (#18)
1 parent 1ec4ec0 commit d70e8d2

File tree

9 files changed

+151
-77
lines changed

9 files changed

+151
-77
lines changed

.github/actions/test/Dockerfile

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

.github/main.workflow

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

.github/workflows/publish.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build-and-publish:
9+
runs-on: ubuntu-latest
10+
environment:
11+
name: pypi
12+
url: https://pypi.org/p/modello
13+
permissions:
14+
id-token: write
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.x'
21+
- name: Build package
22+
run: |
23+
python -m pip install --upgrade pip build
24+
python -m build
25+
# the publishing uses PyPI's trusted publishing, so configured on pypi instead of using secrets
26+
- name: Publish to PyPI
27+
uses: pypa/gh-action-pypi-publish@release/v1
28+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')

.github/workflows/test.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-22.04
11+
strategy:
12+
matrix:
13+
python-version: ["3.7", "3.13", "3.14-dev"]
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
python -m pip install --editable .[test]
24+
- name: Run tests
25+
run: |
26+
pytest
27+
- name: Upload coverage
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: coverage-${{ matrix.python-version }}
31+
path: .coverage

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ pipenv install git+https://github.com/Code0x58/modello.git#egg=modello
4040
pip install --user git+https://github.com/Code0x58/modello.git#egg=modello
4141
```
4242

43-
Currently this requires Python 3.6+ but the version requirements can drop a couple of minor versions easily if there is interest. Python 2.7 isn't planned to be supported as the Modello class relies on [PEP-3115](https://www.python.org/dev/peps/pep-3115/).
43+
Currently this requires Python 3.8+ but the version requirements can drop a couple of minor versions easily if there is interest. Python 2.7 isn't planned to be supported as the Modello class relies on [PEP-3115](https://www.python.org/dev/peps/pep-3115/).
4444

4545

4646
## Development
47-
Run the tests and linting with `python setup.py test`. Pushes have the test suite run against them, and will also publish a release if tagged thanks to GitHub Actions. You can reproduce the Actions locally using [act](https://github.com/nektos/act), e.g. `TWINE_USERNAME= TWINE_PASSWORD= act`.
47+
Run the tests and linting with `pytest`. Pushes have the test suite run against them, and will also publish a release if tagged thanks to GitHub Actions. You can reproduce the Actions locally using [act](https://github.com/nektos/act), e.g. `TWINE_USERNAME= TWINE_PASSWORD= act`.
4848

49-
You can run all the tests with `python setup.py test`. If you want to run a subset of tests or otherwise pass arguments to pytest, use `./pytest` e.g.:
49+
If you want to run a subset of tests or otherwise pass arguments to pytest, just invoke `pytest` directly, e.g.:
5050
```sh
51-
./pytest examples/jobs.py::jobs.Job
51+
pytest examples/jobs.py::jobs.Job
5252
```
5353

5454
## TODO:

modello.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class ModelloMetaNamespace(dict):
3333

3434
def __init__(self, name: str, bases: typing.Tuple[type, ...]) -> None:
3535
"""Create a namespace for a Modello class to use."""
36+
super().__init__()
3637
self.name = name
3738
# map of attributes to sympy Basic (e.g expression, value) objects
3839
self.attrs: typing.Dict[str, Basic] = {}
@@ -96,7 +97,7 @@ class ModelloMeta(type):
9697
@classmethod
9798
def __prepare__(
9899
metacls, __name: str, __bases: typing.Tuple[type, ...], **kwds: typing.Any
99-
) -> typing.Mapping[str, typing.Any]:
100+
) -> typing.MutableMapping[str, typing.Any]:
100101
"""Return a ModelloMetaNamespace instead of a plain dict to accumlate attributes on."""
101102
return ModelloMetaNamespace(__name, __bases)
102103

pyproject.toml

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,80 @@
1+
[build-system]
2+
requires = ["setuptools>=61", "setuptools_scm[toml]>=7"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "modello"
7+
description = "sympy expressions in models"
8+
readme = "README.md"
9+
requires-python = ">=3.7"
10+
license = {text = "MIT"}
11+
authors = [{name = "Oliver Bristow", email = "[email protected]"}]
12+
dependencies = ["sympy"]
13+
keywords = ["symbolic modeling"]
14+
urls = {homepage = "https://github.com/Code0x58/modello/"}
15+
classifiers = [
16+
"Development Status :: 4 - Beta",
17+
"Intended Audience :: Developers",
18+
"Intended Audience :: Science/Research",
19+
"License :: OSI Approved :: MIT License",
20+
"Operating System :: OS Independent",
21+
"Programming Language :: Python :: 3",
22+
"Programming Language :: Python :: 3 :: Only",
23+
"Programming Language :: Python :: 3.7",
24+
"Programming Language :: Python :: 3.8",
25+
"Programming Language :: Python :: 3.9",
26+
"Programming Language :: Python :: 3.10",
27+
"Programming Language :: Python :: 3.11",
28+
"Programming Language :: Python :: 3.12",
29+
]
30+
dynamic = ["version"]
31+
32+
[project.optional-dependencies]
33+
test = [
34+
"flake8-black",
35+
"flake8-docstrings",
36+
"flake8-isort",
37+
"pytest-cov>=2.6.1",
38+
"pytest-ruff",
39+
"pytest-mypy",
40+
"pytest>=4.1",
41+
]
42+
43+
[tool.setuptools]
44+
py-modules = ["modello"]
45+
46+
[tool.setuptools_scm]
47+
48+
[tool.pytest.ini_options]
49+
addopts = "--doctest-modules --doctest-report=udiff --cov=modello --cov-report=html --cov-report=term --mypy --ruff"
50+
python_files = ["test_modello.py", "examples/*.py"]
51+
cache_dir = "artefacts/reports/.pytest_cache"
52+
53+
[tool.coverage.run]
54+
data_file = "artefacts/reports/.coverage"
55+
source = ["modello.py"]
56+
branch = true
57+
58+
[tool.coverage.html]
59+
directory = "artefacts/reports/coverage-html"
60+
61+
[tool.mypy]
62+
ignore_missing_imports = true
63+
cache_dir = "artefacts/reports/.mypy_cache"
64+
65+
[tool.mypy-modello]
66+
disallow_untyped_defs = true
67+
disallow_incomplete_defs = true
68+
disallow_untyped_decorators = true
69+
70+
[tool.isort]
71+
line_length = 120
72+
force_grid_wrap = 0
73+
use_parentheses = true
74+
include_trailing_comma = true
75+
combine_as_imports = true
76+
multi_line_output = 5
77+
178
[tool.ruff]
279
line-length = 120
3-
target-version = "py311"
80+
target-version = "py311"

setup.cfg

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

setup.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"pytest-cov>=2.6.1",
1818
"pytest-ruff",
1919
"pytest-mypy",
20-
"pytest-pudb",
2120
"pytest>=4.1",
2221
]
2322
setup(
@@ -33,7 +32,7 @@
3332
tests_require=TEST_REQUIRES,
3433
extras_require={"test": TEST_REQUIRES},
3534
py_modules=["modello"],
36-
python_requires=">=3.3",
35+
python_requires=">=3.7",
3736
license="MIT",
3837
classifiers=dedent(
3938
"""
@@ -43,6 +42,13 @@
4342
License :: OSI Approved :: MIT License
4443
Operating System :: OS Independent
4544
Programming Language :: Python :: 3
45+
Programming Language :: Python :: 3 :: Only
46+
Programming Language :: Python :: 3.7
47+
Programming Language :: Python :: 3.8
48+
Programming Language :: Python :: 3.9
49+
Programming Language :: Python :: 3.10
50+
Programming Language :: Python :: 3.11
51+
Programming Language :: Python :: 3.12
4652
"""
4753
)
4854
.strip()

0 commit comments

Comments
 (0)