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
This commit is contained in:
parent
50a43a18d1
commit
3ec9f0e809
|
@ -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
|
||||
|
|
|
@ -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))
|
Loading…
Reference in New Issue