Skip to content

Commit

Permalink
Merge branch 'master' into custom
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisverspuij committed Nov 14, 2018
2 parents 7b9aa94 + 6a88aad commit 2888e34
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
9 changes: 4 additions & 5 deletions pbr/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.

from distutils import core
from distutils import errors
import logging
import os
import sys
import warnings

from distutils import errors

from pbr import util


if sys.version_info[0] == 3:
string_type = str
integer_types = (int,)
else:
string_type = basestring # flake8: noqa
integer_types = (int, long) # flake8: noqa
string_type = basestring # noqa
integer_types = (int, long) # noqa


def pbr(dist, attr, value):
Expand Down Expand Up @@ -103,7 +103,6 @@ def pbr(dist, attr, value):
raise errors.DistutilsSetupError(
'Error parsing %s: %s: %s' % (path, e.__class__.__name__, e))


# There are some metadata fields that are only supported by
# setuptools and not distutils, and hence are not in
# dist.metadata. We are OK to write these in. For gory details
Expand Down
57 changes: 29 additions & 28 deletions pbr/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,21 @@
# irritating Python bug that can crop up when using ./setup.py test.
# See: http://www.eby-sarna.com/pipermail/peak/2010-May/003355.html
try:
import multiprocessing # flake8: noqa
import multiprocessing # noqa
except ImportError:
pass
import logging # flake8: noqa
import logging # noqa

from collections import defaultdict
import os
import re
import sys
import traceback

from collections import defaultdict

import distutils.ccompiler
import pkg_resources

from distutils import log
from distutils import errors
from setuptools.command.egg_info import manifest_maker
from distutils import log
import pkg_resources
from setuptools import dist as st_dist
from setuptools import extension

Expand Down Expand Up @@ -244,11 +241,11 @@ def cfg_to_args(path='setup.cfg', script_args=()):
if hook != 'pbr.hooks.setup_hook']
for hook in setup_hooks:
hook_fn = resolve_name(hook)
try :
try:
hook_fn(config)
except SystemExit:
log.error('setup hook %s terminated the installation')
except:
except Exception:
e = sys.exc_info()[1]
log.error('setup hook %s raised exception: %s\n' %
(hook, e))
Expand Down Expand Up @@ -288,7 +285,9 @@ def cfg_to_args(path='setup.cfg', script_args=()):


def setup_cfg_to_setup_kwargs(config, script_args=()):
"""Processes the setup.cfg options and converts them to arguments accepted
"""Convert config options to kwargs.
Processes the setup.cfg options and converts them to arguments accepted
by setuptools' setup() function.
"""

Expand Down Expand Up @@ -354,12 +353,13 @@ def setup_cfg_to_setup_kwargs(config, script_args=()):
# Split install_requires into package,env_marker tuples
# These will be re-assembled later
install_requires = []
requirement_pattern = '(?P<package>[^;]*);?(?P<env_marker>[^#]*?)(?:\s*#.*)?$'
requirement_pattern = (
r'(?P<package>[^;]*);?(?P<env_marker>[^#]*?)(?:\s*#.*)?$')
for requirement in in_cfg_value:
m = re.match(requirement_pattern, requirement)
requirement_package = m.group('package').strip()
env_marker = m.group('env_marker').strip()
install_requires.append((requirement_package,env_marker))
install_requires.append((requirement_package, env_marker))
all_requirements[''] = install_requires
elif arg == 'package_dir':
in_cfg_value = {'': in_cfg_value}
Expand Down Expand Up @@ -414,7 +414,8 @@ def setup_cfg_to_setup_kwargs(config, script_args=()):
# -> {'fred': ['bar'], 'fred:marker':['foo']}

if 'extras' in config:
requirement_pattern = '(?P<package>[^:]*):?(?P<env_marker>[^#]*?)(?:\s*#.*)?$'
requirement_pattern = (
r'(?P<package>[^:]*):?(?P<env_marker>[^#]*?)(?:\s*#.*)?$')
extras = config['extras']
# Add contents of test-requirements, if any, into an extra named
# 'test' if one does not already exist.
Expand All @@ -430,7 +431,7 @@ def setup_cfg_to_setup_kwargs(config, script_args=()):
m = re.match(requirement_pattern, requirement)
extras_value = m.group('package').strip()
env_marker = m.group('env_marker')
extra_requirements.append((extras_value,env_marker))
extra_requirements.append((extras_value, env_marker))
all_requirements[extra] = extra_requirements

# Transform the full list of requirements into:
Expand Down Expand Up @@ -459,7 +460,7 @@ def setup_cfg_to_setup_kwargs(config, script_args=()):
"Marker evaluation failed, see the following "
"error. For more information see: "
"http://docs.openstack.org/"
"developer/pbr/compatibility.html#evaluate-marker"
"pbr/latest/user/using.html#environment-markers"
)
raise
else:
Expand All @@ -473,9 +474,10 @@ def setup_cfg_to_setup_kwargs(config, script_args=()):


def register_custom_compilers(config):
"""Handle custom compilers; this has no real equivalent in distutils, where
additional compilers could only be added programmatically, so we have to
hack it in somehow.
"""Handle custom compilers.
This has no real equivalent in distutils, where additional compilers could
only be added programmatically, so we have to hack it in somehow.
"""

compilers = has_get_option(config, 'global', 'compilers')
Expand All @@ -497,7 +499,7 @@ def register_custom_compilers(config):

module_name = compiler.__module__
# Note; this *will* override built in compilers with the same name
# TODO: Maybe display a warning about this?
# TODO(embray): Maybe display a warning about this?
cc = distutils.ccompiler.compiler_class
cc[name] = (module_name, compiler.__name__, desc)

Expand Down Expand Up @@ -560,13 +562,14 @@ def get_extension_modules(config):


def get_entry_points(config):
"""Process the [entry_points] section of setup.cfg to handle setuptools
entry points. This is, of course, not a standard feature of
distutils2/packaging, but as there is not currently a standard alternative
in packaging, we provide support for them.
"""Process the [entry_points] section of setup.cfg.
Processes setup.cfg to handle setuptools entry points. This is, of course,
not a standard feature of distutils2/packaging, but as there is not
currently a standard alternative in packaging, we provide support for them.
"""

if not 'entry_points' in config:
if 'entry_points' not in config:
return {}

return dict((option, split_multiline(value))
Expand Down Expand Up @@ -600,9 +603,7 @@ def split_csv(value):

# The following classes are used to hack Distribution.command_options a bit
class DefaultGetDict(defaultdict):
"""Like defaultdict, but the get() method also sets and returns the default
value.
"""
"""Like defaultdict, but get() also sets and returns the default value."""

def get(self, key, default=None):
if default is None:
Expand Down

0 comments on commit 2888e34

Please sign in to comment.