Skip to content

Commit a1e4ecc

Browse files
committed
Rework logic to allow nonstandard PYTHONPATHs
to be added while still preserving the automatic adding of standard paths.
1 parent 0310bed commit a1e4ecc

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

easybuild/framework/easyblock.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,21 +1439,20 @@ def make_module_extra(self, altroot=None, altversion=None):
14391439
lines.append(self.module_generator.append_paths(key, value, allow_abs=self.cfg['allow_append_abs_path']))
14401440

14411441
# Add automatic PYTHONPATH or EBPYTHONPREFIXES if they aren't already present
1442-
if 'PYTHONPATH' not in self.module_generator.added_paths_per_key and \
1443-
'EBPYTHONPREFIXES' not in self.module_generator.added_paths_per_key:
1444-
python_paths = [path[len(self.installdir)+1:]
1445-
for path in glob.glob(f'{self.installdir}/lib*/python*/site-packages')
1446-
if re.match(self.installdir + r'/lib(64)?/python\d+\.\d+/site-packages', path)]
1447-
use_ebpythonprefixes = get_software_root('Python') and build_option('prefer_ebpythonprefixes') and \
1448-
self.cfg['prefer_ebpythonprefixes']
1449-
1450-
if len(python_paths) > 1 and not use_ebpythonprefixes:
1451-
raise EasyBuildError('Multiple python paths requires EBPYTHONPREFIXES: ' + ', '.join(python_paths))
1452-
elif python_paths:
1453-
if use_ebpythonprefixes:
1454-
lines.append(self.module_generator.prepend_paths('EBPYTHONPREFIXES', ''))
1455-
else:
1456-
lines.append(self.module_generator.prepend_paths('PYTHONPATH', python_paths))
1442+
python_paths = [path[len(self.installdir)+1:]
1443+
for path in glob.glob(f'{self.installdir}/lib*/python*/site-packages')
1444+
if re.match(self.installdir + r'/lib(64)?/python\d+\.\d+/site-packages', path)]
1445+
use_ebpythonprefixes = get_software_root('Python') and build_option('prefer_ebpythonprefixes') and \
1446+
self.cfg['prefer_ebpythonprefixes']
1447+
1448+
if len(python_paths) > 1 and not use_ebpythonprefixes:
1449+
raise EasyBuildError('Multiple python paths requires EBPYTHONPREFIXES: ' + ', '.join(python_paths))
1450+
elif python_paths:
1451+
# Add paths unless they were already added
1452+
if use_ebpythonprefixes and '' not in self.module_generator.added_paths_per_key['EBPYTHONPREFIXES']:
1453+
lines.append(self.module_generator.prepend_paths('EBPYTHONPREFIXES', ''))
1454+
elif python_paths[0] not in self.module_generator.added_paths_per_key['PYTHONPATH']:
1455+
lines.append(self.module_generator.prepend_paths('PYTHONPATH', python_paths))
14571456

14581457
modloadmsg = self.cfg['modloadmsg']
14591458
if modloadmsg:

0 commit comments

Comments
 (0)