]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Modernized versioning
authorZack Cerza <zack@redhat.com>
Thu, 31 Mar 2022 19:32:14 +0000 (15:32 -0400)
committerZack Cerza <zack@redhat.com>
Tue, 19 Apr 2022 21:31:07 +0000 (15:31 -0600)
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 <zack@redhat.com>
pyproject.toml
setup.cfg
teuthology/__init__.py

index b0f076532a06d9d7b19e62dd4310fbf33a853ecf..ece6fe5f5191f10f39563d14f0342921a6598f17 100644 (file)
@@ -1,3 +1,10 @@
 [build-system]
-requires = ["setuptools>=42"]
 build-backend = "setuptools.build_meta"
+requires = [
+    "setuptools>=45",
+    "wheel",
+    "setuptools_scm>=6.2",
+]
+
+[tool.setuptools_scm]
+version_scheme = "python-simplified-semver"
\ No newline at end of file
index 0de92b8a1e226984eb41a94ec5e6a6835e7700a0..4bfdfab5dcee26e4dc358420ba2c708f01a9285f 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,5 @@
 [metadata]
 name = teuthology
-version = attr: teuthology.__version__
 long_description = file: README.rst
 long_description_content_type = text/x-rst
 url = https://github.com/ceph/teuthology
index 2ef5aeb144d0dbdabb2400dd1cdf09e67ec5fea5..4781f59bc13c84b75bba5065a9840bffdf20b33b 100644 (file)
@@ -1,5 +1,11 @@
 from __future__ import print_function
 import os
+try:
+    import importlib.metadata as importlib_metadata
+except ImportError:
+    import importlib_metadata
+
+__version__ = importlib_metadata.version("teuthology")
 
 # Tell gevent not to patch os.waitpid() since it is susceptible to race
 # conditions. See:
@@ -33,25 +39,6 @@ from teuthology.orchestra import monkey
 monkey.patch_all()
 
 import logging
-import subprocess
-
-__version__ = '1.1.0'
-
-# do our best, but if it fails, continue with above
-
-try:
-    teuthology_dir = os.path.dirname(os.path.realpath(__file__))
-    site_dir = os.path.dirname(teuthology_dir)
-    git_dir = os.path.join(site_dir, '.git')
-    # make sure we use git repo otherwise it is a released version
-    if os.path.exists(git_dir):
-        __version__ += '-' + str(subprocess.check_output(
-            'git rev-parse --short HEAD'.split(),
-            cwd=site_dir
-        ).decode()).strip()
-except Exception as e:
-    # before logging; should be unusual
-    print("Can't get version from git rev-parse %s" % e, file=sys.stderr)
 
 # If we are running inside a virtualenv, ensure we have its 'bin' directory in
 # our PATH. This doesn't happen automatically if scripts are called without