Skip to content

Commit

Permalink
Refactor setup to use uv.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephrdev committed Jan 15, 2025
1 parent 6106689 commit 7e34adb
Show file tree
Hide file tree
Showing 14 changed files with 616 additions and 1,199 deletions.
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ indent_size = 4
multi_line_output = 3
lines_after_imports = 2
include_trailing_comma = True
ensure_newline_before_comments = True
force_grid_wrap = 0
use_parentheses = True
line_length = 96
Expand All @@ -22,6 +21,10 @@ line_length = 96
indent_style = space
indent_size = 4

[*.toml]
indent_style = space
indent_size = 4

[*.yml]
indent_style = space
indent_size = 2
12 changes: 4 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ jobs:
name: "Upload to PyPI"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: "3.x"
- name: "Install dependencies"
run: "python -m pip install --upgrade poetry"
- uses: "actions/checkout@v4"
- uses: "astral-sh/setup-uv@v5"
- name: "Build and publish"
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: "poetry publish --build --username=__token__ --password=$PYPI_TOKEN"
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: "uv publish"
22 changes: 9 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,27 @@ on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
workflow_dispatch:

jobs:
test:
name: "Python ${{ matrix.python-version }}"
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: "${{ matrix.python-version }}"
- name: "Install dependencies"
run: |
set -xe
python -m pip install --upgrade pip setuptools
python -m pip install --upgrade poetry tox tox-gh-actions coverage
- uses: "actions/checkout@v4"
- uses: "astral-sh/setup-uv@v5"

- name: "Install tox"
run: "uv tool install tox --with tox-uv,tox-gh-actions,coverage"

- name: "Run tox targets for ${{ matrix.python-version }}"
run: "python -m tox"
run: "python -m tox run"

- name: "Upload coverage to Codecov"
uses: "codecov/codecov-action@v2"
uses: "codecov/codecov-action@v4"
with:
fail_ci_if_error: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ __pycache__/

.cache
.coverage
coverage.xml
.pytest_cache
*.sqlite3
3 changes: 0 additions & 3 deletions .python-version

This file was deleted.

24 changes: 17 additions & 7 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
build:
image: latest
version: 2

python:
version: 3.8
pip_install: true
extra_requirements:
- docs
build:
os: latest
tools:
python: "3.13"
jobs:
create_environment:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
- uv venv
install:
- uv sync --locked --no-dev
- uv pip install Sphinx
build:
html:
- uv run sphinx-build -T -b html docs $READTHEDOCS_OUTPUT/html
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
=========

2.0.0 - 2025-01-15
------------------

* Add ``defer_init_tapeforms`` to control the tapeforms initialization time
* Move code of tapeforms initialization to a separate method for better customization
* Remove `BootstrapTapeformMixin` class alias


1.2.0 - 2023-02-25
------------------

Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
recursive-include tapeforms/templates *
prune tapeforms/tests
19 changes: 9 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@

clean:
rm -fr build/ dist/ htmlcov/ __pycache__
poetry run make -C docs clean
uv run make -C docs clean

correct:
poetry run isort tapeforms tests
poetry run black -q tapeforms tests
uv run ruff check --fix --select I
uv run ruff format

docs:
poetry run make -C docs html
uv run make -C docs html

pytests:
@PYTHONPATH=$(CURDIR):${PYTHONPATH} poetry run pytest
uv run pytest $(ARGS)

tests:
@PYTHONPATH=$(CURDIR):${PYTHONPATH} poetry run pytest --cov --isort --flake8 --black
tests: lint pytests

coverage-html: pytests
poetry run coverage html
coverage-html:
uv run pytest --cov --cov-report=html ${ARGS}

release:
@VERSION=`poetry version -s`
@VERSION=`grep -E "^version =" pyproject.toml | cut -d\" -f2`
@echo About to release $${VERSION}
@echo [ENTER] to continue; read
git tag -a "$${VERSION}" -m "Version $${VERSION}" && git push --follow-tags
13 changes: 7 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,23 @@ and some Django template tags to help you render your forms to HTML.
Requirements
------------

django-tapeforms supports Python 3 only and requires at least Django 2.2.
django-tapeforms supports Python 3 only and requires at least Django 4.2.
No other dependencies are required.


Prepare for development
-----------------------

A Python 3.6 interpreter is required in addition to pipenv.
The project uses `uv` to manage dependencies and the python environment.

.. code-block:: shell
To run the tests, use:

$ poetry install
.. code-block:: shell
$ make tests
Now you're ready to start the example project to experiment with tapeforms.
To start the example project to experiment with tapeforms, run:

.. code-block:: shell
$ poetry run python examples/manage.py runserver
$ uv run python examples/manage.py runserver
Loading

0 comments on commit 7e34adb

Please sign in to comment.