Skip to content

Commit c376302

Browse files
committed
Modernized versioning
Using setuptools_scm; we can automatically generate version numbers instead of using this odd combination of hardcoding and running git commands. This method is faster as well. Signed-off-by: Zack Cerza <[email protected]>
1 parent 9602115 commit c376302

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

pyproject.toml

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
[build-system]
2-
requires = ["setuptools>=42"]
32
build-backend = "setuptools.build_meta"
3+
requires = [
4+
"setuptools>=45",
5+
"wheel",
6+
"setuptools_scm>=6.2",
7+
]
8+
9+
[tool.setuptools_scm]
10+
version_scheme = "python-simplified-semver"

setup.cfg

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[metadata]
22
name = teuthology
3-
version = attr: teuthology.__version__
43
long_description = file: README.rst
54
long_description_content_type = text/x-rst
65
url = https://github.com/ceph/teuthology

teuthology/__init__.py

+6-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
from __future__ import print_function
22
import os
3+
try:
4+
import importlib.metadata as importlib_metadata
5+
except ImportError:
6+
import importlib_metadata
7+
8+
__version__ = importlib_metadata.version("teuthology")
39

410
# Tell gevent not to patch os.waitpid() since it is susceptible to race
511
# conditions. See:
@@ -33,25 +39,6 @@
3339
monkey.patch_all()
3440

3541
import logging
36-
import subprocess
37-
38-
__version__ = '1.1.0'
39-
40-
# do our best, but if it fails, continue with above
41-
42-
try:
43-
teuthology_dir = os.path.dirname(os.path.realpath(__file__))
44-
site_dir = os.path.dirname(teuthology_dir)
45-
git_dir = os.path.join(site_dir, '.git')
46-
# make sure we use git repo otherwise it is a released version
47-
if os.path.exists(git_dir):
48-
__version__ += '-' + str(subprocess.check_output(
49-
'git rev-parse --short HEAD'.split(),
50-
cwd=site_dir
51-
).decode()).strip()
52-
except Exception as e:
53-
# before logging; should be unusual
54-
print("Can't get version from git rev-parse %s" % e, file=sys.stderr)
5542

5643
# If we are running inside a virtualenv, ensure we have its 'bin' directory in
5744
# our PATH. This doesn't happen automatically if scripts are called without

0 commit comments

Comments
 (0)