Skip to content

Commit e4979d6

Browse files
committed
Add warning for duplicated PYTHONPATH's that should not occur
1 parent 71fc7c4 commit e4979d6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

easybuild/tools/module_generator.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,14 @@ def update_paths(self, key, paths, prepend=True, allow_abs=False, expand_relpath
271271
if key == 'PYTHONPATH' and build_option('prefer_ebpythonprefix_over_pythonpath'):
272272
# Special condition for PYTHONPATHs that match the standard pattern,
273273
# replace with EBPYTHONPREFIX which is added to python sys path at runtime
274-
python_paths = {path for path in paths if re.match(r'lib/python\d+\.\d+/site-packages', path)}
274+
python_paths = [path for path in paths if re.match(r'lib/python\d+\.\d+/site-packages', path)]
275275
if python_paths:
276-
self.log.info("Replaced PYTHONPATH %s with EBPYTHONPREFIX", python_paths)
277-
paths = [path for path in paths if path not in python_paths]
276+
if len(python_paths) > 1:
277+
raise EasyBuildError('Found multiple paths for PYTHONPATH: ' + ', '.join(pythonpaths))
278+
python_path = python_paths[0]
279+
self.log.info("Replaced PYTHONPATH %s with EBPYTHONPREFIX", python_path)
278280
ret = self._update_paths('EBPYTHONPREFIX', [''], prepend, allow_abs, expand_relpaths)
281+
paths = [path for path in paths if path != python_path]
279282
if paths:
280283
ret += self._update_paths(key, paths, prepend, allow_abs, expand_relpaths)
281284
return ret

0 commit comments

Comments
 (0)