Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/actions/test/Dockerfile

This file was deleted.

21 changes: 0 additions & 21 deletions .github/main.workflow

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish

on:
release:
types: [published]

jobs:
build-and-publish:
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/modello
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Build package
run: |
python -m pip install --upgrade pip build
python -m build
# the publishing uses PyPI's trusted publishing, so configured on pypi instead of using secrets
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
branches: [master]
pull_request:

jobs:
test:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ["3.7", "3.13", "3.14-dev"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --editable .[test]
- name: Run tests
run: |
pytest
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}
path: .coverage
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ pipenv install git+https://github.com/Code0x58/modello.git#egg=modello
pip install --user git+https://github.com/Code0x58/modello.git#egg=modello
```

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/).
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/).


## Development
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`.
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`.

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.:
If you want to run a subset of tests or otherwise pass arguments to pytest, just invoke `pytest` directly, e.g.:
```sh
./pytest examples/jobs.py::jobs.Job
pytest examples/jobs.py::jobs.Job
```

## TODO:
Expand Down
3 changes: 2 additions & 1 deletion modello.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ModelloMetaNamespace(dict):

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

Expand Down
79 changes: 78 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,80 @@
[build-system]
requires = ["setuptools>=61", "setuptools_scm[toml]>=7"]
build-backend = "setuptools.build_meta"

[project]
name = "modello"
description = "sympy expressions in models"
readme = "README.md"
requires-python = ">=3.7"
license = {text = "MIT"}
authors = [{name = "Oliver Bristow", email = "github+pypi@oliverbristow.co.uk"}]
dependencies = ["sympy"]
keywords = ["symbolic modeling"]
urls = {homepage = "https://github.com/Code0x58/modello/"}
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dynamic = ["version"]

[project.optional-dependencies]
test = [
"flake8-black",
"flake8-docstrings",
"flake8-isort",
"pytest-cov>=2.6.1",
"pytest-ruff",
"pytest-mypy",
"pytest>=4.1",
]

[tool.setuptools]
py-modules = ["modello"]

[tool.setuptools_scm]

[tool.pytest.ini_options]
addopts = "--doctest-modules --doctest-report=udiff --cov=modello --cov-report=html --cov-report=term --mypy --ruff"
python_files = ["test_modello.py", "examples/*.py"]
cache_dir = "artefacts/reports/.pytest_cache"

[tool.coverage.run]
data_file = "artefacts/reports/.coverage"
source = ["modello.py"]
branch = true

[tool.coverage.html]
directory = "artefacts/reports/coverage-html"

[tool.mypy]
ignore_missing_imports = true
cache_dir = "artefacts/reports/.mypy_cache"

[tool.mypy-modello]
disallow_untyped_defs = true
disallow_incomplete_defs = true
disallow_untyped_decorators = true

[tool.isort]
line_length = 120
force_grid_wrap = 0
use_parentheses = true
include_trailing_comma = true
combine_as_imports = true
multi_line_output = 5

[tool.ruff]
line-length = 120
target-version = "py311"
target-version = "py311"
44 changes: 0 additions & 44 deletions setup.cfg

This file was deleted.

10 changes: 8 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"pytest-cov>=2.6.1",
"pytest-ruff",
"pytest-mypy",
"pytest-pudb",
"pytest>=4.1",
]
setup(
Expand All @@ -33,7 +32,7 @@
tests_require=TEST_REQUIRES,
extras_require={"test": TEST_REQUIRES},
py_modules=["modello"],
python_requires=">=3.3",
python_requires=">=3.7",
license="MIT",
classifiers=dedent(
"""
Expand All @@ -43,6 +42,13 @@
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
"""
)
.strip()
Expand Down
Loading