Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to uv for building and packaging #212

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 3 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ jobs:

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U setuptools twine wheel
curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Build package
run: |
python setup.py --version
python setup.py sdist --format=gztar bdist_wheel
twine check dist/*
uv build
uvx twine check dist/*

- name: Upload packages to Jazzband
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
Expand Down
73 changes: 64 additions & 9 deletions .github/workflows/test_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,89 @@ on:
- master
pull_request:
jobs:
tox:
pytest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
django-version:
- "4.2"
- "5.0"
- "5.1"
exclude:
- django-version: 4.2
python-version: 3.12
- django-version: 4.2
python-version: 3.13
- django-version: 5.0
python-version: 3.9
- django-version: 5.1
python-version: 3.9
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
cache-suffix: ${{ matrix.python-version }}
- name: Install Python
run: uv python install ${{ matrix.python-version }}
env:
UV_PYTHON_PREFERENCE: only-managed
- run: uv sync --all-groups
- run: uv run --with 'django~=${{ matrix.django-version }}.0' pytest --cov --cov-report=
env:
DJANGO_SETTINGS_MODULE: tests.settings
PYTHONPATH: "."
- name: Rename coverage file
run: mv .coverage .coverage.py${{ matrix.python-version }}.dj${{ matrix.django-version }}
- name: Save coverage file
uses: actions/upload-artifact@v4
with:
python-version: ${{ matrix.python-version }}
name: .coverage.py${{ matrix.python-version }}.dj${{ matrix.django-version }}
path: .coverage.py${{ matrix.python-version }}.dj${{ matrix.django-version }}
include-hidden-files: true

- run: pip install tox tox-gh-actions codecov
codecov:
needs: pytest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- run: uv python install 3.13
- uses: actions/download-artifact@v4
with:
pattern: .coverage.*
merge-multiple: true
- name: Combine coverage
run: |
uv run coverage combine
uv run coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5

- run: tox
lint: # redundant with pre-commit-ci, but we want to make the linters a part of strict status checks.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- run: uv python install 3.13
- run: uv sync --group dev
- run: uvx ruff check
- run: uvx ruff format --check

- run: codecov
check:
runs-on: ubuntu-latest
if: always()
needs:
- tox
- pytest
- lint
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ build/
dist/
*.egg-info
docs/_build

uv.lock

.envrc
16 changes: 2 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,7 @@ repos:
- id: markdownlint
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.8.6'
rev: "v0.8.6"
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
args:
- "--line-length"
- "119"
exclude: ^django_fsm_log/migrations|^docs/
- repo: https://github.com/adamchainz/django-upgrade
rev: "1.22.2"
hooks:
- id: django-upgrade
args: [--target-version, "3.2"]
- id: ruff-format
19 changes: 10 additions & 9 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
version: 2

build:
os: ubuntu-20.04
os: ubuntu-22.04
tools:
python: "3.9"
python: "3.11"

commands:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
- mkdir -p $READTHEDOCS_OUTPUT/html/
- uv sync --group docs
- uv run -m sphinx -T -b html -d docs/_build/doctrees -D language=en docs $READTHEDOCS_OUTPUT/html

sphinx:
configuration: docs/conf.py

python:
install:
- method: pip
path: .
extra_requirements:
- docs
4 changes: 2 additions & 2 deletions django_fsm_log/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ class StateLog(models.Model):
null=True,
on_delete=models.SET_NULL,
)
source_state = models.CharField(max_length=255, db_index=True, null=True, blank=True, default=None)
source_state = models.CharField(max_length=255, db_index=True, null=True, blank=True, default=None) # noqa:DJ001
state = models.CharField("Target state", max_length=255, db_index=True)
transition = models.CharField(max_length=255)

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

description = models.TextField(blank=True, null=True)
description = models.TextField(blank=True, null=True) # noqa:DJ001

objects = StateLogManager()

Expand Down
78 changes: 71 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,74 @@
[tool.black]
line-length = 119
target-version = ["py37"]
extend-exclude = "(^/django_fsm_log/migrations/.*$|^docs/.*$)"
[project]
license = { file = "LICENSE" }
description = "Transition's persistence for django-fsm"
name = "django-fsm-log"
dynamic = ["version"]
readme = "README.md"
requires-python = ">=3.9"
authors = [
{ name = "Gizmag", email = "[email protected]" },
{ name = "Various Contributors" },
]
keywords = ["django", "django-fsm-2"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: Django :: 5.1",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = ["django>=4.2", "django-fsm-2", "django_appconf"]

[dependency-groups]
dev = [
"pytest",
"pytest-cov",
"pytest-django",
"pytest-mock",
"tox",
"tox-uv>=1.17.0",
"twine",
]
ci = ["codecov>=2.1.13"]
docs = ["sphinx", "sphinx_rtd_theme", "myst-parser"]

[project.urls]
Documentation = "https://django-fsm-log.readthedocs.io/en/latest/"
Homepage = "https://github.com/jazzband/django-fsm-log"

[build-system]
requires = ["setuptools>=64", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
include-package-data = true

[tool.setuptools_scm]

[tool.ruff]
line-length = 119
target-version = "py37"
select = ["E", "F", "I", "B", "C4", "T20", "TID", "UP"]
exclude = ["django_fsm_log/migrations", ".tox", "build"]
target-version = "py39"
extend-exclude = ["django_fsm_log/migrations/", ".tox/", "build/", "docs/"]

[tool.ruff.lint]
select = ["E", "F", "I", "B", "C4", "T20", "TID", "UP", "DJ"]

[tool.pytest.ini_options]
markers = [
"ignore_article: Configure the settings DJANGO_FSM_LOG_IGNORED_MODELS to ignore Article Model.",
"pending_objects: Install PendingStateLogManager on StateLog",
]
testpaths = ["tests"]
pythonpath = ["."]
DJANGO_SETTINGS_MODULE = "tests.settings"
8 changes: 0 additions & 8 deletions setup.cfg

This file was deleted.

53 changes: 0 additions & 53 deletions setup.py

This file was deleted.

11 changes: 6 additions & 5 deletions tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ class Article(models.Model):

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

def __str__(self):
return f"pk={self.pk}"

@fsm_log_by
@fsm_log_description
@transition(field=state, source="draft", target="submitted")
def submit(self, description=None, by=None):
pass

@fsm_log_by
@transition(field=state, source="submitted", target="draft")
def request_changes(self, by=None):
pass

@fsm_log_by
@transition(field=state, source="submitted", target="published")
def publish(self, by=None):
Expand Down Expand Up @@ -72,6 +70,9 @@ class ArticleInteger(models.Model):

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

def __str__(self):
return f"pk={self.pk}"

@fsm_log_by
@transition(field=state, source=STATE_ONE, target=STATE_TWO)
def change_to_two(self, by=None):
Expand Down
Loading
Loading