diff options
| author | Monty Taylor <mordred@inaugust.com> | 2012-05-05 12:01:18 -0700 |
|---|---|---|
| committer | Monty Taylor <mordred@inaugust.com> | 2012-05-06 11:42:56 -0700 |
| commit | 5b0b59ed56abcd08b5a3f7fcf1af8639f9ef0a7c (patch) | |
| tree | 4105cd12c4764e67cabbc50038b14b6c8fcd238b /openstack/common | |
| parent | cf0a8a78b33bcdc6694af87fdd978ef4d9616c14 (diff) | |
| download | oslo-5b0b59ed56abcd08b5a3f7fcf1af8639f9ef0a7c.tar.gz oslo-5b0b59ed56abcd08b5a3f7fcf1af8639f9ef0a7c.tar.xz oslo-5b0b59ed56abcd08b5a3f7fcf1af8639f9ef0a7c.zip | |
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 'openstack/common')
| -rw-r--r-- | openstack/common/setup.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/openstack/common/setup.py b/openstack/common/setup.py index 2c16b5b..4017890 100644 --- a/openstack/common/setup.py +++ b/openstack/common/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 |
