diff --git a/Makefile b/Makefile index 2578ee7..9a7956e 100644 --- a/Makefile +++ b/Makefile @@ -97,7 +97,7 @@ clean-test: ## remove test and coverage artifacts .PHONY: dist dist: clean-build ## builds source and wheel package - python setup.py sdist bdist_wheel + python scripts/make-wheel.py twine check dist/* .PHONY: release diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..2234b5e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,91 @@ +[build-system] +requires = ["setuptools>=80", "setuptools-scm>=8"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +version_file = "cloup/_version.py" + +[project] +name = "cloup" +dynamic = ["version"] + +description = "Adds features to Click: option groups, constraints, subcommand sections and help themes." +readme = { file = "README.rst", content-type = "text/x-rst" } +license = { text = "BSD 3-Clause" } + +requires-python = ">= 3.9" +authors = [ + { name = "Gianluca Gippetto", email = "gianluca.gippetto@gmail.com" }, +] + +classifiers = [ + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] + + +dependencies = [ + "click>=8.0,<9.0", + "typing_extensions; python_version <= '3.10'", +] + + +[dependency-groups] +docs = [ + "furo", + "sphinx", + "sphinx-autoapi", + "sphinx-autobuild", + "sphinx-panels", + "sphinx-copybutton", + "sphinx-version-warning", + "sphinx-issues", +] + +test = [ + "pytest", + "pytest-cov", + "pytest-html", +] + +dev = [ + "build", + "flake8", + "flake8-pyproject", + "mypy", + "setuptools-scm", + "tox<4", + "twine", + {include-group = "docs"}, + {include-group = "test"}, +] + + +[tool.flake8] +exclude = "docs" +max-line-length = 90 + +ignore = [ + "E241", + "E251", + "W503", +] + +[tool.mypy] +ignore_missing_imports = true + + +[tool.coverage.report] +exclude_lines = [ + "pragma: no covver", + "raise NotImplementedError", + "...", + "if TYPE_CHECKING:", +] diff --git a/scripts/make-wheel.py b/scripts/make-wheel.py new file mode 100644 index 0000000..8f72f23 --- /dev/null +++ b/scripts/make-wheel.py @@ -0,0 +1,37 @@ +import sys +import contextlib +import shutil +import subprocess +from pathlib import Path + + +@contextlib.contextmanager +def backup(): + saved = [] + + def save(path: Path): + saved.append((path, path.parent / f"{path.name}.bck")) + shutil.copyfile(*saved[-1]) + return saved[-1][0] + + try: + yield save + finally: + for dst, src in saved: + shutil.copyfile(src, dst) + src.unlink() + + +def process(): + with backup() as save: + readme = save(Path("README.rst")) + print("massaging {readme} ..") + txt = readme.read_text() + readme.write_text(txt[txt.find(".. docs-index-start") :]) + + print("creating wheel ..") + subprocess.check_call([sys.executable, "-m", "build", "."]) + + +if __name__ == "__main__": + process() diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 974fe9d..0000000 --- a/setup.cfg +++ /dev/null @@ -1,20 +0,0 @@ -[bdist_wheel] -universal = 1 - -[flake8] -exclude = docs -max_line_length = 90 -ignore = E241, E251, W503 - -[aliases] -test = pytest - -[mypy] -ignore_missing_imports = True - -[coverage:report] -exclude_lines = - pragma: no cover - raise NotImplementedError - \.\.\. - if TYPE_CHECKING: diff --git a/setup.py b/setup.py deleted file mode 100644 index be9445f..0000000 --- a/setup.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python -from pathlib import Path - -from setuptools import find_packages, setup - - -def make_long_description(write_file=False): - readme = Path('README.rst').read_text(encoding='utf-8') - # PyPI doesn't support the `raw::` directive. Skip it. - start = readme.find('.. docs-index-start') - long_description = readme[start:] - if write_file: - Path('PYPI_README.rst').write_text(long_description, encoding='utf-8') - return long_description - - -setup( - name='cloup', - setup_requires=['setuptools_scm'], - use_scm_version={ - 'write_to': 'cloup/_version.py' - }, - author='Gianluca Gippetto', - author_email='gianluca.gippetto@gmail.com', - description="Adds features to Click: option groups, constraints, subcommand " - "sections and help themes.", - long_description_content_type='text/x-rst', - long_description=make_long_description(), - url='https://github.com/janLuke/cloup', - license="BSD 3-Clause", - keywords=['CLI', 'click', 'argument groups', 'option groups', 'constraints', - 'help colors', 'help themes', 'help styles'], - classifiers=[ - 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', - 'Natural Language :: English', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Programming Language :: Python :: 3.13', - ], - packages=find_packages(include=['cloup', 'cloup.*']), - zip_safe=False, - include_package_data=True, - python_requires='>=3.9', - install_requires=[ - 'click >= 8.0, < 9.0', - 'typing_extensions; python_version<="3.10"', - ], -) diff --git a/tox.ini b/tox.ini index 4e0dafa..fa3b892 100644 --- a/tox.ini +++ b/tox.ini @@ -1,4 +1,5 @@ [tox] +isolated_build = true envlist = lint mypy @@ -35,7 +36,9 @@ commands = [testenv:lint] skip_install = true -deps = flake8 +deps = + flake8 + flake8-pyproject commands = flake8 cloup tests examples [testenv:mypy]