Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setup_hook(config):
"""Filter config parsed from a setup.cfg to inject our defaults."""
metadata = config['metadata']
metadata['version'] = packaging.get_version(metadata['name'],
metadata.get('version', None))
metadata['requires_dist'] = "\n".join(packaging.parse_requirements())
config['metadata'] = metadata
config['global'] = config.get('global', dict())
config['global']['commands'] = config['global'].get('commands', "") + """
pbr.packaging.LocalSDist
"""
if packaging.have_sphinx():
config['global']['commands'] = config['global']['commands'] + """
pbr.packaging.LocalBuildDoc
pbr.packaging.LocalBuildLatex
"""
pbr_config = config.get('pbr', dict())
use_egg = packaging.get_boolean_option(
pbr_config, 'use-egg', 'PBR_USE_EGG')
# We always want non-egg install unless explicitly requested
# install_requires are treated as a special case of extras, before
# being put back in the expected place
#
# fred =
# foo:marker
# bar
# -> {'fred': ['bar'], 'fred:marker':['foo']}
if 'extras' in config:
requirement_pattern = '(?P[^:]*):?(?P[^#]*?)(?:\s*#.*)?$'
extras = config['extras']
# Add contents of test-requirements, if any, into an extra named
# 'test' if one does not already exist.
if 'test' not in extras:
from pbr import packaging
extras['test'] = "\n".join(packaging.parse_requirements(
packaging.TEST_REQUIREMENTS_FILES)).replace(';', ':')
for extra in extras:
extra_requirements = []
requirements = split_multiline(extras[extra])
for requirement in requirements:
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))
all_requirements[extra] = extra_requirements
# Transform the full list of requirements into:
# - install_requires, for those that have no extra and no
# env_marker
# - named extras, for those with an extra name (which may include
def hook(self):
self.config['version'] = packaging.get_version(
self.config['name'], self.config.get('version', None))
packaging.append_text_list(
self.config, 'requires_dist',
packaging.parse_requirements())
# install_requires are treated as a special case of extras, before
# being put back in the expected place
#
# fred =
# foo:marker
# bar
# -> {'fred': ['bar'], 'fred:marker':['foo']}
if 'extras' in config:
requirement_pattern = '(?P[^:]*):?(?P[^#]*?)(?:\s*#.*)?$'
extras = config['extras']
# Add contents of test-requirements, if any, into an extra named
# 'test' if one does not already exist.
if 'test' not in extras:
from pbr import packaging
extras['test'] = "\n".join(packaging.parse_requirements(
packaging.TEST_REQUIREMENTS_FILES)).replace(';', ':')
for extra in extras:
extra_requirements = []
requirements = split_multiline(extras[extra])
for requirement in requirements:
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))
all_requirements[extra] = extra_requirements
# Transform the full list of requirements into:
# - install_requires, for those that have no extra and no
# env_marker
# - named extras, for those with an extra name (which may include
# being put back in the expected place
#
# fred =
# foo:marker
# bar
# -> {'fred': ['bar'], 'fred:marker':['foo']}
if 'extras' in config:
requirement_pattern = (
r'(?P[^:]*):?(?P[^#]*?)(?:\s*#.*)?$')
extras = config['extras']
# Add contents of test-requirements, if any, into an extra named
# 'test' if one does not already exist.
if 'test' not in extras:
from pbr import packaging
extras['test'] = "\n".join(packaging.parse_requirements(
packaging.TEST_REQUIREMENTS_FILES)).replace(';', ':')
for extra in extras:
extra_requirements = []
requirements = split_multiline(extras[extra])
for requirement in requirements:
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))
all_requirements[extra] = extra_requirements
# Transform the full list of requirements into:
# - install_requires, for those that have no extra and no
# env_marker
# - named extras, for those with an extra name (which may include
def hook(self):
self.config['include_package_data'] = 'True'
packaging.append_text_list(
self.config, 'dependency_links',
packaging.parse_dependency_links())
packaging.append_text_list(
self.config, 'tests_require',
packaging.parse_requirements(
packaging.TEST_REQUIREMENTS_FILES,
strip_markers=True))