Skip to content

Commit

Permalink
Switch to just and uv
Browse files Browse the repository at this point in the history
  • Loading branch information
dyve committed Dec 10, 2024
1 parent 318c9f1 commit 86a5eb4
Show file tree
Hide file tree
Showing 5 changed files with 1,579 additions and 2 deletions.
Empty file added .env
Empty file.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
layout uv
96 changes: 96 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
set export := true
set dotenv-load := true

EXAMPLE_DIRNAME := "example"
VENV_DIRNAME := ".venv"
VERSION := `sed -n 's/^ *version.*=.*"\([^"]*\)".*/\1/p' pyproject.toml`

# default recipe
default:
just --list

[private]
@uv:
if ! command -v uv >/dev/null; then \
echo "Error: 'uv' command is not available"; \
exit 1; \
fi

# Set up development environment
@bootstrap: uv
if test ! -e {{ VENV_DIRNAME }}; then \
uv python install; \
fi
just update

# Install and/or update all dependencies defined in pyproject.toml
@update: uv
uv sync --all-extras --all-groups --upgrade

# Format
@format: bootstrap
ruff format
ruff check --fix

# Lint
@lint: bootstrap
ruff format --check
ruff check

# Test
@test: bootstrap
coverage run manage.py test
coverage report

# Test
@tests: bootstrap
tox

# Build
@build: bootstrap
uv build
uvx twine check dist/*
uvx check-manifest
uvx pyroma .
uvx check-wheel-contents dist

# Clean
@clean:
rm -rf build dist src/*.egg-info .coverage*

# Check if the current Git branch is 'main'
@branch:
if [ "`git rev-parse --abbrev-ref HEAD`" = "main" ]; then \
echo "On branch main."; \
else \
echo "Error - Not on branch main."; \
exit 1; \
fi

# Check if the working directory is clean
@porcelain:
if [ -z "`git status --porcelain`" ]; then \
echo "Working directory is clean."; \
else \
echo "Error - working directory is dirty. Commit your changes."; \
exit 1; \
fi

@docs: bootstrap clean
uv run -m sphinx -T -b html -d docs/_build/doctrees -D language=en docs docs/_build/html

@example:
if test -e {{ EXAMPLE_DIRNAME }}; then \
cd "{{ EXAMPLE_DIRNAME }}" && python manage.py runserver; \
else \
echo "Example not found."; \
fi

@publish: porcelain branch docs build
uvx uv-publish
git tag -a v${VERSION} -m "Release {{ VERSION }}"
git push origin --tags

# Version number
@version:
echo "{{ VERSION }}"
20 changes: 18 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=64"]
build-backend = "hatchling.build"
requires = ["hatchling"]

[project]
authors = [
Expand Down Expand Up @@ -87,3 +87,19 @@ package = ["src/django_bootstrap5", "*/django_bootstrap5/src/django_bootstrap5"]
[tool.coverage.report]
show_missing = true
skip_covered = true

[dependency-groups]
dev = [
"check-manifest>=0.50",
"check-wheel-contents>=0.6.0",
"coverage[toml]>=7.6.1",
"pyroma>=4.2",
"ruff>=0.7.1",
"tox-uv>=1.13.1",
"twine>=5.1.1",
]
docs = [
"furo>=2024.8.6",
"myst-parser>=3.0.1",
"sphinx>=7.1.2",
]
Loading

0 comments on commit 86a5eb4

Please sign in to comment.