Skip to content

Commit

Permalink
package consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
powderflask committed Oct 5, 2023
1 parent 3eb55df commit 285501c
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 50 deletions.
41 changes: 27 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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...
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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"
Expand Down
66 changes: 38 additions & 28 deletions tasks/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
5 changes: 3 additions & 2 deletions tasks/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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...")
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -44,7 +44,7 @@ deps =
flake8
flake8-bugbear
commands =
flake8 . {posargs}
flake8 fmft demo tests {posargs}

# Other Configuration
[pytest]
Expand Down

0 comments on commit 285501c

Please sign in to comment.