Skip to content

Commit

Permalink
Merge pull request #354 from jelmer/hatch
Browse files Browse the repository at this point in the history
Migrate from pbr to hatch
  • Loading branch information
jelmer authored Nov 1, 2023
2 parents 16991ea + 87cbf96 commit 87ab359
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 = "[email protected]"}]
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", "fixtures"]
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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.")
10 changes: 3 additions & 7 deletions testtools/tests/twistedsupport/test_matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""Tests for Deferred matchers."""

from testtools.content import TracebackContent
from testtools.helpers import try_import
from testtools.matchers import (
AfterPreprocessing,
Equals,
Expand All @@ -13,13 +12,10 @@
from ._helpers import NeedsTwistedTestCase


has_no_result = try_import('testtools.twistedsupport.has_no_result')
failed = try_import('testtools.twistedsupport.failed')
succeeded = try_import('testtools.twistedsupport.succeeded')
from testtools.twistedsupport import has_no_result, failed, succeeded


defer = try_import('twisted.internet.defer')
Failure = try_import('twisted.python.failure.Failure')
from twisted.internet import defer
from twisted.python.failure import Failure


def mismatches(description, details=None):
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
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 87ab359

Please sign in to comment.