Sync with oslo-incubator ad93e4e3
Change-Id: Id85b0862e3813cf93fbf49c06df04ae34835bfc2
This commit is contained in:
@@ -276,6 +276,9 @@ def get_cmdclass():
|
|||||||
from sphinx.setup_command import BuildDoc
|
from sphinx.setup_command import BuildDoc
|
||||||
|
|
||||||
class LocalBuildDoc(BuildDoc):
|
class LocalBuildDoc(BuildDoc):
|
||||||
|
|
||||||
|
builders = ['html', 'man']
|
||||||
|
|
||||||
def generate_autoindex(self):
|
def generate_autoindex(self):
|
||||||
print "**Autodocumenting from %s" % os.path.abspath(os.curdir)
|
print "**Autodocumenting from %s" % os.path.abspath(os.curdir)
|
||||||
modules = {}
|
modules = {}
|
||||||
@@ -311,14 +314,19 @@ def get_cmdclass():
|
|||||||
if not os.getenv('SPHINX_DEBUG'):
|
if not os.getenv('SPHINX_DEBUG'):
|
||||||
self.generate_autoindex()
|
self.generate_autoindex()
|
||||||
|
|
||||||
for builder in ['html', 'man']:
|
for builder in self.builders:
|
||||||
self.builder = builder
|
self.builder = builder
|
||||||
self.finalize_options()
|
self.finalize_options()
|
||||||
self.project = self.distribution.get_name()
|
self.project = self.distribution.get_name()
|
||||||
self.version = self.distribution.get_version()
|
self.version = self.distribution.get_version()
|
||||||
self.release = self.distribution.get_version()
|
self.release = self.distribution.get_version()
|
||||||
BuildDoc.run(self)
|
BuildDoc.run(self)
|
||||||
|
|
||||||
|
class LocalBuildLatex(LocalBuildDoc):
|
||||||
|
builders = ['latex']
|
||||||
|
|
||||||
cmdclass['build_sphinx'] = LocalBuildDoc
|
cmdclass['build_sphinx'] = LocalBuildDoc
|
||||||
|
cmdclass['build_sphinx_latex'] = LocalBuildLatex
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -24,39 +24,6 @@ import pkg_resources
|
|||||||
import setup
|
import setup
|
||||||
|
|
||||||
|
|
||||||
class _deferred_version_string(str):
|
|
||||||
"""Internal helper class which provides delayed version calculation."""
|
|
||||||
|
|
||||||
def __new__(cls, version_info, prefix):
|
|
||||||
new_obj = str.__new__(cls, "")
|
|
||||||
new_obj._version_info = version_info
|
|
||||||
new_obj._prefix = prefix
|
|
||||||
new_obj._cached_version = None
|
|
||||||
return new_obj
|
|
||||||
|
|
||||||
def _get_cached_version(self):
|
|
||||||
if not self._cached_version:
|
|
||||||
self._cached_version = \
|
|
||||||
"%s%s" % (self._prefix,
|
|
||||||
self._version_info.version_string())
|
|
||||||
return self._cached_version
|
|
||||||
|
|
||||||
def __len__(self):
|
|
||||||
return self._get_cached_version().__len__()
|
|
||||||
|
|
||||||
def __contains__(self, item):
|
|
||||||
return self._get_cached_version().__contains__(item)
|
|
||||||
|
|
||||||
def __getslice__(self, i, j):
|
|
||||||
return self._get_cached_version().__getslice__(i, j)
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self._get_cached_version()
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return self._get_cached_version()
|
|
||||||
|
|
||||||
|
|
||||||
class VersionInfo(object):
|
class VersionInfo(object):
|
||||||
|
|
||||||
def __init__(self, package, python_package=None, pre_version=None):
|
def __init__(self, package, python_package=None, pre_version=None):
|
||||||
@@ -77,6 +44,7 @@ class VersionInfo(object):
|
|||||||
self.python_package = python_package
|
self.python_package = python_package
|
||||||
self.pre_version = pre_version
|
self.pre_version = pre_version
|
||||||
self.version = None
|
self.version = None
|
||||||
|
self._cached_version = None
|
||||||
|
|
||||||
def _generate_version(self):
|
def _generate_version(self):
|
||||||
"""Defer to the openstack.common.setup routines for making a
|
"""Defer to the openstack.common.setup routines for making a
|
||||||
@@ -158,11 +126,14 @@ class VersionInfo(object):
|
|||||||
else:
|
else:
|
||||||
return '%s-dev' % (version_parts[0],)
|
return '%s-dev' % (version_parts[0],)
|
||||||
|
|
||||||
def deferred_version_string(self, prefix=""):
|
def cached_version_string(self, prefix=""):
|
||||||
"""Generate an object which will expand in a string context to
|
"""Generate an object which will expand in a string context to
|
||||||
the results of version_string(). We do this so that don't
|
the results of version_string(). We do this so that don't
|
||||||
call into pkg_resources every time we start up a program when
|
call into pkg_resources every time we start up a program when
|
||||||
passing version information into the CONF constructor, but
|
passing version information into the CONF constructor, but
|
||||||
rather only do the calculation when and if a version is requested
|
rather only do the calculation when and if a version is requested
|
||||||
"""
|
"""
|
||||||
return _deferred_version_string(self, prefix)
|
if not self._cached_version:
|
||||||
|
self._cached_version = "%s%s" % (prefix,
|
||||||
|
self.version_string())
|
||||||
|
return self._cached_version
|
||||||
|
|||||||
Reference in New Issue
Block a user