Export ChangeLog and AUTHORS in install
readthedocs uses 'setup.py install' to prepare trees for doc creation, but ChangeLog is not currently created there, and doing so would be nice. This won't affect develop invocations AFAICT, and even if it did, the overheads are ~10% of the time to run 0 tests in Nova today - e.g. quite tolerable. Change-Id: I7bc18fc9ca2dbe852598cc79b2ad6273fc53557d
This commit is contained in:
parent
1f102e60d7
commit
89402a7177
|
@ -61,3 +61,5 @@ class CommandsConfig(base.BaseConfig):
|
|||
# We always want non-egg install unless explicitly requested
|
||||
if 'manpages' in self.pbr_config or not use_egg:
|
||||
self.add_command('pbr.packaging.LocalInstall')
|
||||
else:
|
||||
self.add_command('pbr.packaging.InstallWithGit')
|
||||
|
|
|
@ -163,6 +163,20 @@ def parse_dependency_links(requirements_files=None):
|
|||
return dependency_links
|
||||
|
||||
|
||||
class InstallWithGit(install.install):
|
||||
"""Extracts ChangeLog and AUTHORS from git then installs.
|
||||
|
||||
This is useful for e.g. readthedocs where the package is
|
||||
installed and then docs built.
|
||||
"""
|
||||
|
||||
command_name = 'install'
|
||||
|
||||
def run(self):
|
||||
_from_git(self.distribution)
|
||||
return install.install.run(self)
|
||||
|
||||
|
||||
class LocalInstall(install.install):
|
||||
"""Runs python setup.py install in a sensible manner.
|
||||
|
||||
|
@ -174,6 +188,7 @@ class LocalInstall(install.install):
|
|||
command_name = 'install'
|
||||
|
||||
def run(self):
|
||||
_from_git(self.distribution)
|
||||
return du_install.install.run(self)
|
||||
|
||||
|
||||
|
@ -397,18 +412,22 @@ class LocalEggInfo(egg_info.egg_info):
|
|||
self.filelist.append(entry)
|
||||
|
||||
|
||||
def _from_git(distribution):
|
||||
option_dict = distribution.get_option_dict('pbr')
|
||||
changelog = git._iter_log_oneline(option_dict=option_dict)
|
||||
if changelog:
|
||||
changelog = git._iter_changelog(changelog)
|
||||
git.write_git_changelog(option_dict=option_dict, changelog=changelog)
|
||||
git.generate_authors(option_dict=option_dict)
|
||||
|
||||
|
||||
class LocalSDist(sdist.sdist):
|
||||
"""Builds the ChangeLog and Authors files from VC first."""
|
||||
|
||||
command_name = 'sdist'
|
||||
|
||||
def run(self):
|
||||
option_dict = self.distribution.get_option_dict('pbr')
|
||||
changelog = git._iter_log_oneline(option_dict=option_dict)
|
||||
if changelog:
|
||||
changelog = git._iter_changelog(changelog)
|
||||
git.write_git_changelog(option_dict=option_dict, changelog=changelog)
|
||||
git.generate_authors(option_dict=option_dict)
|
||||
_from_git(self.distribution)
|
||||
# sdist.sdist is an old style class, can't use super()
|
||||
sdist.sdist.run(self)
|
||||
|
||||
|
|
|
@ -156,21 +156,23 @@ class TestPackagingInGitRepoWithCommit(base.BaseTestCase):
|
|||
super(TestPackagingInGitRepoWithCommit, self).setUp()
|
||||
repo = self.useFixture(TestRepo(self.package_dir))
|
||||
repo.commit()
|
||||
self.run_setup('sdist', allow_fail=False)
|
||||
|
||||
def test_authors(self):
|
||||
self.run_setup('sdist', allow_fail=False)
|
||||
# One commit, something should be in the authors list
|
||||
with open(os.path.join(self.package_dir, 'AUTHORS'), 'r') as f:
|
||||
body = f.read()
|
||||
self.assertNotEqual(body, '')
|
||||
|
||||
def test_changelog(self):
|
||||
self.run_setup('sdist', allow_fail=False)
|
||||
with open(os.path.join(self.package_dir, 'ChangeLog'), 'r') as f:
|
||||
body = f.read()
|
||||
# One commit, something should be in the ChangeLog list
|
||||
self.assertNotEqual(body, '')
|
||||
|
||||
def test_manifest_exclude_honoured(self):
|
||||
self.run_setup('sdist', allow_fail=False)
|
||||
with open(os.path.join(
|
||||
self.package_dir,
|
||||
'pbr_testpackage.egg-info/SOURCES.txt'), 'r') as f:
|
||||
|
@ -179,6 +181,12 @@ class TestPackagingInGitRepoWithCommit(base.BaseTestCase):
|
|||
body, matchers.Not(matchers.Contains('pbr_testpackage/extra.py')))
|
||||
self.assertThat(body, matchers.Contains('pbr_testpackage/__init__.py'))
|
||||
|
||||
def test_install_writes_changelog(self):
|
||||
stdout, _, _ = self.run_setup(
|
||||
'install', '--root', self.temp_dir + 'installed',
|
||||
allow_fail=False)
|
||||
self.expectThat(stdout, matchers.Contains('Generating ChangeLog'))
|
||||
|
||||
|
||||
class TestPackagingInGitRepoWithoutCommit(base.BaseTestCase):
|
||||
|
||||
|
@ -204,18 +212,26 @@ class TestPackagingInPlainDirectory(base.BaseTestCase):
|
|||
|
||||
def setUp(self):
|
||||
super(TestPackagingInPlainDirectory, self).setUp()
|
||||
self.run_setup('sdist', allow_fail=False)
|
||||
|
||||
def test_authors(self):
|
||||
self.run_setup('sdist', allow_fail=False)
|
||||
# Not a git repo, no AUTHORS file created
|
||||
filename = os.path.join(self.package_dir, 'AUTHORS')
|
||||
self.assertFalse(os.path.exists(filename))
|
||||
|
||||
def test_changelog(self):
|
||||
self.run_setup('sdist', allow_fail=False)
|
||||
# Not a git repo, no ChangeLog created
|
||||
filename = os.path.join(self.package_dir, 'ChangeLog')
|
||||
self.assertFalse(os.path.exists(filename))
|
||||
|
||||
def test_install_no_ChangeLog(self):
|
||||
stdout, _, _ = self.run_setup(
|
||||
'install', '--root', self.temp_dir + 'installed',
|
||||
allow_fail=False)
|
||||
self.expectThat(
|
||||
stdout, matchers.Not(matchers.Contains('Generating ChangeLog')))
|
||||
|
||||
|
||||
class TestPresenceOfGit(base.BaseTestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue