Remove the use of six from PBR
Outside of testing the only real place six was used was to import configparser in a backward and forward compatible manner. We can do conditional imports ourselves and drop the user of six from pbr which drops a runtime requirement. In testing we used six for configparser and unicode strings. We fix configparser as in pbr proper and simply use u'' strings where six.u() was previously used. Change-Id: I3b38c9a9c3c1a8baf38993b459ea72715b91776a
This commit is contained in:
parent
f797fc1c58
commit
50fceaca0d
@ -4,4 +4,3 @@ sphinx!=1.6.6,!=1.6.7,>=1.6.2;python_version>='3.4' # BSD
|
||||
sphinxcontrib-apidoc>=0.2.0 # BSD
|
||||
openstackdocstheme>=1.18.1 # Apache-2.0
|
||||
reno>=2.5.0 # Apache-2.0
|
||||
six>=1.16.0 # MIT
|
||||
|
@ -13,9 +13,16 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# (hberaud) do not use six here to import configparser
|
||||
# to keep this module free from external dependencies
|
||||
# to avoid cross dependencies errors on minimal system
|
||||
# free from dependencies.
|
||||
try:
|
||||
import configparser
|
||||
except ImportError:
|
||||
import ConfigParser as configparser
|
||||
import os.path
|
||||
|
||||
from six.moves import configparser
|
||||
from sphinx.util import logging
|
||||
|
||||
import pbr.version
|
||||
|
@ -52,7 +52,6 @@ try:
|
||||
except ImportError:
|
||||
import mock
|
||||
import pkg_resources
|
||||
import six
|
||||
import testscenarios
|
||||
import testtools
|
||||
from testtools import matchers
|
||||
@ -218,18 +217,18 @@ class CreatePackages(fixtures.Fixture):
|
||||
"""
|
||||
|
||||
defaults = {
|
||||
'setup.py': textwrap.dedent(six.u("""\
|
||||
'setup.py': textwrap.dedent(u"""\
|
||||
#!/usr/bin/env python
|
||||
import setuptools
|
||||
setuptools.setup(
|
||||
setup_requires=['pbr'],
|
||||
pbr=True,
|
||||
)
|
||||
""")),
|
||||
'setup.cfg': textwrap.dedent(six.u("""\
|
||||
"""),
|
||||
'setup.cfg': textwrap.dedent(u"""\
|
||||
[metadata]
|
||||
name = {pkg_name}
|
||||
"""))
|
||||
""")
|
||||
}
|
||||
|
||||
def __init__(self, packages):
|
||||
|
@ -13,12 +13,14 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
try:
|
||||
import configparser
|
||||
except ImportError:
|
||||
import ConfigParser as configparser
|
||||
import io
|
||||
import tempfile
|
||||
import textwrap
|
||||
|
||||
import six
|
||||
from six.moves import configparser
|
||||
import sys
|
||||
|
||||
from pbr.tests import base
|
||||
@ -27,7 +29,7 @@ from pbr import util
|
||||
|
||||
def config_from_ini(ini):
|
||||
config = {}
|
||||
ini = textwrap.dedent(six.u(ini))
|
||||
ini = textwrap.dedent(ini)
|
||||
if sys.version_info >= (3, 2):
|
||||
parser = configparser.ConfigParser()
|
||||
parser.read_file(io.StringIO(ini))
|
||||
@ -43,7 +45,7 @@ class TestBasics(base.BaseTestCase):
|
||||
|
||||
def test_basics(self):
|
||||
self.maxDiff = None
|
||||
config_text = """
|
||||
config_text = u"""
|
||||
[metadata]
|
||||
name = foo
|
||||
version = 1.0
|
||||
@ -145,7 +147,7 @@ class TestExtrasRequireParsingScenarios(base.BaseTestCase):
|
||||
|
||||
scenarios = [
|
||||
('simple_extras', {
|
||||
'config_text': """
|
||||
'config_text': u"""
|
||||
[extras]
|
||||
first =
|
||||
foo
|
||||
@ -162,7 +164,7 @@ class TestExtrasRequireParsingScenarios(base.BaseTestCase):
|
||||
}
|
||||
}),
|
||||
('with_markers', {
|
||||
'config_text': """
|
||||
'config_text': u"""
|
||||
[extras]
|
||||
test =
|
||||
foo:python_version=='2.6'
|
||||
@ -174,7 +176,7 @@ class TestExtrasRequireParsingScenarios(base.BaseTestCase):
|
||||
"test:(python_version=='2.6')": ['foo', 'baz<1.6'],
|
||||
"test": ['bar', 'zaz']}}),
|
||||
('no_extras', {
|
||||
'config_text': """
|
||||
'config_text': u"""
|
||||
[metadata]
|
||||
long_description = foo
|
||||
""",
|
||||
@ -201,7 +203,7 @@ class TestMapFieldsParsingScenarios(base.BaseTestCase):
|
||||
|
||||
scenarios = [
|
||||
('simple_project_urls', {
|
||||
'config_text': """
|
||||
'config_text': u"""
|
||||
[metadata]
|
||||
project_urls =
|
||||
Bug Tracker = https://bugs.launchpad.net/pbr/
|
||||
@ -215,7 +217,7 @@ class TestMapFieldsParsingScenarios(base.BaseTestCase):
|
||||
},
|
||||
}),
|
||||
('query_parameters', {
|
||||
'config_text': """
|
||||
'config_text': u"""
|
||||
[metadata]
|
||||
project_urls =
|
||||
Bug Tracker = https://bugs.launchpad.net/pbr/?query=true
|
||||
@ -241,7 +243,7 @@ class TestKeywordsParsingScenarios(base.BaseTestCase):
|
||||
|
||||
scenarios = [
|
||||
('keywords_list', {
|
||||
'config_text': """
|
||||
'config_text': u"""
|
||||
[metadata]
|
||||
keywords =
|
||||
one
|
||||
@ -252,7 +254,7 @@ class TestKeywordsParsingScenarios(base.BaseTestCase):
|
||||
},
|
||||
),
|
||||
('inline_keywords', {
|
||||
'config_text': """
|
||||
'config_text': u"""
|
||||
[metadata]
|
||||
keywords = one, two, three
|
||||
""", # noqa: E501
|
||||
@ -269,7 +271,7 @@ class TestKeywordsParsingScenarios(base.BaseTestCase):
|
||||
|
||||
class TestProvidesExtras(base.BaseTestCase):
|
||||
def test_provides_extras(self):
|
||||
ini = """
|
||||
ini = u"""
|
||||
[metadata]
|
||||
provides_extras = foo
|
||||
bar
|
||||
@ -283,7 +285,7 @@ class TestDataFilesParsing(base.BaseTestCase):
|
||||
|
||||
scenarios = [
|
||||
('data_files', {
|
||||
'config_text': """
|
||||
'config_text': u"""
|
||||
[files]
|
||||
data_files =
|
||||
'i like spaces/' =
|
||||
@ -306,7 +308,7 @@ class TestDataFilesParsing(base.BaseTestCase):
|
||||
class TestUTF8DescriptionFile(base.BaseTestCase):
|
||||
def test_utf8_description_file(self):
|
||||
_, path = tempfile.mkstemp()
|
||||
ini_template = """
|
||||
ini_template = u"""
|
||||
[metadata]
|
||||
description_file = %s
|
||||
"""
|
||||
|
@ -7,7 +7,6 @@ wheel>=0.32.0 # MIT
|
||||
fixtures>=3.0.0 # Apache-2.0/BSD
|
||||
hacking>=1.1.0,<4.0.0;python_version>='3.6' # Apache-2.0
|
||||
mock>=2.0.0,<4.0.0;python_version=='2.7' # BSD
|
||||
six>=1.16.0 # MIT
|
||||
stestr>=2.1.0,<3.0;python_version=='2.7' # Apache-2.0
|
||||
stestr>=2.1.0;python_version>='3.0' # Apache-2.0
|
||||
testresources>=2.0.0 # Apache-2.0/BSD
|
||||
|
Loading…
x
Reference in New Issue
Block a user