summaryrefslogtreecommitdiff
path: root/pbr/packaging.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2015-06-26 12:07:39 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2015-07-02 04:52:14 +0000
commit826380603382e4aa2d1eb57649da91dd3ba4e0a5 (patch)
tree6bf8f8a6a38b11e66571f87123ac377310186f5d /pbr/packaging.py
parent5039c9a3f81f5a5ee3fc92c37bebc1c7573a3c74 (diff)
downloadpbr-826380603382e4aa2d1eb57649da91dd3ba4e0a5.tar.gz
Expose a 'rpm_version' extra command
Intended usage, getting a rpm *compatible* version number from pbr from a pbr using python package. Typically this will then get put into a rpm spec file (what is used to build an rpm) and used to build an rpm using `rpmbuild` (the thing used to translate rpm spec files into rpms). For example: this allows [1][2] (which I am the primary maintainer of and godaddy, cray, and y! are users of) to get out of the whacky and/or flakey rpm version number calculation/conversion process (which previously just worked around by saying only use tags). [1] https://github.com/stackforge/anvil [2] https://anvil.readthedocs.org/en/latest/topics/summary.html Change-Id: I26cd1d6e8aef69d52e8a4f36bd264c690e712ba3
Diffstat (limited to 'pbr/packaging.py')
-rw-r--r--pbr/packaging.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/pbr/packaging.py b/pbr/packaging.py
index ebdfb09..3ab930f 100644
--- a/pbr/packaging.py
+++ b/pbr/packaging.py
@@ -28,6 +28,7 @@ import re
import sys
import pkg_resources
+import setuptools
from setuptools.command import develop
from setuptools.command import easy_install
from setuptools.command import egg_info
@@ -187,6 +188,25 @@ class TestrTest(testr_command.Testr):
testr_command.Testr.run(self)
+class LocalRPMVersion(setuptools.Command):
+ __doc__ = """Output the rpm *compatible* version string of this package"""
+ description = __doc__
+
+ user_options = []
+ command_name = "rpm_version"
+
+ def run(self):
+ log.info("[pbr] Extracting rpm version")
+ name = self.distribution.get_name()
+ print(version.VersionInfo(name).semantic_version().rpm_string())
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
+
+
def have_testr():
return testr_command.have_testr