qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC qemu.qmp PATCH 16/24] Add setuptools_scm package versioning


From: John Snow
Subject: [RFC qemu.qmp PATCH 16/24] Add setuptools_scm package versioning
Date: Wed, 15 Dec 2021 16:06:26 -0500

The version number will now be generated using the setuptools_scm
package, which pulls the version number from git tags.

As PEP660 is not yet usable with pyproject.toml style packages, we will
be sticking to setup.py style installation for now.

"version = 0.0.0" exists as a fallback in the event that the
build/installation environment does not have setuptools_scm
installed. Further, if setuptools_scm *is* installed but we are trying
to install directly from a source tarball (instead of from a python
source distribution), 'fallback_version': '0.0.0' will be utilized as
the fallback.

Lastly, tag this release as v0.0.0 to give setuptools_scm something to
work with and establish precedent for future releases.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 .gitlab-ci.d/build.yml         |  2 +-
 .gitlab-ci.d/python.Dockerfile |  1 +
 INDEX.rst                      |  2 --
 MANIFEST.in                    |  1 -
 VERSION                        |  1 -
 setup.cfg                      |  3 ++-
 setup.py                       | 11 ++++++++++-
 7 files changed, 14 insertions(+), 7 deletions(-)
 delete mode 100644 VERSION

diff --git a/.gitlab-ci.d/build.yml b/.gitlab-ci.d/build.yml
index 6a68408..bf2d487 100644
--- a/.gitlab-ci.d/build.yml
+++ b/.gitlab-ci.d/build.yml
@@ -10,4 +10,4 @@ build-package:
     paths:
       - dist/*
   variables:
-    GIT_DEPTH: 1
+    GIT_DEPTH: 0
\ No newline at end of file
diff --git a/.gitlab-ci.d/python.Dockerfile b/.gitlab-ci.d/python.Dockerfile
index 35d84f3..93661b2 100644
--- a/.gitlab-ci.d/python.Dockerfile
+++ b/.gitlab-ci.d/python.Dockerfile
@@ -25,6 +25,7 @@ RUN dnf --setopt=install_weak_deps=False install -y \
     && python3 -m pip install --upgrade \
         build \
         pip \
+        setuptools_scm \
         twine \
     && dnf clean all \
     && rm -rf ~/.cache/pip \
diff --git a/INDEX.rst b/INDEX.rst
index 8b7a56a..dddfcde 100644
--- a/INDEX.rst
+++ b/INDEX.rst
@@ -62,5 +62,3 @@ Files in this directory
 - ``README.rst`` is used as the README file that is visible on PyPI.org.
 - ``setup.cfg`` houses setuptools package configuration.
 - ``setup.py`` is the setuptools installer used by pip; See above.
-- ``VERSION`` contains the PEP-440 compliant version used to describe
-  this package; it is referenced by ``setup.cfg``.
diff --git a/MANIFEST.in b/MANIFEST.in
index 2a3fc58..9561fb1 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,2 +1 @@
-include VERSION
 include README.rst
diff --git a/VERSION b/VERSION
deleted file mode 100644
index 7741e1a..0000000
--- a/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-0.0.0a1
diff --git a/setup.cfg b/setup.cfg
index f4a02d6..03dd4f0 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
 [metadata]
 name = qemu.qmp
-version = file:VERSION
+version = 0.0.0
 author = John Snow
 author_email = jsnow@redhat.com
 maintainer = QEMU Project
@@ -26,6 +26,7 @@ classifiers =
     Typing :: Typed
 
 [options]
+setup_requires = setuptools_scm
 python_requires = >= 3.6
 packages =
     qemu.qmp
diff --git a/setup.py b/setup.py
index cb9b9b6..5904d07 100755
--- a/setup.py
+++ b/setup.py
@@ -7,6 +7,12 @@ Copyright (c) 2020-2021 John Snow for Red Hat, Inc.
 import setuptools
 import pkg_resources
 
+try:
+    import setuptools_scm
+    _HAVE_SCM = True
+except ModuleNotFoundError:
+    _HAVE_SCM = False
+
 
 def main():
     """
@@ -16,7 +22,10 @@ def main():
     # 
https://medium.com/@daveshawley/safely-using-setup-cfg-for-metadata-1babbe54c108
     pkg_resources.require('setuptools>=39.2')
 
-    setuptools.setup()
+    if _HAVE_SCM:
+        setuptools.setup(use_scm_version={'fallback_version': '0.0.0'})
+    else:
+        setuptools.setup()
 
 
 if __name__ == '__main__':
-- 
2.31.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]