summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2012-05-05 12:01:18 -0700
committerMonty Taylor <mordred@inaugust.com>2012-05-06 11:42:56 -0700
commit03893be94bdb95b051a00412357adce6ddec1322 (patch)
tree05e789c9f8c91e174ae25b67fc6f1fafbb81f053 /setup.py
parent51c2ee33fe1388536526015acbef51cf5899b3d0 (diff)
downloadpbr-03893be94bdb95b051a00412357adce6ddec1322.tar.gz
Encapsulate common sdist actions into a cmdclass.
The pattern of running generate_authors and write_git_changelog at sdist time is (and should be) repeated in all project's setup.py. Instead of copying the creation of the two classes and injection of them into a cmdclass dict, we can do it here and have it be consistent. Related to bug 986462. Change-Id: I0b7b44d58685551482f874b2a6091dec29e6bed6
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/setup.py b/setup.py
index 2c16b5b..4017890 100644
--- a/setup.py
+++ b/setup.py
@@ -23,6 +23,8 @@ import os
import re
import subprocess
+from setuptools.command import sdist
+
def parse_mailmap(mailmap='.mailmap'):
mapping = {}
@@ -144,3 +146,38 @@ def generate_authors():
if os.path.exists(old_authors):
with open(old_authors, "r") as old_authors_fh:
new_authors_fh.write('\n' + old_authors_fh.read())
+
+
+def get_cmdclass():
+ """Return dict of commands to run from setup.py."""
+
+ cmdclass = dict()
+
+ class LocalSDist(sdist.sdist):
+ """Builds the ChangeLog and Authors files from VC first."""
+
+ def run(self):
+ write_git_changelog()
+ generate_authors()
+ # sdist.sdist is an old style class, can't use super()
+ sdist.sdist.run(self)
+
+ cmdclass['sdist'] = LocalSDist
+
+ # If Sphinx is installed on the box running setup.py,
+ # enable setup.py to build the documentation, otherwise,
+ # just ignore it
+ try:
+ from sphinx.setup_command import BuildDoc
+
+ class LocalBuildDoc(BuildDoc):
+ def run(self):
+ for builder in ['html', 'man']:
+ self.builder = builder
+ self.finalize_options()
+ BuildDoc.run(self)
+ cmdclass['build_sphinx'] = LocalBuildDoc
+ except ImportError:
+ pass
+
+ return cmdclass