Skip to content

Commit

Permalink
Merge pull request #142 from wpoely86/finalfix
Browse files Browse the repository at this point in the history
Fix dependency_links injection for real
  • Loading branch information
boegel authored Feb 11, 2020
2 parents 8541e8b + 97e9420 commit 7dc7620
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 22 deletions.
38 changes: 16 additions & 22 deletions lib/vsc/install/shared_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@
except ImportError:
have_xmlrunner = False

# see https://docs.python.org/3/reference/expressions.html#comparisons
COMPARISON_OPERATORS = ['<=', '<', '>=', '>', '==', '!=']

# Test that these are matched by a .gitignore pattern
GITIGNORE_PATTERNS = ['.pyc', '.pyo', '~']
# .gitnore needs to contain these exactly
Expand Down Expand Up @@ -162,7 +159,7 @@ def _log(self, level, msg, args):

RELOAD_VSC_MODS = False

VERSION = '0.14.12'
VERSION = '0.14.13'

log.info('This is (based on) vsc.install.shared_setup %s' % VERSION)
log.info('(using setuptools version %s located at %s)' % (setuptools.__version__, setuptools.__file__))
Expand Down Expand Up @@ -1431,28 +1428,25 @@ def parse_target(self, target, urltemplate=None):
]
else:
urls = [('github.com', 'git+https://')]

for dependency in set(new_target['install_requires'] + new_target['setup_requires'] +
new_target['tests_require']):

# see https://docs.python.org/3/reference/expressions.html#comparisons
split_re = re.compile(r'(\s)?([<>]=?|[=!]=)(\s)?')
check_whitespace = split_re.search(dependency)

if check_whitespace and (check_whitespace.group(1) is None or check_whitespace.group(3) is None):
raise ValueError("Missing spaces around comparison operator in '%s'" % dependency)

if dependency.startswith('vsc'):
dep = dependency.split(' ')[0]
depversion = ''
# if you specify any kind of version on a dependency, the depedency_links also needs a version or
dep_name = split_re.split(dependency)[0]
dep_name_version = split_re.sub('-', dependency)
# if you specify any kind of version on a dependency, the dependency_links also needs a version or
# else it's ignored: https://setuptools.readthedocs.io/en/latest/setuptools.html#id14
for comp in COMPARISON_OPERATORS:
try:
depversion = "-" + dependency.split(comp)[1].strip()
except IndexError:
pass
for url, git_scheme in urls:
new_target['dependency_links'] += [''.join([git_scheme, url, '/hpcugent/', dep, '.git#egg=',
dep, depversion])]

for dep in new_target['install_requires']:
for comp in COMPARISON_OPERATORS:
if comp in dep:
if (' %s ' % comp) not in dep:
raise ValueError("Missing spaces around comparison operator in '%s'" % dep)
break
for url, git_scheme in urls:
new_target['dependency_links'] += [''.join([git_scheme, url, '/hpcugent/', dep_name, '.git#egg=',
dep_name_version])]

log.debug("New target = %s" % (new_target))
print(new_target)
Expand Down
34 changes: 34 additions & 0 deletions test/shared_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,37 @@ def test_parse_target(self):
self.assertTrue(new_target['long_description'].startswith("Description\n==========="))

klass.SHARED_TARGET = orig_target

def test_parse_target_dependencies(self):
"""Test injecting dependency_links in parse_target"""
package = {
'name': 'vsc-test',
'excluded_pkgs_rpm': [],
'version': '1.0',
'install_requires': [
'vsc-config >= 2.0.0',
'vsc-accountpage-clients',
'vsc-base > 1.0.0'
],
}
setup = vsc_setup()
# this is needed to pass the tests on Travis: travis will clone vsc-install through
# https and it will be marked as non private repo, causing the dependency_links to be injected
# with git+https, which is not correct in this test case.
setup.private_repo = True
new_target = setup.parse_target(package)

dep_links_urls = [
'git+ssh://[email protected]/hpcugent/vsc-accountpage-clients.git#egg=vsc-accountpage-clients',
'git+ssh://[email protected]/hpcugent/vsc-accountpage-clients.git#egg=vsc-accountpage-clients',
'git+ssh://[email protected]/hpcugent/vsc-config.git#egg=vsc-config-2.0.0',
'git+ssh://[email protected]/hpcugent/vsc-config.git#egg=vsc-config-2.0.0',
'git+ssh://[email protected]/hpcugent/vsc-base.git#egg=vsc-base-1.0.0',
'git+ssh://[email protected]/hpcugent/vsc-base.git#egg=vsc-base-1.0.0',
]

for url in dep_links_urls:
self.assertIn(url, new_target['dependency_links'])

package['install_requires'].append('vsc-utils<=1.0.0')
self.assertRaises(ValueError, setup.parse_target, package)

0 comments on commit 7dc7620

Please sign in to comment.