diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 4903985c..00000000 --- a/.coveragerc +++ /dev/null @@ -1,13 +0,0 @@ -# https://pytest-cov.readthedocs.io/ - -[run] -source = semver -branch = True - -[report] -show_missing = true -precision = 1 -exclude_lines = - pragma: no cover - if __name__ == .__main__.: - if not hasattr\(__builtins__, .cmp.\): diff --git a/changelog.d/373.trivial.rst b/changelog.d/373.trivial.rst new file mode 100644 index 00000000..5705a297 --- /dev/null +++ b/changelog.d/373.trivial.rst @@ -0,0 +1 @@ +Use hatchling build backend diff --git a/pyproject.toml b/pyproject.toml index d288e68e..4c9832d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,27 +1,235 @@ -# -# -# See also https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html -# -# General idea taken from -# https://godatadriven.com/blog/a-practical-guide-to-setuptools-and-pyproject-toml/ - [build-system] requires = [ - # sync with setup.py until we discard non-pep-517/518 - "setuptools", - "setuptools-scm", - "wheel", - "build", + "hatchling>=1.8.0", +] +build-backend = "hatchling.build" + +[project] +name = "semver" +description = "Python helper for Semantic Versioning (https://semver.org)" +readme = "README.rst" +requires-python = ">=3.7" +authors = [ + { name = "Kostiantyn Rybnikov", email = "k-bx@k-bx.com" }, +] +maintainers = [ + { name = "Sebastien Celles", email = "s.celles@gmail.com" }, + { name = "Tom Schraitle" }, +] +keywords = [ + "python", + "version", + "semver", + "versioning", + "version", + "semantic-versioning", + "release", + "semver-format", + "semver-tag", + "semver-release", + "semver-cli", +] +classifiers = [ + "Environment :: Web Environment", + "Development Status :: 5 - Production/Stable", + "Topic :: Software Development", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "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", + "Topic :: Software Development :: Libraries :: Python Modules", +] +dependencies = [] +dynamic = [ + "version", +] + +[project.urls] +Homepage = "https://github.com/python-semver/python-semver" +Changelog = "https://python-semver.readthedocs.io/en/latest/changelog.html" +Documentation = "https://python-semver.rtfd.io" +Releases = "https://github.com/python-semver/python-semver/releases" +Issues = "https://github.com/python-semver/python-semver/issues" + +[project.license] +file = "LICENSE.txt" + +[project.scripts] +pysemver = "semver.cli:main" + +[tool.hatch.version] +path = "src/semver/__about__.py" + +[tool.hatch.build.targets.wheel] +packages = [ + "src/semver", +] + +[tool.hatch.build.targets.wheel.force-include] +"src/semver/py.typed" = "semver/py.typed" + +[tool.hatch.envs.default] +dependencies = [ + "towncrier", + "wheel", +] + +[tool.hatch.envs.style] +dependencies = [ + "black", + "flake8", + "pycodestyle", ] -build-backend = "setuptools.build_meta" +[tool.hatch.envs.style.scripts] +fmt = [ + "black .", +] +lint = [ + "flake8 --exit-zero", + "pycodestyle", +] + +[tool.hatch.envs.docs] +dependencies = [ + #"sphinx", + "sphinx-argparse", + "sphinx-autodoc-typehints", +] + +[tool.hatch.envs.docs.scripts] +build = "docs/make.bat -C docs html" +linkcheck = "docs/make.bat -C docs linkcheck" +serve = "python3 -m webbrowser -t docs/_build/html/index.html" +[tool.hatch.envs.test] +dependencies = [ + "coverage[toml]", + "pytest-cov", +] + +[[tool.hatch.envs.test.matrix]] +python = ["37", ] + +[tool.hatch.envs.test.scripts] +cov = "pytest -vx" +no-cov = "cov --no-cov" + +[tool.hatch.envs.testall] +dependencies = [ + "coverage[toml]", + "pytest-cov", +] +[[tool.hatch.envs.testall.matrix]] +python = ["37", "38", "39", "310", "311", ] + +[tool.hatch.envs.testall.scripts] +cov = "pytest -vx" +no-cov = "cov --no-cov" + +[tool.hatch.envs.tox] +dependencies = [ + "tox", +] + +[tool.hatch.envs.tox.scripts] +test = "tox" + +[tool.coverage.run] +source = [ + "semver", + #"src/semver/*", +] +branch = true +parallel = true +omit = [ + # add files to exclude them from the coverage report, e.g. + "src/semver/_types.py", +] + +[tool.coverage.report] +show_missing = true +precision = 1 +exclude_lines = [ + "no cover", + "if __name__ == .__main__.:", + "if TYPE_CHECKING:", + # note the use of single quote below to denote "raw" strings in TOML + 'if not hasattr\(__builtins__, .cmp.\):', + 'class .*\bProtocol\):', + '@(abc\.)?abstractmethod', +] + +[tool.mypy] +# the mypy settings go here +# To have the `py.typed` file installed with the package we had to include it +# in the build metadata (see [tool.hatch.build.targets.wheel.force-include]) +enable_error_code = [ + "ignore-without-code", +] +show_error_codes = true +warn_unused_ignores = true +implicit_reexport = true +pretty = true +follow_imports = "normal" + +[tool.pytest.ini_options] +norecursedirs = [ + ".git", + "build", + ".env/", + "env/", + ".pyenv/", + ".tmp/", + ".eggs/", + "venv/", +] +testpaths = [ + "tests", + "docs", +] +filterwarnings = [ + "ignore::DeprecationWarning", + 'ignore:Function semver.*:DeprecationWarning', +] +addopts = [ + "--no-cov-on-fail", + "--cov=semver", + "--cov-report=term-missing", + "--doctest-glob='*.rst'", + "--doctest-modules", + "--doctest-report ndiff", +] + +# flake8 does not support configuration in pyproject.toml +# see https://github.com/PyCQA/flake8/issues/234 +# (there are alternatives, e.g. https://github.com/john-hen/Flake8-pyproject) +# we stick to the original flake8 with configuration +# in the `[flake8]` section of setup.cfg + +# pycodestyle does not support configuration in pyproject.toml +# We stick to the original pycodestyle configuration +# in the `[pycodestyle]` section of setup.cfg [tool.black] line-length = 88 -target-version = ['py37', 'py38', 'py39', 'py310', 'py311'] +target-version = ["py36", "py37", "py38", "py39", "py310", "py311"] # diff = true - +# note the use of single quotes below to denote "raw" strings in TOML +extend-exclude = ''' +# A regex preceded with ^/ will apply only to files and directories +# in the root of the project. +^/*.py +''' +include = ''' +^/setup.py +''' [tool.towncrier] package = "semver" diff --git a/setup.cfg b/setup.cfg index 0ee8564c..5789d709 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,73 +1,3 @@ -# -# Metadata for setup.py -# -# See https://setuptools.rtfd.io/en/latest/userguide/declarative_config.html - -[metadata] -name = semver -version = attr: semver.__about__.__version__ -description = Python helper for Semantic Versioning (https://semver.org) -long_description = file: README.rst -long_description_content_type = text/x-rst -author = Kostiantyn Rybnikov -author_email = k-bx@k-bx.com -maintainer = Sebastien Celles, Tom Schraitle -maintainer_email = s.celles@gmail.com -url = https://github.com/python-semver/python-semver -project_urls = - Changelog = https://python-semver.readthedocs.io/en/latest/changelog.html - Documentation = https://python-semver.rtfd.io - Releases = https://github.com/python-semver/python-semver/releases - Bug Tracker = https://github.com/python-semver/python-semver/issues -classifiers = - Environment :: Web Environment - Intended Audience :: Developers - License :: OSI Approved :: BSD License - 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 :: 3.12 - Topic :: Software Development :: Libraries :: Python Modules -license = BSD - -[options] -package_dir = - =src -packages = find: -python_requires = >=3.7 -include_package_data = True - -[options.entry_points] -console_scripts = - pysemver = semver.cli:main - -[options.packages.find] -where = src - -[options.package_data] -semver = py.typed - -[tool:pytest] -norecursedirs = .git build .env/ env/ .pyenv/ .tmp/ .eggs/ venv/ -testpaths = tests docs -pythonpath = src tests -filterwarnings = - ignore:Function 'semver.*:DeprecationWarning - # ' <- This apostroph is just to fix syntax highlighting -addopts = - --import-mode=importlib - --no-cov-on-fail - --cov=semver - --cov-report=term-missing - --doctest-glob='*.rst' - --doctest-modules - --doctest-report ndiff - [flake8] max-line-length = 88 ignore = F821,W503