summaryrefslogtreecommitdiff
path: root/pbr/packaging.py
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2017-10-19 10:58:02 +0000
committerGerrit Code Review <review@openstack.org>2017-10-19 10:58:02 +0000
commit721aa9547b26d8f70f240da2343359444281aee3 (patch)
tree0085372b4bfe052ca86c81246a0146b1bed0120c /pbr/packaging.py
parentf450cd26a29e85573697cdd9fdc8279ef0fe8aed (diff)
parent3a6b96c799de732364d414d63d05b10305c9c5ba (diff)
downloadpbr-721aa9547b26d8f70f240da2343359444281aee3.tar.gz
Merge "Use 'build_reno' setuptools extension if available"
Diffstat (limited to 'pbr/packaging.py')
-rw-r--r--pbr/packaging.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/pbr/packaging.py b/pbr/packaging.py
index 6753dc3..99eff52 100644
--- a/pbr/packaging.py
+++ b/pbr/packaging.py
@@ -524,11 +524,57 @@ class LocalSDist(sdist.sdist):
command_name = 'sdist'
+ def checking_reno(self):
+ """Ensure reno is installed and configured.
+
+ We can't run reno-based commands if reno isn't installed/available, and
+ don't want to if the user isn't using it.
+ """
+ if hasattr(self, '_has_reno'):
+ return self._has_reno
+
+ try:
+ # versions of reno witout this module will not have the required
+ # feature, hence the import
+ from reno import setup_command # noqa
+ except ImportError:
+ log.info('[pbr] reno was not found or is too old. Skipping '
+ 'release notes')
+ self._has_reno = False
+ return False
+
+ conf, output_file, cache_file = setup_command.load_config(
+ self.distribution)
+
+ if not os.path.exists(os.path.join(conf.reporoot, conf.notespath)):
+ log.info('[pbr] reno does not appear to be configured. Skipping '
+ 'release notes')
+ self._has_reno = False
+ return False
+
+ self._files = [output_file, cache_file]
+
+ log.info('[pbr] Generating release notes')
+ self._has_reno = True
+
+ return True
+
+ sub_commands = [('build_reno', checking_reno)] + sdist.sdist.sub_commands
+
def run(self):
_from_git(self.distribution)
# sdist.sdist is an old style class, can't use super()
sdist.sdist.run(self)
+ def make_distribution(self):
+ # This is included in make_distribution because setuptools doesn't use
+ # 'get_file_list'. As such, this is the only hook point that runs after
+ # the commands in 'sub_commands'
+ if self.checking_reno():
+ self.filelist.extend(self._files)
+ self.filelist.sort()
+ sdist.sdist.make_distribution(self)
+
try:
from pbr import builddoc
_have_sphinx = True