From 285501c94846e7a5a08a3df2152fe86b87c1bdc7 Mon Sep 17 00:00:00 2001 From: powderflask Date: Thu, 5 Oct 2023 12:20:27 -0700 Subject: [PATCH] package consistency --- README.md | 41 ++++++++++++++++++++----------- pyproject.toml | 6 ++--- tasks/deps.py | 66 +++++++++++++++++++++++++++++--------------------- tasks/pypi.py | 5 ++-- tox.ini | 6 ++--- 5 files changed, 74 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index a4f8d92..92831f3 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ rendered as form fields ### Acknowledgments Special thanks to BC Hydro, [Chartwell](https://crgl.ca/), -and all [Contributors](https://github.com/powderflask/django_document_catalogue/graphs/contributors) +and all [Contributors](https://github.com/powderflask/django-fmft/graphs/contributors) #### Technology Colophon @@ -125,30 +125,43 @@ This package just glues together the amazing functionality provided by Python3, Django, HTML5, CSS3, JavaScript ## For Developers - * `> pip install -r reqirements_dev.txt` + ```bash + $ pip install -r reqirements_dev.txt + ``` ### Tests - * `> pytest` - * `> tox` - -### Code Style - * `> isort` - * `> black` - * `> flake8` + ```bash + $ pytest + ``` +or + ```bash + $ tox + ``` + +### Code Style / Linting + ```bash + $ isort + $ black + $ flake8 + ``` ### Versioning * [Semantic Versioning](https://semver.org/) - * `> bumpver` + ```bash + $ bumpver show + ``` ### Docs * [Sphinx](https://www.sphinx-doc.org/en/master/) + [MyST parser](https://myst-parser.readthedocs.io/en/latest/intro.html) - * [Read The Docs](https://readthedocs.org/projects/django-document-catalogue/) + * [Read The Docs](https://readthedocs.org/projects/django-fmft/) ### Build / Deploy Automation * [invoke](https://www.pyinvoke.org/) - * `> invoke -l` - * [GitHub Actions](https://docs.github.com/en/actions) (see [.github/workflows](https://github.com/powderflask/django_document_catalogue/tree/master/.github/workflows)) - * [GitHub Webhooks](https://docs.github.com/en/webhooks) (see [settings/hooks](https://github.com/powderflask/django_document_catalogue/settings/hooks)) + ```bash + $ invoke -l + ``` + * [GitHub Actions](https://docs.github.com/en/actions) (see [.github/workflows](https://github.com/powderflask/django-fmft/tree/master/.github/workflows)) + * [GitHub Webhooks](https://docs.github.com/en/webhooks) (see [settings/hooks](https://github.com/powderflask/django-fmft/settings/hooks)) ### TODO My wish list... diff --git a/pyproject.toml b/pyproject.toml index f122821..61122dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Intended Audience :: Developers", "Natural Language :: English", - "Programming Language :: Python", + "Programming Language :: Python :: 3", "Framework :: Django", ] dependencies = [ @@ -65,8 +65,8 @@ utils = [ ] [project.urls] -Homepage = "https://github.com/powderflask/django_fmft" -Repository = "https://github.com/powderflask/django_fmft" +Homepage = "https://github.com/powderflask/django-fmft" +Repository = "https://github.com/powderflask/django-fmft" [project.scripts] "manage.py" = "django_fmft:django_manage" diff --git a/tasks/deps.py b/tasks/deps.py index e1f37ab..c8bd909 100644 --- a/tasks/deps.py +++ b/tasks/deps.py @@ -2,44 +2,54 @@ @task -def pin(c, optional=False, docs=False): - """Pin all core [and optional] dependencies from pyproject.toml""" +def compile(c, upgrade=False, extras=(), output_file="requirements.txt", options=''): + """ Run pip-compile with given CLI options """ + extras = ' '.join(f"--extra={e}" for e in extras) + upgrade = '--upgrade' if upgrade else '' + c.run(f"pip-compile --resolver=backtracking {upgrade} { extras } {options} -o { output_file } pyproject.toml") + + +@task +def compile_dev(c, upgrade=False, extras=(), output_file="requirements_dev.txt", options=''): + """ pip-compile Dev requirements """ + compile(c, upgrade=upgrade, extras=extras, output_file=output_file, options='--all-extras '+options) + + +@task +def compile_docs(c, upgrade=False, extras=("docs", "fsm"), output_file="docs/requirements_docs.txt", options=''): + """ pip-compile Docs requirements""" + compile(c, upgrade=upgrade, extras=extras, output_file=output_file, options=options) + + +@task +def pin(c, dev=False, docs=False): + """ Pin all core [and development] dependencies from pyproject.toml """ print("Generating requirements files...") - c.run("pip-compile --resolver=backtracking -o requirements.txt pyproject.toml") - if optional: - c.run( - "pip-compile --resolver=backtracking --all-extras -o requirements_dev.txt pyproject.toml" - ) + compile(c) + if dev: + compile_dev(c) if docs: - c.run( - "pip-compile --resolver=backtracking --extra=docs -o docs/requirements_docs.txt pyproject.toml" - ) + compile_docs(c) print("Done.") @task -def upgrade(c, optional=False, docs=False, all=False): - """Force update all core [and optional] dependencies in requirements files""" +def upgrade(c, dev=False, docs=False): + """ Force update all core [and optional] dependencies in requirements files """ print("Updating requirements files...") - c.run( - "pip-compile --resolver=backtracking --upgrade -o requirements.txt pyproject.toml" - ) - if optional or all: - c.run( - "pip-compile --resolver=backtracking --all-extras --upgrade -o requirements_dev.txt pyproject.toml" - ) - if docs or all: - c.run( - "pip-compile --resolver=backtracking --extra=docs --upgrade -o docs/requirements_docs.txt pyproject.toml" - ) + compile(c, upgrade=True) + if dev: + compile_dev(c, upgrade=True) + if docs: + compile_docs(c, upgrade=True) print("Done.") @task -def install(c, optional=False): - """Install all core [and optional] dependencies""" +def install(c, dev=False): + """ Install all core [and optional] dependencies """ print("Installing dependencies...") - c.run("pip install -r requirements.txt") - if optional: - c.run("pip install -r requirements_dev.txt") + c.run("pip-sync requirements.txt") + if dev: + c.run("pip-sync requirements_dev.txt") print("Done.") diff --git a/tasks/pypi.py b/tasks/pypi.py index b17f966..47eb19f 100644 --- a/tasks/pypi.py +++ b/tasks/pypi.py @@ -12,7 +12,7 @@ def clean(c, docs=False): docs_task.clean(c) -@task(pre=[clean], post=[clean_task.clean_all]) +@task(pre=[clean, docs_task.clean], post=[clean_task.clean_all]) def build(c, docs=False): """Clean up and build a new distribution [and docs]""" c.run("python -m build") @@ -38,7 +38,8 @@ def check(c, dist): c.run(f"twine check dist/{dist}") -@task(help={"repo": "Specify: pypi for a production release."}) +@task(pre=[clean], post=[clean_task.clean_all], + help={"repo": "Specify: pypi for a production release."}) def release(c, repo="testpypi"): """Build release and upload to PyPI""" print("Fetching version...") diff --git a/tox.ini b/tox.ini index 4ed82aa..9483c23 100644 --- a/tox.ini +++ b/tox.ini @@ -2,10 +2,10 @@ [tox] min_version = 4.0.0 env_list = {py38,py39,py310}-django32, - {py39,py310,py311}-{django41,django42}, + {py39,py310,py311}-django42, format, lint, coverage labels = - test = python{38, 39, 310, 311}, coverage + tests = {py38,py39,py310}-django32, {py39,py310,py311}-django42 static = format, lint [testenv] @@ -44,7 +44,7 @@ deps = flake8 flake8-bugbear commands = - flake8 . {posargs} + flake8 fmft demo tests {posargs} # Other Configuration [pytest]