Skip to content

Commit

Permalink
Migrate from pbr to hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmer committed Nov 1, 2023
1 parent 16991ea commit f74eec6
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade setuptools wheel
python3 -m pip install --upgrade setuptools wheel setuptools_scm
python3 -m pip install sphinx
python3 -m pip install ".[test,twisted]"
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -21,3 +21,6 @@ AUTHORS
ChangeLog
.idea
.tox
testtools/_version.py
man/testtools.1
man
70 changes: 69 additions & 1 deletion pyproject.toml
Expand Up @@ -8,6 +8,74 @@ module = [
"fixtures.*",
"testresources.*",
"testscenarios.*",
"pbr.*",
]
ignore_missing_imports = true

[build-system]
requires = ["setuptools>=61"]
build-backend = "setuptools.build_meta"

[project]
name = "testtools"
description = "Extensions to the Python standard library unit testing framework"
readme = "doc/overview.rst"
authors = [{name = "Jonathan M. Lange", email = "jml+testtools@mumak.net"}]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT 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",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Testing",
]
dependencies = ["setuptools; python_version>='3.12'"]
dynamic = ["version"]
requires-python = ">=3.7"

[project.urls]
Homepage = "https://github.com/testing-cabal/testtools"

[tool.setuptools]
include-package-data = false

[tool.setuptools.packages.find]
include = ["testtools"]
exclude = ["man*"]

[tool.extras]
test = """
testscenarios
testresources"""
twisted = """
Twisted"""

[tool.files]
packages = "testtools"

[tool.hatch.version]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "testtools/_version.py"
tag-pattern = "^(testtools-)?(?P<version>[0-9]+(\\.[0-9]+)*(-[0-9]+)?)(\\.post(?P<post>[0-9]+))?$"
template = """\
# This file is automatically generated by hatch.
version = {version!r}
__version__ = {version_tuple!r}
"""

[project.optional-dependencies]
test = ["testscenarios", "testresources"]
twisted = ["Twisted"]
1 change: 0 additions & 1 deletion requirements.txt
@@ -1,2 +1 @@
pbr>=0.11
fixtures>=2.0
41 changes: 0 additions & 41 deletions setup.cfg

This file was deleted.

5 changes: 1 addition & 4 deletions setup.py
@@ -1,7 +1,4 @@
#!/usr/bin/env python
import setuptools

setuptools.setup(
python_requires='>=3.7',
setup_requires=['pbr'],
pbr=True)
setuptools.setup()
25 changes: 21 additions & 4 deletions testtools/__init__.py
Expand Up @@ -42,6 +42,8 @@
'TimestampingStreamResult',
'try_import',
'unique_text_generator',
'version',
'__version__',
]

from testtools.helpers import try_import
Expand Down Expand Up @@ -107,7 +109,22 @@
# established at this point, and setup.py will use a version of next-$(revno).
# If the releaselevel is 'final', then the tarball will be major.minor.micro.
# Otherwise it is major.minor.micro~$(revno).
from pbr.version import VersionInfo
_version = VersionInfo('testtools')
__version__ = _version.semantic_version().version_tuple()
version = _version.release_string()

try:
# If setuptools_scm is installed (e.g. in a development environment with
# an editable install), then use it to determine the version dynamically.
from setuptools_scm import get_version

# This will fail with LookupError if the package is not installed in
# editable mode or if Git is not installed.
version = get_version(root="..", relative_to=__file__)
__version__ = tuple(version.split('.'))
except (ImportError, LookupError):
# As a fallback, use the version that is hard-coded in the file.
try:
from ._version import (__version__, version)
except ModuleNotFoundError:
# The user is probably trying to run this without having installed
# the package, so complain.
raise RuntimeError(
"Testtools is not correctly installed. Please install it with pip.")
2 changes: 2 additions & 0 deletions tox.ini
Expand Up @@ -6,6 +6,8 @@ minversion = 1.6
usedevelop = True
deps =
sphinx
setuptools>=61
setuptools-scm
extras =
test
twisted
Expand Down

0 comments on commit f74eec6

Please sign in to comment.