From c84876dc0f559a66fec19b2f81f5717204b253e2 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sun, 21 Jul 2013 09:35:17 -0700 Subject: [PATCH] Remove the need to specify the pbr hook If you're running pbr codepaths, you want the hook. There is no need to say "pbr=True" in setup.py and then to list the hook in setup.cfg now that d2to1 is in the tree. Change-Id: Ie33d3e08d5a4133f5caf2613859919ce4f02c4a0 --- README.rst | 3 --- pbr/tests/__init__.py | 1 + pbr/util.py | 8 +++++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 09e4135c..ecdbb9aa 100644 --- a/README.rst +++ b/README.rst @@ -124,9 +124,6 @@ A simple sample can be found in pbr s own setup.cfg [files] packages = oslo - [hooks] - setup-hooks = - pbr.hooks.setup_hook The minimal setup.py should look something like this:: diff --git a/pbr/tests/__init__.py b/pbr/tests/__init__.py index 5109b0f2..a4874c34 100644 --- a/pbr/tests/__init__.py +++ b/pbr/tests/__init__.py @@ -79,6 +79,7 @@ class BaseTestCase(testtools.TestCase, testresources.ResourcedTestCase): self.useFixture(fixtures.NestedTempfile()) self.useFixture(fixtures.FakeLogger()) + self.useFixture(fixtures.EnvironmentVariable('PBR_VERSION', '0.0')) self.temp_dir = self.useFixture(fixtures.TempDir()).path self.package_dir = os.path.join(self.temp_dir, 'testpackage') diff --git a/pbr/util.py b/pbr/util.py index 353635ea..3faa58e6 100644 --- a/pbr/util.py +++ b/pbr/util.py @@ -77,6 +77,7 @@ try: except ImportError: import ConfigParser as configparser +import pbr.hooks # A simplified RE for this; just checks that the line ends with version # predicates in () @@ -219,7 +220,9 @@ def cfg_to_args(path='setup.cfg'): try: if setup_hooks: - setup_hooks = split_multiline(setup_hooks) + setup_hooks = [ + hook for hook in split_multiline(setup_hooks) + if hook != 'pbr.hook.setup_hook'] for hook in setup_hooks: hook_fn = resolve_name(hook) try : @@ -233,6 +236,9 @@ def cfg_to_args(path='setup.cfg'): log.error(traceback.format_exc()) sys.exit(1) + # Run the pbr hook + pbr.hooks.setup_hook(config) + kwargs = setup_cfg_to_setup_kwargs(config) # Set default config overrides