Skip to content

Commit 4652509

Browse files
committed
Add automatic detection of python site-package dir in installations
1 parent 27c32ef commit 4652509

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

easybuild/framework/easyblock.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,22 @@ def make_module_extra(self, altroot=None, altversion=None):
14381438
value, type(value))
14391439
lines.append(self.module_generator.append_paths(key, value, allow_abs=self.cfg['allow_append_abs_path']))
14401440

1441+
# 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 for path in glob.glob('lib*/python*/site-packages')
1445+
if re.match(r'lib(64)?/python\d+\.\d+/site-packages', path)]
1446+
use_ebpythonprefixes = get_software_root('Python') and build_option('prefer_ebpythonprefixes') and \
1447+
self.cfg['prefer_ebpythonprefixes']
1448+
1449+
if len(python_paths) > 1 and not use_ebpythonprefixes:
1450+
raise EasyBuildError('Multiple python paths requires EBPYHONPREFIXES: ' + ', '.join(python_paths))
1451+
elif python_paths:
1452+
if use_ebpythonprefixes:
1453+
lines.append(self.module_generator.append_paths('EBPYHONPREFIXES', '.'))
1454+
else:
1455+
lines.append(self.module_generator.append_paths('PYTHONPATH', python_paths))
1456+
14411457
modloadmsg = self.cfg['modloadmsg']
14421458
if modloadmsg:
14431459
# add trailing newline to prevent that shell prompt is 'glued' to module load message

0 commit comments

Comments
 (0)