diff --git a/Makefile b/Makefile index 023069c..5fd8928 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # This Makefile is used to manage development and distribution. # # Created: 2022-08-11 -# Updated: 2022-08-31 +# Updated: 2022-09-01 # .PHONY: build create-venv help prebuild publish test test-all update-venv @@ -64,7 +64,7 @@ dev-venv-create: dev-venv-base dev-venv-install dev-venv-install: ${VENV} pip install --upgrade pip setuptools wheel - ${VENV} pip install --upgrade build sphinx tox twine typing-extensions + ${VENV} pip install --upgrade build sphinx tomli tox twine typing-extensions ${VENV} pip install -e "${SRC_DIR}" diff --git a/prebuild.py b/prebuild.py index c42940c..2d009da 100644 --- a/prebuild.py +++ b/prebuild.py @@ -1,10 +1,14 @@ """ -This script generates files required for source and wheel distributions. +This script generates files required for source and wheel distributions, +and legacy installations. """ import argparse +import configparser import sys +import tomli + def generate_readme_dist() -> None: """ @@ -25,6 +29,43 @@ def generate_readme_dist() -> None: fh.write(output) +def generate_setup_cfg() -> None: + """ + Generate the "setup.cfg" file from "pyproject.toml" in order to + support legacy installation with "setup.py". + """ + print("Read: pyproject.toml") + with open("pyproject.toml", 'rb') as fh: + config = tomli.load(fh) + + print("Write: setup.cfg") + output = configparser.ConfigParser() + output['metadata'] = { + 'author': config['project']['authors'][0]['name'], + 'author_email': config['project']['authors'][0]['email'], + 'classifiers': "\n" + "\n".join(config['project']['classifiers']), + 'description': config['project']['description'], + 'license': config['project']['license']['text'], + 'long_description': f"file: {config['project']['readme']}", + 'long_description_content_type': "text/x-rst", + 'name': config['project']['name'], + 'url': config['project']['urls']['Source Code'], + 'version': f"attr: {config['tool']['setuptools']['dynamic']['version']['attr']}", + } + output['options'] = { + 'packages': "find:", + 'python_requires': config['project']['requires-python'], + 'setup_requires': ", ".join(config['build-system']['requires']), + 'test_suite': "tests", + } + output['bdist_wheel'] = { + 'universal': "1", + } + + with open("setup.cfg", 'w') as fh: + output.write(fh) + + def main() -> int: """ Run the script. @@ -34,6 +75,7 @@ def main() -> int: parser.parse_args(sys.argv[1:]) generate_readme_dist() + generate_setup_cfg() return 0 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..6b65c40 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,36 @@ +[metadata] +author = Caleb P. Burns +author_email = cpburnz@gmail.com +classifiers = + Development Status :: 4 - Beta + Intended Audience :: Developers + License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0) + Operating System :: OS Independent + Programming Language :: Python + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + Programming Language :: Python :: Implementation :: CPython + Programming Language :: Python :: Implementation :: PyPy + Topic :: Software Development :: Libraries :: Python Modules + Topic :: Utilities +description = Utility library for gitignore style pattern matching of file paths. +license = MPL 2.0 +long_description = file: README-dist.rst +long_description_content_type = text/x-rst +name = pathspec +url = https://github.com/cpburnz/python-pathspec +version = attr: pathspec._meta.__version__ + +[options] +packages = find: +python_requires = >=3.7 +setup_requires = setuptools>=40.8.0 +test_suite = tests + +[bdist_wheel] +universal = 1 + diff --git a/setup.py b/setup.py index b5e21ab..17788aa 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,8 @@ """ -This setup script only exists to support installations where pip cannot -be used such as for system packages. +This setup script only exists to support legacy installations where pip +is cumbersome be used such as for system packages. """ -import setuptools -import sys +from setuptools import setup -if int(setuptools.__version__.split(".")[0]) < 61: - sys.stderr.write(( - "WARNING: Installed version of setuptools, {version}, is too old. " - "Version 61.0.0 is required for the pyproject.toml configuration " - "to load. This will most likely build and install as a packaged " - "named 'UNKNOWN'.\n" - ).format(version=setuptools.__version__)) - -setuptools.setup() +setup()