|
| 1 | +.PHONY: clean deepclean install dev version pre-commit lint black mypy ruff toml-sort tests freeze build upload docs docs-autobuild |
| 2 | + |
| 3 | +# Construct pipenv run command with or without site-packages flag when not in CI environment and pipenv command exists. |
| 4 | +SITE_PACKAGES_FLAG = $(shell [ "${SS_SITE_PACKAGES}" = "true" ] && echo --site-packages) |
| 5 | +PIPRUN := $(shell [ "${CI}" != "true" ] && command -v pipenv > /dev/null 2>&1 && echo pipenv ${SITE_PACKAGES_FLAG} run) |
| 6 | + |
| 7 | +# Remove common intermediate files. |
| 8 | +clean: |
| 9 | + -rm -rf \ |
| 10 | +{%- if project_name == "Serious Scaffold Python" %} |
| 11 | + .copier-answers.yml \ |
| 12 | +{%- endif %} |
| 13 | + .coverage \ |
| 14 | + .mypy_cache \ |
| 15 | + .pytest_cache \ |
| 16 | + .ruff_cache \ |
| 17 | + Pipfile* \ |
| 18 | + coverage.xml \ |
| 19 | + dist \ |
| 20 | + docs/_build |
| 21 | + find . -name '*.egg-info' -print0 | xargs -0 rm -rf |
| 22 | + find . -name '*.pyc' -print0 | xargs -0 rm -f |
| 23 | + find . -name '*.swp' -print0 | xargs -0 rm -f |
| 24 | + find . -name '.DS_Store' -print0 | xargs -0 rm -r |
| 25 | + find . -name '__pycache__' -print0 | xargs -0 rm -rf |
| 26 | + |
| 27 | +deepclean: clean |
| 28 | + -pre-commit uninstall --hook-type pre-push |
| 29 | + -pipenv --venv >/dev/null 2>&1 && pipenv --rm |
| 30 | + |
| 31 | +install: |
| 32 | + ${PIPRUN} pip install -e . -c constraints/$(or $(SS_CONSTRAINTS_VERSION),default).txt |
| 33 | + |
| 34 | +dev-%: |
| 35 | + ${PIPRUN} pip install -e .[$*] -c constraints/$(or $(SS_CONSTRAINTS_VERSION),default).txt |
| 36 | + |
| 37 | +dev: |
| 38 | + ${PIPRUN} pip install -e .[docs,lint,package,tests] -c constraints/$(or $(SS_CONSTRAINTS_VERSION),default).txt |
| 39 | + -[ "${CI}" != "true" ] && pre-commit install --hook-type pre-push |
| 40 | + |
| 41 | +version: |
| 42 | + ${PIPRUN} python -m setuptools_scm |
| 43 | + |
| 44 | +pre-commit: |
| 45 | + pre-commit run --all-files |
| 46 | + |
| 47 | +black: |
| 48 | + ${PIPRUN} python -m black docs tests src |
| 49 | + |
| 50 | +lint: isort mypy ruff toml-sort |
| 51 | + |
| 52 | +isort: |
| 53 | + ${PIPRUN} python -m isort . |
| 54 | + |
| 55 | +mypy: |
| 56 | + ${PIPRUN} python -m mypy docs tests src |
| 57 | + |
| 58 | +ruff: |
| 59 | + ${PIPRUN} python -m ruff docs tests src |
| 60 | + |
| 61 | +toml-sort: |
| 62 | + ${PIPRUN} toml-sort -a -i pyproject.toml |
| 63 | + |
| 64 | +tests: |
| 65 | + ${PIPRUN} python -m pytest . |
| 66 | + |
| 67 | +freeze: |
| 68 | + @${PIPRUN} pip freeze --exclude-editable |
| 69 | + |
| 70 | +build: |
| 71 | + ${PIPRUN} python -m build |
| 72 | + |
| 73 | +upload: |
| 74 | + ${PIPRUN} python -m twine upload dist/* |
| 75 | + |
| 76 | +docs: |
| 77 | + ${PIPRUN} python -m sphinx.cmd.build docs docs/_build |
| 78 | + |
| 79 | +docs-autobuild: |
| 80 | + ${PIPRUN} python -m sphinx_autobuild docs docs/_build |
0 commit comments