summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClark Boylan <clark.boylan@gmail.com>2014-12-19 09:45:16 -0800
committerJeremy Stanley <fungi@yuggoth.org>2014-12-21 22:21:48 +0000
commit3ec9f0e809f8588fd9110f2b0426a495a44e7a2f (patch)
treeee3c4a60967caedc04220bfc6879f09d48e631cd
parent50a43a18d14f4c2acebbd3fb221400224eb56781 (diff)
downloadpbr-3ec9f0e809f8588fd9110f2b0426a495a44e7a2f.tar.gz
Move write_pbr_json to avoid issues with nose
Put write_pbr_json in pbr.pbr_json so that you do not need to import pbr.packaging to use it. This avoids python3 errors with nose where nose is imported by pbr before it is converted to python3 by 2to3 under python3. Change-Id: I1c420fed609bc60bbfdf78eb219e067ccab1a61e
-rw-r--r--pbr/packaging.py22
-rw-r--r--pbr/pbr_json.py32
-rw-r--r--setup.cfg2
3 files changed, 41 insertions, 15 deletions
diff --git a/pbr/packaging.py b/pbr/packaging.py
index 8d41104..c42600e 100644
--- a/pbr/packaging.py
+++ b/pbr/packaging.py
@@ -25,7 +25,6 @@ from distutils import log
import email
import functools
import itertools
-import json
import os
import platform
import re
@@ -41,6 +40,7 @@ from setuptools.command import sdist
from pbr import extra_files
from pbr import git
from pbr import options
+import pbr.pbr_json
from pbr import version
REQUIREMENTS_FILES = ('requirements.txt', 'tools/pip-requires')
@@ -505,19 +505,6 @@ def _get_increment_kwargs(git_dir, tag):
return result
-def write_pbr_json(cmd, basename, filename):
- git_dir = git._run_git_functions()
- if not git_dir:
- return
- values = dict()
- git_version = git.get_git_short_sha(git_dir)
- is_release = git.get_is_release(git_dir)
- if git_version is not None:
- values['git_version'] = git_version
- values['is_release'] = is_release
- cmd.write_file('pbr', filename, json.dumps(values))
-
-
def _get_revno_and_last_tag(git_dir):
"""Return the commit data about the most recent tag.
@@ -671,3 +658,10 @@ def get_version(package_name, pre_version=None):
raise Exception("Versioning for this project requires either an sdist"
" tarball, or access to an upstream git repository."
" Are you sure that git is installed?")
+
+
+# This is added because pbr uses pbr to install itself. That means that
+# any changes to the egg info writer entrypoints must be forward and
+# backward compatible. This maintains the pbr.packaging.write_pbr_json
+# path.
+write_pbr_json = pbr.pbr_json.write_pbr_json
diff --git a/pbr/pbr_json.py b/pbr/pbr_json.py
new file mode 100644
index 0000000..2290103
--- /dev/null
+++ b/pbr/pbr_json.py
@@ -0,0 +1,32 @@
+# Copyright 2011 OpenStack LLC.
+# Copyright 2012-2013 Hewlett-Packard Development Company, L.P.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import json
+
+from pbr import git
+
+
+def write_pbr_json(cmd, basename, filename):
+ git_dir = git._run_git_functions()
+ if not git_dir:
+ return
+ values = dict()
+ git_version = git.get_git_short_sha(git_dir)
+ is_release = git.get_is_release(git_dir)
+ if git_version is not None:
+ values['git_version'] = git_version
+ values['is_release'] = is_release
+ cmd.write_file('pbr', filename, json.dumps(values))
diff --git a/setup.cfg b/setup.cfg
index b217fd3..c2d06e7 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -39,7 +39,7 @@ distutils.setup_keywords =
distutils.commands =
testr = pbr.testr_command:Testr
egg_info.writers =
- pbr.json = pbr.packaging:write_pbr_json
+ pbr.json = pbr.pbr_json:write_pbr_json
console_scripts =
pbr = pbr.cmd.main:main