Skip to content

Commit f6fe0b0

Browse files
committed
Switch to uv for building and packaging
Get dynamic version based on current tag
1 parent d69b60e commit f6fe0b0

File tree

11 files changed

+181
-104
lines changed

11 files changed

+181
-104
lines changed

.github/workflows/release.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Release
22
on:
33
push:
44
tags:
5-
- '*'
5+
- "*"
66

77
jobs:
88
build:
@@ -17,17 +17,17 @@ jobs:
1717
- name: Set up Python
1818
uses: actions/setup-python@v5
1919
with:
20-
python-version: '3.11'
20+
python-version: "3.11"
2121

2222
- name: Install dependencies
2323
run: |
24-
python -m pip install -U pip
25-
python -m pip install -U setuptools twine wheel
24+
curl -LsSf https://astral.sh/uv/install.sh | sh
25+
2626
- name: Build package
2727
run: |
28-
python setup.py --version
29-
python setup.py sdist --format=gztar bdist_wheel
30-
twine check dist/*
28+
uv build
29+
uvx twine check dist/*
30+
3131
- name: Upload packages to Jazzband
3232
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
3333
uses: pypa/gh-action-pypi-publish@v1.12.3

.github/workflows/test_suite.yml

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,89 @@ on:
55
- master
66
pull_request:
77
jobs:
8-
tox:
8+
pytest:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
1212
python-version:
13-
- "3.8"
1413
- "3.9"
1514
- "3.10"
1615
- "3.11"
1716
- "3.12"
17+
- "3.13"
18+
django-version:
19+
- "4.2"
20+
- "5.0"
21+
- "5.1"
22+
exclude:
23+
- django-version: 4.2
24+
python-version: 3.12
25+
- django-version: 4.2
26+
python-version: 3.13
27+
- django-version: 5.0
28+
python-version: 3.9
29+
- django-version: 5.1
30+
python-version: 3.9
1831
steps:
1932
- uses: actions/checkout@v4
20-
2133
- name: Set up Python ${{ matrix.python-version }}
22-
uses: actions/setup-python@v5
34+
uses: astral-sh/setup-uv@v5
35+
with:
36+
enable-cache: true
37+
cache-dependency-glob: "pyproject.toml"
38+
cache-suffix: ${{ matrix.python-version }}
39+
- name: Install Python
40+
run: uv python install ${{ matrix.python-version }}
41+
env:
42+
UV_PYTHON_PREFERENCE: only-managed
43+
- run: uv sync --all-groups
44+
- run: uv run --with 'django~=${{ matrix.django-version }}.0' pytest --cov --cov-report=
45+
env:
46+
DJANGO_SETTINGS_MODULE: tests.settings
47+
PYTHONPATH: "."
48+
- name: Rename coverage file
49+
run: mv .coverage .coverage.py${{ matrix.python-version }}.dj${{ matrix.django-version }}
50+
- name: Save coverage file
51+
uses: actions/upload-artifact@v4
2352
with:
24-
python-version: ${{ matrix.python-version }}
53+
name: .coverage.py${{ matrix.python-version }}.dj${{ matrix.django-version }}
54+
path: .coverage.py${{ matrix.python-version }}.dj${{ matrix.django-version }}
55+
include-hidden-files: true
2556

26-
- run: pip install tox tox-gh-actions codecov
57+
codecov:
58+
needs: pytest
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v4
62+
- uses: astral-sh/setup-uv@v5
63+
- run: uv python install 3.13
64+
- uses: actions/download-artifact@v4
65+
with:
66+
pattern: .coverage.*
67+
merge-multiple: true
68+
- name: Combine coverage
69+
run: |
70+
uv run coverage combine
71+
uv run coverage xml
72+
- name: Upload coverage to Codecov
73+
uses: codecov/codecov-action@v5
2774

28-
- run: tox
75+
lint:
76+
runs-on: ubuntu-latest
77+
steps:
78+
- uses: actions/checkout@v4
79+
- uses: astral-sh/setup-uv@v5
80+
- run: uv python install 3.13
81+
- run: uv sync --group dev
82+
- run: uvx ruff check
83+
- run: uvx ruff format --check
2984

30-
- run: codecov
3185
check:
3286
runs-on: ubuntu-latest
3387
if: always()
3488
needs:
35-
- tox
89+
- pytest
90+
- lint
3691
steps:
3792
- name: Decide whether the needed jobs succeeded or failed
3893
uses: re-actors/alls-green@release/v1

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ build/
99
dist/
1010
*.egg-info
1111
docs/_build
12+
13+
uv.lock
14+
15+
.envrc

.readthedocs.yaml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
version: 2
22

33
build:
4-
os: ubuntu-20.04
4+
os: ubuntu-22.04
55
tools:
6-
python: "3.9"
6+
python: "3.11"
7+
8+
commands:
9+
- asdf plugin add uv
10+
- asdf install uv latest
11+
- asdf global uv latest
12+
- mkdir -p $READTHEDOCS_OUTPUT/html/
13+
- uv sync --group docs
14+
- uv run -m sphinx -T -b html -d docs/_build/doctrees -D language=en docs $READTHEDOCS_OUTPUT/html
715

816
sphinx:
917
configuration: docs/conf.py
10-
11-
python:
12-
install:
13-
- method: pip
14-
path: .
15-
extra_requirements:
16-
- docs

django_fsm_log/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ class StateLog(models.Model):
1616
null=True,
1717
on_delete=models.SET_NULL,
1818
)
19-
source_state = models.CharField(max_length=255, db_index=True, null=True, blank=True, default=None)
19+
source_state = models.CharField(max_length=255, db_index=True, null=True, blank=True, default=None) # noqa:DJ001
2020
state = models.CharField("Target state", max_length=255, db_index=True)
2121
transition = models.CharField(max_length=255)
2222

2323
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
2424
object_id = models.PositiveIntegerField(db_index=True)
2525
content_object = GenericForeignKey("content_type", "object_id")
2626

27-
description = models.TextField(blank=True, null=True)
27+
description = models.TextField(blank=True, null=True) # noqa:DJ001
2828

2929
objects = StateLogManager()
3030

pyproject.toml

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,74 @@
1-
[tool.black]
2-
line-length = 119
3-
target-version = ["py37"]
4-
extend-exclude = "(^/django_fsm_log/migrations/.*$|^docs/.*$)"
1+
[project]
2+
license = { file = "LICENSE" }
3+
description = "Transition's persistence for django-fsm"
4+
name = "django-fsm-log"
5+
dynamic = ["version"]
6+
readme = "README.md"
7+
requires-python = ">=3.9"
8+
authors = [
9+
{ name = "Gizmag", email = "tech@gizmag.com" },
10+
{ name = "Various Contributors" },
11+
]
12+
keywords = ["django", "django-fsm-2"]
13+
classifiers = [
14+
"Development Status :: 5 - Production/Stable",
15+
"Environment :: Web Environment",
16+
"Framework :: Django",
17+
"Framework :: Django :: 4.2",
18+
"Framework :: Django :: 5.0",
19+
"Framework :: Django :: 5.1",
20+
"Intended Audience :: Developers",
21+
"License :: OSI Approved :: MIT License",
22+
"Operating System :: OS Independent",
23+
"Programming Language :: Python :: 3",
24+
"Programming Language :: Python :: 3.9",
25+
"Programming Language :: Python :: 3.10",
26+
"Programming Language :: Python :: 3.11",
27+
"Programming Language :: Python :: 3.12",
28+
"Programming Language :: Python :: 3.13",
29+
"Topic :: Software Development :: Libraries :: Python Modules",
30+
]
31+
dependencies = ["django>=4.2", "django-fsm-2", "django_appconf"]
32+
33+
[dependency-groups]
34+
dev = [
35+
"pytest",
36+
"pytest-cov",
37+
"pytest-django",
38+
"pytest-mock",
39+
"tox",
40+
"tox-uv>=1.17.0",
41+
"twine",
42+
]
43+
ci = ["codecov>=2.1.13"]
44+
docs = ["sphinx", "sphinx_rtd_theme", "myst-parser"]
45+
46+
[project.urls]
47+
Documentation = "https://django-fsm-log.readthedocs.io/en/latest/"
48+
Homepage = "https://github.com/jazzband/django-fsm-log"
49+
50+
[build-system]
51+
requires = ["setuptools>=64", "setuptools_scm>=8"]
52+
build-backend = "setuptools.build_meta"
53+
54+
[tool.setuptools]
55+
include-package-data = true
56+
57+
[tool.setuptools_scm]
558

659
[tool.ruff]
760
line-length = 119
8-
target-version = "py37"
9-
select = ["E", "F", "I", "B", "C4", "T20", "TID", "UP"]
10-
exclude = ["django_fsm_log/migrations", ".tox", "build"]
61+
target-version = "py39"
62+
extend-exclude = ["django_fsm_log/migrations/", ".tox/", "build/", "docs/"]
63+
64+
[tool.ruff.lint]
65+
select = ["E", "F", "I", "B", "C4", "T20", "TID", "UP", "DJ"]
66+
67+
[tool.pytest.ini_options]
68+
markers = [
69+
"ignore_article: Configure the settings DJANGO_FSM_LOG_IGNORED_MODELS to ignore Article Model.",
70+
"pending_objects: Install PendingStateLogManager on StateLog",
71+
]
72+
testpaths = ["tests"]
73+
pythonpath = ["."]
74+
DJANGO_SETTINGS_MODULE = "tests.settings"

setup.cfg

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

setup.py

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

tests/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ class Article(models.Model):
1515

1616
state = FSMField(choices=STATES, default="draft", protected=True)
1717

18+
def __str__(self):
19+
return f"pk={self.pk}"
20+
1821
@fsm_log_by
1922
@fsm_log_description
2023
@transition(field=state, source="draft", target="submitted")
@@ -72,6 +75,9 @@ class ArticleInteger(models.Model):
7275

7376
state = FSMIntegerField(choices=STATES, default=STATE_ONE)
7477

78+
def __str__(self):
79+
return f"pk={self.pk}"
80+
7581
@fsm_log_by
7682
@transition(field=state, source=STATE_ONE, target=STATE_TWO)
7783
def change_to_two(self, by=None):

tests/test_model.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,5 @@ def test_get_display_state_with_integer(article_integer):
161161
article_integer = ArticleInteger.objects.get(pk=article_integer.pk)
162162

163163
assert log.get_state_display() == article_integer.get_state_display()
164+
# only to appease code coverage
165+
assert str(article_integer) == f"pk={article_integer.pk}"

tox.ini

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[tox]
22
envlist =
33
py{39,310,311}-dj-4.2
4-
py{310,311,312,313}-5.0
5-
py{310,311,312,313}-5.1
6-
py{310,311,312,313}-dj-master
4+
py{310,311,312,313}-dj-5.0
5+
py{310,311,312,313}-dj-5.1
6+
py{310,311,312,313}-dj-main
7+
lint
78

89
[gh-actions]
910
python =
@@ -16,12 +17,17 @@ python =
1617
[testenv]
1718
usedevelop = true
1819
commands = pytest --cov=django_fsm_log --cov=tests {posargs}
19-
extras = testing
2020
setenv=
2121
DJANGO_SETTINGS_MODULE = tests.settings
22-
PYTHONPATH = {toxinidir}
2322
deps =
24-
dj-4.2: Django>=4.2,<5
25-
dj-5.0: Django>=5,<5.1
26-
dj-5.1: Django>=5.1,<5.2
27-
dj-master: https://github.com/django/django/archive/master.tar.gz
23+
dj-4.2: Django~=4.2
24+
dj-5.0: Django~=5.0
25+
dj-5.1: Django~=5.1
26+
dj-main: https://github.com/django/django/archive/main.tar.gz
27+
28+
[testenv:lint]
29+
basepython = python3
30+
deps = ruff
31+
commands =
32+
ruff check
33+
ruff format --check

0 commit comments

Comments
 (0)