Utilize newer changes in openstack-common.
Use common.setup.get_cmdclass() to clean-up redundant code. * keystone/openstack/common/setup.py Sync from openstack-common project. * setup.py Code clean-up. No functional change. Change-Id: I12f538ba8e727270b3b615dc06b0fd0328f36e1e
This commit is contained in:
parent
991a6182e0
commit
94f45dac51
@ -23,6 +23,8 @@ import os
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
from setuptools.command import sdist
|
||||
|
||||
|
||||
def parse_mailmap(mailmap='.mailmap'):
|
||||
mapping = {}
|
||||
@ -48,6 +50,7 @@ def canonicalize_emails(changelog, mapping):
|
||||
|
||||
# Get requirements from the first file that exists
|
||||
def get_reqs_from_files(requirements_files):
|
||||
reqs_in = []
|
||||
for requirements_file in requirements_files:
|
||||
if os.path.exists(requirements_file):
|
||||
return open(requirements_file, 'r').read().split('\n')
|
||||
@ -143,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
|
||||
|
32
setup.py
32
setup.py
@ -15,41 +15,13 @@
|
||||
# under the License.
|
||||
|
||||
from setuptools import find_packages
|
||||
from setuptools.command.sdist import sdist
|
||||
from setuptools import setup
|
||||
import subprocess
|
||||
|
||||
from keystone.openstack.common.setup import generate_authors
|
||||
from keystone.openstack.common.setup import get_cmdclass
|
||||
from keystone.openstack.common.setup import parse_requirements
|
||||
from keystone.openstack.common.setup import parse_dependency_links
|
||||
from keystone.openstack.common.setup import write_requirements
|
||||
from keystone.openstack.common.setup import write_git_changelog
|
||||
|
||||
|
||||
class local_sdist(sdist):
|
||||
"""Customized sdist hook - builds the ChangeLog file from VC first"""
|
||||
def run(self):
|
||||
write_git_changelog()
|
||||
generate_authors()
|
||||
sdist.run(self)
|
||||
cmdclass = {'sdist': local_sdist}
|
||||
|
||||
|
||||
try:
|
||||
from sphinx.setup_command import BuildDoc
|
||||
|
||||
class local_BuildDoc(BuildDoc):
|
||||
def run(self):
|
||||
subprocess.call('sphinx-apidoc -f -o doc/source keystone',
|
||||
shell=True)
|
||||
for builder in ['html', 'man']:
|
||||
self.builder = builder
|
||||
self.finalize_options()
|
||||
BuildDoc.run(self)
|
||||
cmdclass['build_sphinx'] = local_BuildDoc
|
||||
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
requires = parse_requirements()
|
||||
@ -64,7 +36,7 @@ setup(name='keystone',
|
||||
author='OpenStack, LLC.',
|
||||
author_email='openstack@lists.launchpad.net',
|
||||
url='http://www.openstack.org',
|
||||
cmdclass=cmdclass,
|
||||
cmdclass=get_cmdclass(),
|
||||
packages=find_packages(exclude=['test', 'bin']),
|
||||
include_package_data=True,
|
||||
scripts=['bin/keystone-all', 'bin/keystone-manage'],
|
||||
|
Loading…
x
Reference in New Issue
Block a user