Modernize packaging

Switch to pyproject.toml packaging, using hatchling.

- Replace all uses of setup.py with updated equivalent
- BREAKING: Change extra name `amazon_ses` to
  `amazon-ses`, to comply with Python packaging
  name normalization
- Use hatch custom build hook to freeze version number
  in readme (previously custom setup.py code)
- Move separate requirements for dev, docs, tests
  into their own requirements.txt files
- Fix AnymailImproperlyInstalled to correctly refer
  to package extra name
- Update testing documentation
- Update docs readme rendering to match PyPI
  (and avoid setup.py)
- In tox tests, use isolated builds and update pip
- Remove AUTHORS.txt (it just referred to GitHub)
This commit is contained in:
Mike Edmunds
2023-05-03 16:55:08 -07:00
committed by GitHub
parent 9fba58237d
commit e8df0ec8e0
31 changed files with 418 additions and 292 deletions

33
tox.ini
View File

@@ -28,9 +28,15 @@ envlist =
djangoDev-py{310,311}-all
# ... then partial installation (limit extras):
django42-py311-{none,amazon_ses,postal}
# tox requires isolated builds to use pyproject.toml build config:
isolated_build = True
[testenv]
args_are_paths = false
# Download latest version of pip/setuptools available on each Python version:
download = true
deps =
-rtests/requirements.txt
django30: django~=3.0.0
django31: django~=3.1.0
django32: django~=3.2.0
@@ -40,10 +46,10 @@ deps =
django50: django~=5.0.0a0
djangoDev: https://github.com/django/django/tarball/main
extras =
# install [test] extras, unconditionally
test
# install [esp_name] extras only when testing "all" or esp_name factor
all,amazon_ses: amazon_ses
# Install [esp-name] extras only when testing "all" or esp_name factor.
# (Only ESPs with extra dependencies need to be listed here.
# Careful: tox factors (on the left) use underscore; extra names use hyphen.)
all,amazon_ses: amazon-ses
all,postal: postal
setenv =
# tell runtests.py to limit some test tags based on extras factor
@@ -61,11 +67,9 @@ setenv =
ignore_outcome =
# CI that wants to handle errors itself can set TOX_OVERRIDE_IGNORE_OUTCOME=false
djangoDev: {env:TOX_OVERRIDE_IGNORE_OUTCOME:true}
args_are_paths = false
# Upgrade pip/wheel/setuptools:
download = true
commands_pre =
python -VV
python -m pip --version
python -c 'import django; print("Django", django.__version__)'
commands =
python runtests.py {posargs}
@@ -98,25 +102,22 @@ commands =
pre-commit run --all-files
[testenv:docs]
basepython = python3.8
skip_install = true
basepython = python3.10
passenv =
CONTINUOUS_INTEGRATION
# (but not any of the live test API keys)
setenv =
DOCS_BUILD_DIR={envdir}/_html
whitelist_externals = /bin/bash
deps =
-rdocs/requirements.txt
commands_pre =
python -VV
sphinx-build --version
commands =
# Verify README.rst as used in setup.py long_description:
python setup.py check --restructuredtext --strict
# Build and verify docs:
sphinx-build -W -b dirhtml docs {env:DOCS_BUILD_DIR}
# Build README.rst into html:
/bin/bash -c 'python setup.py --long-description \
| rst2html5.py --config=docs/_readme/docutils.cfg \
> {env:DOCS_BUILD_DIR}/readme.html'
# Build and verify package metadata readme.
# Errors here are in README.rst:
python docs/_readme/render.py \
--package django-anymail \
--out {env:DOCS_BUILD_DIR}/readme.html