summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Collins <rbtcollins@hp.com>2015-07-16 12:34:50 +1200
committerRobert Collins <rbtcollins@hp.com>2015-07-29 06:19:40 +1200
commit89402a71776a02c69b67fc14452b82a9a9d85ac0 (patch)
tree57a9d404b042178052fa8d18de3762931c242e21
parent1f102e60d72de4ece80c22c0be5734f74cc3b776 (diff)
downloadpbr-89402a71776a02c69b67fc14452b82a9a9d85ac0.tar.gz
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
-rw-r--r--pbr/hooks/commands.py2
-rw-r--r--pbr/packaging.py31
-rw-r--r--pbr/tests/test_packaging.py20
3 files changed, 45 insertions, 8 deletions
diff --git a/pbr/hooks/commands.py b/pbr/hooks/commands.py
index 8e651e6..216c9a1 100644
--- a/pbr/hooks/commands.py
+++ b/pbr/hooks/commands.py
@@ -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')
diff --git a/pbr/packaging.py b/pbr/packaging.py
index be5eb74..e444165 100644
--- a/pbr/packaging.py
+++ b/pbr/packaging.py
@@ -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)
diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py
index c6b2e7d..24373ab 100644
--- a/pbr/tests/test_packaging.py
+++ b/pbr/tests/test_packaging.py
@@ -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):