Skip to content

Commit

Permalink
Adopt modern python packaging (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Nov 10, 2021
1 parent da7aaa4 commit 16166cd
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 52 deletions.
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[build-system]
requires = [
"pip >= 19.3.1",
"setuptools >= 42",
"setuptools_scm[toml] >= 3.5.0",
"setuptools_scm_git_archive >= 1.1",
"wheel >= 0.33.6",
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
local_scheme = "no-local-version"
8 changes: 0 additions & 8 deletions requirements.txt

This file was deleted.

8 changes: 7 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[metadata]
name = doc8
summary = Style checker for Sphinx (or other) RST documentation
description-file =
description_file =
README.rst
author = OpenStack
author_email = openstack-discuss@lists.openstack.org
Expand Down Expand Up @@ -40,3 +40,9 @@ extend_ignore = E203

[options]
python_requires = >=3.6
# These are required in actual runtime:
install_requires =
docutils
restructuredtext-lint>=0.7
stevedore
Pygments
27 changes: 0 additions & 27 deletions setup.py

This file was deleted.

44 changes: 28 additions & 16 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
[tox]
minversion = 3.8
minversion = 3.24.4
envlist = lint,py,docs,packaging
isolated_build = True

[testenv]
deps =
-r{toxinidir}/test-requirements.txt
commands = pytest {posargs}
whitelist_externals =
rm
sh
setenv =
PIP_DISABLE_PIP_VERSION_CHECK=1

[testenv:lint]
deps =
Expand All @@ -19,25 +23,33 @@ commands =
deps =
-r{toxinidir}/doc/requirements.txt
commands =
doc8 -e .rst doc CONTRIBUTING.rst README.rst
python -m doc8 -e .rst doc CONTRIBUTING.rst README.rst
sphinx-build -W -b html doc/source doc/build/html

[testenv:packaging]
description =
Do packagin/distribution. If tag is not present or PEP440 compliant upload to
PYPI could fail
# `usedevelop = true` overrides `skip_install` instruction, it's unwanted
Build package, verify metadata, install package and assert behavior
deps =
build >= 0.7.0, < 0.8.0
twine
usedevelop = false
# don't install molecule itself in this env
skip_install = true
deps =
collective.checkdocs >= 0.2
pep517 >= 0.5.0
twine >= 1.14.0
setenv =
# Ref: https://twitter.com/di_codes/status/1044358639081975813
commands =
rm -rfv {toxinidir}/dist/
python setup.py sdist bdist_wheel
# metadata validation
python -m setup checkdocs --verbose
python -m twine check {toxinidir}/dist/*
# build wheel and sdist using PEP-517
{envpython} -c 'import os.path, shutil, sys; \
dist_dir = os.path.join("{toxinidir}", "dist"); \
os.path.isdir(dist_dir) or sys.exit(0); \
print("Removing \{!s\} contents...".format(dist_dir), file=sys.stderr); \
shutil.rmtree(dist_dir)'
{envpython} -m build \
--outdir {toxinidir}/dist/ \
{toxinidir}
# Validate metadata using twine
twine check --strict {toxinidir}/dist/*
# Ensure package is not installed
pip uninstall -y doc8
# Install the wheel
sh -c "python3 -m pip install {toxinidir}/dist/*.whl"
# Ensure package can be uninstalled
pip uninstall -y doc8

0 comments on commit 16166cd

Please sign in to comment.