Skip to content

Commit 474db52

Browse files
authored
Merge pull request #212 from ticosax/uv-integration
Switch to uv for building and packaging
2 parents f2f3efc + ded3923 commit 474db52

File tree

12 files changed

+182
-124
lines changed

12 files changed

+182
-124
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ jobs:
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
2625
2726
- name: Build package
2827
run: |
29-
python setup.py --version
30-
python setup.py sdist --format=gztar bdist_wheel
31-
twine check dist/*
28+
uv build
29+
uvx twine check dist/*
3230
3331
- name: Upload packages to Jazzband
3432
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')

.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: # redundant with pre-commit-ci, but we want to make the linters a part of strict status checks.
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

.pre-commit-config.yaml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,7 @@ repos:
1818
- id: markdownlint
1919
- repo: https://github.com/astral-sh/ruff-pre-commit
2020
# Ruff version.
21-
rev: 'v0.9.1'
21+
rev: "v0.10.0"
2222
hooks:
2323
- id: ruff
24-
- repo: https://github.com/psf/black
25-
rev: 24.10.0
26-
hooks:
27-
- id: black
28-
args:
29-
- "--line-length"
30-
- "119"
31-
exclude: ^django_fsm_log/migrations|^docs/
32-
- repo: https://github.com/adamchainz/django-upgrade
33-
rev: "1.22.2"
34-
hooks:
35-
- id: django-upgrade
36-
args: [--target-version, "3.2"]
24+
- id: ruff-format

.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 = "[email protected]" },
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 & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@ 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")
2124
def submit(self, description=None, by=None):
2225
pass
2326

24-
@fsm_log_by
25-
@transition(field=state, source="submitted", target="draft")
26-
def request_changes(self, by=None):
27-
pass
28-
2927
@fsm_log_by
3028
@transition(field=state, source="submitted", target="published")
3129
def publish(self, by=None):
@@ -72,6 +70,9 @@ class ArticleInteger(models.Model):
7270

7371
state = FSMIntegerField(choices=STATES, default=STATE_ONE)
7472

73+
def __str__(self):
74+
return f"pk={self.pk}"
75+
7576
@fsm_log_by
7677
@transition(field=state, source=STATE_ONE, target=STATE_TWO)
7778
def change_to_two(self, by=None):

0 commit comments

Comments
 (0)