Skip to content

Commit

Permalink
Move from setup.py to setup.cfg
Browse files Browse the repository at this point in the history
* Add `pyproject.toml`
* Replace `MANIFEST.in` with `package_data` in `setup.cfg`
* Fold `tox.ini` into `setup.cfg`
  • Loading branch information
posita committed Sep 18, 2021
1 parent 268fc12 commit 08edd74
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 140 deletions.
11 changes: 0 additions & 11 deletions MANIFEST.in

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
WARNING: THIS DOCUMENT MUST BE SELF-CONTAINED.
ALL LINKS MUST BE ABSOLUTE.
This file is used on GitHub and PyPi (via setup.py).
This file is used on GitHub and PyPi (via setup.cfg).
There is no guarantee that other docs/resources will be available where this content is displayed.
-->

Expand Down Expand Up @@ -310,13 +310,13 @@ Installation can be performed via [PyPI](https://pypi.python.org/pypi/dyce/).
...
```

Alternately, you can download [the source](https://github.com/posita/dyce) and run ``setup.py``.
Alternately, you can download [the source](https://github.com/posita/dyce) and install manually ``setup.cfg``.

```sh
% git clone https://github.com/posita/dyce.git
...
% cd dyce
% python setup.py install
% python -m pip install . # -or- python -c 'from setuptools import setup ; setup()' install .
...
```

Expand Down
2 changes: 1 addition & 1 deletion docs/contrib.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The above is essentially equivalent to the following (with some additional check
```

The ``[dev]`` variant includes additional dependencies necessary for development and testing.
See the ``extras_require`` parameter in [``setup.py``](https://github.com/posita/dyce/blob/latest/setup.py).
See the ``[options.extras_require]`` section in [``setup.cfg``](https://github.com/posita/dyce/blob/latest/setup.cfg).

Unit tests are run with [Tox](https://tox.readthedocs.org/) (but can also be run with [pytest](https://docs.pytest.org/) directly, if installed).

Expand Down
11 changes: 6 additions & 5 deletions helpers/draft-release.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#!/usr/bin/env sh
# -*- encoding: utf-8 -*-
# ======================================================================================
Expand All @@ -21,8 +22,7 @@ if [ "${#}" -ne 3 ] ; then
exit 1
fi

PKG="$( python -c 'import setup ; print(setup.SETUP_ARGS["name"])' )"
VERS_PY="$( python -c 'import setup ; print(setup.vers_info["__path__"])' )"
PKG="$( python -c 'import configparser, sys ; config = configparser.ConfigParser() ; config.read_file(open(sys.argv[1])) ; print(config.get("metadata", "name"))' "${_REPO_DIR}/setup.cfg" )"
MAJOR="${1}"
MINOR="${2}"
PATCH="${3}"
Expand All @@ -36,8 +36,9 @@ twine --version
mkdocs --version
mike --version
git checkout -b "${VERS_PATCH}-release"
perl -pi -e 's{^__version__([^#=]*)=\s*\(\s*0\s*,\s*0\s*,\s*0\s*,?\s*\)(\s*#.*)?$} {__version__\1= ('"${MAJOR}"', '"${MINOR}"', '"${PATCH}"')\2}g ;' "${VERS_PY}"
perl -pi -e 's{\.github\.io/dyce/latest/([^)]*)\)} {\.github\.io/dyce/'"${VERS}"'/\1)}g ; s{/dyce/([^/]+/)*latest/} {/dyce/\1'"${TAG}"'/}g ; s{//pypi\.org/([^/]+/)?'"${PKG}"'/} {//pypi.org/\1'"${PKG}"'/'"${VERS_PATCH}"'/}g ; s{/pypi/([^/]+/)?'"${PKG}"'\.svg\)} {/pypi/\1'"${PKG}"'/'"${VERS_PATCH}"'.svg)}g' README.md docs/contrib.md
perl -pi -e "s{^__version__\\b([^#=]*)=\\s*\\(\\s*0\\s*,\\s*0\\s*,\\s*0\\s*,?\\s*\\)(\\s*#.*)?\$} {__version__\\1= (${MAJOR}, ${MINOR}, ${PATCH})\\2}g" dyce/version.py
perl -pi -e "s{^version\\s+=\\s+0.0.0\$} {version = ${MAJOR}.${MINOR}.${PATCH}}g" setup.cfg
perl -pi -e "s{\\.github\\.io/dyce/latest/([^)]*)\\)} {\\.github\\.io/dyce/${VERS}/\\1)}g ; s{/dyce/([^/]+/)*latest/} {/dyce/\\1${TAG}/}g ; s{//pypi\\.org/([^/]+/)?${PKG}/} {//pypi.org/\\1${PKG}/${VERS_PATCH}/}g ; s{/pypi/([^/]+/)?${PKG}\\.svg\\)} {/pypi/\\1${PKG}/${VERS_PATCH}.svg)}g" setup.cfg README.md docs/contrib.md

problem_areas="$(
grep -En '/latest\b' /dev/null README.md docs/*.md || [ "${?}" -eq 1 ]
Expand Down Expand Up @@ -87,7 +88,7 @@ fi
set -ex
git commit --all --message "Update version and release ${TAG}."
tox
python setup.py bdist_wheel sdist
python -c 'from setuptools import setup ; setup()' bdist_wheel sdist
twine check "dist/${PKG}-${VERS_PATCH}"[-.]*
mike deploy --rebase --update-aliases "${VERS}" latest
git tag --force --message "$( cat <<EOF
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
89 changes: 69 additions & 20 deletions tox.ini → setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# ======================================================================================
# Copyright and other protections apply. Please see the accompanying LICENSE file for
# rights and restrictions governing use of this software. All rights not expressly
Expand All @@ -7,26 +6,78 @@
# software in any capacity.
# ======================================================================================

[tox] # -------------------------------------------------------------------------------

envlist = check, py{39,38}-lint{,-beartype}, py{39,38,37}{,-beartype-matplotlib}, pypy{39,38,37}{,-beartype}
skip_missing_interpreters = true
[metadata] # --------------------------------------------------------------------------

name = dycelib
version = 0.0.0
url = https://posita.github.io/dyce/latest/
author = Matt Bogosian
author_email = [email protected]
# From <https://pypi.python.org/pypi?%3Aaction=list_classifiers>
classifiers =
Topic :: Education
Topic :: Games/Entertainment
Topic :: Scientific/Engineering :: Mathematics
Topic :: Software Development :: Libraries :: Python Modules
Development Status :: 4 - Beta
Intended Audience :: Developers
Intended Audience :: Education
Intended Audience :: Science/Research
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
license = MIT License
description = Simple Python tools for exploring dice outcomes and other finite discrete probabilities
long_description = file: README
long_description_content_type = text/markdown; charset=UTF-8

[options] # ---------------------------------------------------------------------------

install_requires =
typing-extensions>=3.10;python_version<'3.9'
packages = dyce

[options.package_data] # --------------------------------------------------------------

* = LICENSE

[options.extras_require] # ------------------------------------------------------------

dev =
beartype>=0.8
mike
# See:
# * <https://github.com/mkdocs/mkdocs/issues/2448>
# * <https://github.com/mkdocstrings/mkdocstrings/issues/295>
mkdocs!=1.2
mkdocs-exclude
mkdocs-material
mkdocstrings
mypy
numpy
pre-commit
pytest-gitignore
sympy
tox
twine

[travis] # ----------------------------------------------------------------------------
[tox:tox] # ---------------------------------------------------------------------------

python =
3.7: py37{,-beartype-matplotlib}
3.8: py38{,-beartype-matplotlib}, py38-lint{,-beartype}
3.9: py39{,-beartype-matplotlib}, py39-lint{,-beartype}, check
pypy3.7: pypy37{,-beartype}
pypy3.8: pypy38{,-beartype}
pypy3.9: pypy39{,-beartype}
envlist = check, py{39,38}-lint{,-beartype} py39 py39-beartype-matplotlib py{38,37,py39,py38,py37}-beartype
skipsdist = true
skip_missing_interpreters = true

[testenv] # ---------------------------------------------------------------------------

commands =
pytest --cov=dyce {posargs}
deps =
--editable .
beartype: beartype>=0.8
matplotlib: matplotlib
!pypy37-!pypy38-!pypy39: numpy
Expand All @@ -43,7 +94,6 @@ deps =
sympy
setenv =
PYTHONWARNINGS = once
usedevelop = true

[testenv:pypy{37,38,39}{,-beartype}] # ------------------------------------------------

Expand All @@ -52,16 +102,15 @@ basepython =
pypy38: pypy-3.8
pypy39: pypy-3.9

[testenv:check{,-classdiagrams}] # ----------------------------------------------------
[testenv:check] # ----------------------------------------------------

basepython = {env:PYTHON:python}
commands =
rm -frv site
make -C docs/img
mkdocs build --strict
python setup.py sdist
python -c 'from setuptools import setup ; setup()' sdist
twine check dist/*
!classdiagrams: git diff-files --exit-code --patch
deps =
graphviz
matplotlib
Expand All @@ -76,8 +125,8 @@ deps =
sympy
twine
# pylint contains pyreverse
classdiagrams: pygraphviz
classdiagrams: pylint
pygraphviz
pylint
setenv =
PYTHONWARNINGS = ignore
whitelist_externals =
Expand Down Expand Up @@ -119,7 +168,7 @@ ignore =
E704, # multiple statements on one line (def)
W503 # line break occurred before a binary operator

[pytest] # ----------------------------------------------------------------------------
[tool:pytest] # -----------------------------------------------------------------------

addopts = --doctest-continue-on-failure --doctest-glob='*.md' --doctest-modules
doctest_optionflags = ELLIPSIS IGNORE_EXCEPTION_DETAIL NORMALIZE_WHITESPACE NUMBER
100 changes: 0 additions & 100 deletions setup.py

This file was deleted.

0 comments on commit 08edd74

Please sign in to comment.