Skip to content

Commit 80de178

Browse files
authored
Merge pull request #11 from jugmac00/move-buildback-end-to-hatchling
Move buildbackend from setuptools/pbr to hatchling
2 parents 9c484e6 + fd9a585 commit 80de178

File tree

10 files changed

+123
-71
lines changed

10 files changed

+123
-71
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Install dependencies
2323
run: |
2424
python -m pip install --upgrade pip
25-
python -m pip install testtools pbr ruff
25+
python -m pip install testtools ruff
2626
- name: Run ruff
2727
run: |
2828
python -m ruff check .

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
TAGS
22
tags
33
lib/testtools
4-
MANIFEST
54
build
65
dist
76
*~
@@ -11,5 +10,5 @@ testscenarios.egg-info
1110
*.pyc
1211
__pycache__
1312
*.egg
14-
ChangeLog
15-
AUTHORS
13+
testscenarios/_version.py
14+
tox.ini

MANIFEST.in

Lines changed: 0 additions & 10 deletions
This file was deleted.

Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PYTHONPATH:=$(shell pwd):${PYTHONPATH}
2-
PYTHON ?= python
2+
PYTHON ?= python3
33

44
all: check
55

@@ -16,7 +16,4 @@ TAGS: testscenarios/*.py testscenarios/tests/*.py
1616
tags: testscenarios/*.py testscenarios/tests/*.py
1717
ctags -R testscenarios/
1818

19-
release:
20-
python setup.py sdist bdist_wheel upload -s
21-
22-
.PHONY: all check release
19+
.PHONY: all check

pyproject.toml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
[build-system]
2+
requires = ["hatchling", "hatch-vcs"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "testscenarios"
7+
description = "Testscenarios, a pyunit extension for dependency injection"
8+
readme = "README.rst"
9+
classifiers = [
10+
"Development Status :: 6 - Mature",
11+
"Intended Audience :: Developers",
12+
"License :: OSI Approved :: BSD License",
13+
"License :: OSI Approved :: Apache Software License",
14+
"Operating System :: OS Independent",
15+
"Programming Language :: Python",
16+
"Programming Language :: Python :: 3",
17+
"Programming Language :: Python :: 3.10",
18+
"Programming Language :: Python :: 3.11",
19+
"Programming Language :: Python :: 3.12",
20+
"Programming Language :: Python :: 3.13",
21+
"Programming Language :: Python :: 3.14",
22+
"Topic :: Software Development :: Quality Assurance",
23+
"Topic :: Software Development :: Testing",
24+
]
25+
authors = [{name = "Testing-cabal", email = "[email protected]"}]
26+
license = {text = "Apache-2.0 or BSD"}
27+
requires-python = ">=3.10"
28+
dynamic = ["version"]
29+
30+
[project.urls]
31+
Homepage = "https://launchpad.net/testscenarios"
32+
"Bug Tracker" = "https://bugs.launchpad.net/testscenarios"
33+
"Source Code" = "https://github.com/testing-cabal/testscenarios"
34+
35+
[project.optional-dependencies]
36+
"test" = ["testtools"]
37+
38+
[tool.hatch.version]
39+
source = "vcs"
40+
41+
[tool.hatch.build.hooks.vcs]
42+
version-file = "testscenarios/_version.py"
43+
tag-pattern = "^(testtools-)?(?P<version>[0-9]+(\\.[0-9]+)*(-[0-9]+)?)(\\.post(?P<post>[0-9]+))?$"
44+
template = """\
45+
# This file is automatically generated by hatch.
46+
version = {version!r}
47+
__version__ = {version_tuple!r}
48+
"""
49+
50+
[tool.hatch.build.targets.sdist]
51+
include = [
52+
"testscenarios*",
53+
"APACHE-2.0",
54+
"AUTHORS",
55+
"BSD",
56+
"ChangeLog",
57+
"COPYING",
58+
"GOALS",
59+
"HACKING",
60+
"Makefile",
61+
"NEWS",
62+
"README.rst",
63+
"tox.ini",
64+
"doc/*.py",
65+
]

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
pbr >= 0.11
21
testtools

setup.cfg

Lines changed: 0 additions & 28 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

testscenarios/__init__.py

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,6 @@
2727
methods for details.
2828
"""
2929

30-
# same format as sys.version_info: "A tuple containing the five components of
31-
# the version number: major, minor, micro, releaselevel, and serial. All
32-
# values except releaselevel are integers; the release level is 'alpha',
33-
# 'beta', 'candidate', or 'final'. The version_info value corresponding to the
34-
# Python version 2.0 is (2, 0, 0, 'final', 0)." Additionally we use a
35-
# releaselevel of 'dev' for unreleased under-development code.
36-
#
37-
# If the releaselevel is 'alpha' then the major/minor/micro components are not
38-
# established at this point, and setup.py will use a version of next-$(revno).
39-
# If the releaselevel is 'final', then the tarball will be major.minor.micro.
40-
# Otherwise it is major.minor.micro~$(revno).
41-
from pbr.version import VersionInfo
42-
43-
_version = VersionInfo("testscenarios")
44-
__version__ = _version.semantic_version().version_tuple()
45-
version = _version.release_string()
46-
4730
__all__ = [
4831
"TestWithScenarios",
4932
"WithScenarios",
@@ -53,6 +36,7 @@
5336
"load_tests_apply_scenarios",
5437
"multiply_scenarios",
5538
"per_module_scenarios",
39+
"__version__",
5640
]
5741

5842

@@ -76,3 +60,53 @@ def test_suite():
7660
def load_tests(standard_tests, module, loader):
7761
standard_tests.addTests(loader.loadTestsFromNames(["testscenarios.tests"]))
7862
return standard_tests
63+
64+
65+
def __get_git_version():
66+
import os
67+
import subprocess
68+
69+
cwd = os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir)
70+
71+
try:
72+
out = subprocess.check_output(
73+
["git", "describe"], stderr=subprocess.STDOUT, cwd=cwd
74+
)
75+
except (OSError, subprocess.CalledProcessError):
76+
return None
77+
78+
try:
79+
version = out.strip().decode("utf-8")
80+
except UnicodeDecodeError:
81+
return None
82+
83+
if "-" in version: # after tag
84+
# convert version-N-githash to version.postN+githash
85+
return version.replace("-", ".post", 1).replace("-g", "+git", 1)
86+
else:
87+
return version
88+
89+
90+
# same format as sys.version_info: "A tuple containing the five components of
91+
# the version number: major, minor, micro, releaselevel, and serial. All
92+
# values except releaselevel are integers; the release level is 'alpha',
93+
# 'beta', 'candidate', or 'final'. The version_info value corresponding to the
94+
# Python version 2.0 is (2, 0, 0, 'final', 0)." Additionally we use a
95+
# releaselevel of 'dev' for unreleased under-development code.
96+
#
97+
# If the releaselevel is 'alpha' then the major/minor/micro components are not
98+
# established at this point, and setup.py will use a version of next-$(revno).
99+
# If the releaselevel is 'final', then the tarball will be major.minor.micro.
100+
# Otherwise it is major.minor.micro~$(revno).
101+
102+
try:
103+
from ._version import __version__, version
104+
except ModuleNotFoundError:
105+
# package is not installed
106+
if version := __get_git_version():
107+
# we're in a git repo
108+
__version__ = tuple([int(v) if v.isdigit() else v for v in version.split(".")])
109+
else:
110+
# we're working with a tarball or similar
111+
version = "0.0.0"
112+
__version__ = (0, 0, 0)

testscenarios/tests/test_scenarios.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def test_load_tests_apply_scenarios(self):
204204
unittest.TestLoader(), [self.SampleTest("test_nothing")], None
205205
)
206206
result_tests = list(testtools.iterate_tests(suite))
207-
self.assertEquals(2, len(result_tests), result_tests)
207+
self.assertEqual(2, len(result_tests), result_tests)
208208

209209
def test_load_tests_apply_scenarios_old_style(self):
210210
"""Call load_tests in the way used by bzr."""
@@ -214,7 +214,7 @@ def test_load_tests_apply_scenarios_old_style(self):
214214
unittest.TestLoader(),
215215
)
216216
result_tests = list(testtools.iterate_tests(suite))
217-
self.assertEquals(2, len(result_tests), result_tests)
217+
self.assertEqual(2, len(result_tests), result_tests)
218218

219219

220220
class TestMultiplyScenarios(testtools.TestCase):

0 commit comments

Comments
 (0)