Use sdist cmdclass from openstack-common.
Change-Id: I6f970cb61929d32fa121c1bc1209fc1fef1d572d
This commit is contained in:
parent
6d15a2debb
commit
f879081427
|
@ -23,6 +23,8 @@ import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from setuptools.command import sdist
|
||||||
|
|
||||||
|
|
||||||
def parse_mailmap(mailmap='.mailmap'):
|
def parse_mailmap(mailmap='.mailmap'):
|
||||||
mapping = {}
|
mapping = {}
|
||||||
|
@ -31,7 +33,8 @@ def parse_mailmap(mailmap='.mailmap'):
|
||||||
for l in fp:
|
for l in fp:
|
||||||
l = l.strip()
|
l = l.strip()
|
||||||
if not l.startswith('#') and ' ' in l:
|
if not l.startswith('#') and ' ' in l:
|
||||||
canonical_email, alias = l.split(' ')
|
canonical_email, alias = [x for x in l.split(' ') \
|
||||||
|
if x.startswith('<')]
|
||||||
mapping[alias] = canonical_email
|
mapping[alias] = canonical_email
|
||||||
return mapping
|
return mapping
|
||||||
|
|
||||||
|
@ -143,3 +146,38 @@ def generate_authors():
|
||||||
if os.path.exists(old_authors):
|
if os.path.exists(old_authors):
|
||||||
with open(old_authors, "r") as old_authors_fh:
|
with open(old_authors, "r") as old_authors_fh:
|
||||||
new_authors_fh.write('\n' + old_authors_fh.read())
|
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
|
||||||
|
|
55
setup.py
55
setup.py
|
@ -14,55 +14,24 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import gettext
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from setuptools import setup, find_packages
|
import setuptools
|
||||||
from setuptools.command.sdist import sdist
|
from setuptools.command import sdist
|
||||||
|
|
||||||
from glance.openstack.common.setup import generate_authors
|
from glance.openstack.common import setup
|
||||||
from glance.openstack.common.setup import parse_dependency_links
|
|
||||||
from glance.openstack.common.setup import parse_requirements
|
|
||||||
from glance.openstack.common.setup import write_git_changelog
|
|
||||||
from glance.openstack.common.setup import write_vcsversion
|
|
||||||
|
|
||||||
gettext.install('glance', unicode=1)
|
setup.write_vcsversion('glance/vcsversion.py')
|
||||||
|
|
||||||
|
|
||||||
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}
|
|
||||||
|
|
||||||
# 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 local_BuildDoc(BuildDoc):
|
|
||||||
def run(self):
|
|
||||||
for builder in ['html', 'man']:
|
|
||||||
self.builder = builder
|
|
||||||
self.finalize_options()
|
|
||||||
BuildDoc.run(self)
|
|
||||||
cmdclass['build_sphinx'] = local_BuildDoc
|
|
||||||
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
requires = parse_requirements()
|
|
||||||
depend_links = parse_dependency_links()
|
|
||||||
write_vcsversion('glance/vcsversion.py')
|
|
||||||
|
|
||||||
|
# import this after write_vcsversion because version imports vcsversion
|
||||||
from glance import version
|
from glance import version
|
||||||
|
|
||||||
setup(
|
|
||||||
|
requires = setup.parse_requirements()
|
||||||
|
depend_links = setup.parse_dependency_links()
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
name='glance',
|
name='glance',
|
||||||
version=version.canonical_version_string(),
|
version=version.canonical_version_string(),
|
||||||
description='The Glance project provides services for discovering, '
|
description='The Glance project provides services for discovering, '
|
||||||
|
@ -71,9 +40,9 @@ setup(
|
||||||
author='OpenStack',
|
author='OpenStack',
|
||||||
author_email='openstack@lists.launchpad.net',
|
author_email='openstack@lists.launchpad.net',
|
||||||
url='http://glance.openstack.org/',
|
url='http://glance.openstack.org/',
|
||||||
packages=find_packages(exclude=['bin']),
|
packages=setuptools.find_packages(exclude=['bin']),
|
||||||
test_suite='nose.collector',
|
test_suite='nose.collector',
|
||||||
cmdclass=cmdclass,
|
cmdclass=setup.get_cmdclass(),
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
install_requires=requires,
|
install_requires=requires,
|
||||||
dependency_links=depend_links,
|
dependency_links=depend_links,
|
||||||
|
|
Loading…
Reference in New Issue