Skip to content

Commit 0150194

Browse files
committed
Add automatic detection of python site-package dir in installations
1 parent e22fa0b commit 0150194

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
@@ -1423,6 +1423,22 @@ def make_module_extra(self, altroot=None, altversion=None):
14231423
value, type(value))
14241424
lines.append(self.module_generator.append_paths(key, value, allow_abs=self.cfg['allow_append_abs_path']))
14251425

1426+
# Add automatic PYTHONPATH or EBPYTHONPREFIXES if they aren't already present
1427+
if 'PYTHONPATH' not in self.module_generator.added_paths_per_key and \
1428+
'EBPYTHONPREFIXES' not in self.module_generator.added_paths_per_key:
1429+
python_paths = [path for path in glob.glob('lib*/python*/site-packages')
1430+
if re.match(r'lib(64)?/python\d+\.\d+/site-packages', path)]
1431+
use_ebpythonprefixes = get_software_root('Python') and build_option('prefer_ebpythonprefixes') and \
1432+
self.cfg['prefer_ebpythonprefixes']
1433+
1434+
if len(python_paths) > 1 and not use_ebpythonprefixes:
1435+
raise EasyBuildError('Multiple python paths requires EBPYHONPREFIXES: ' + ', '.join(python_paths))
1436+
elif python_paths:
1437+
if use_ebpythonprefixes:
1438+
lines.append(self.module_generator.append_paths('EBPYHONPREFIXES', '.'))
1439+
else:
1440+
lines.append(self.module_generator.append_paths('PYTHONPATH', python_paths))
1441+
14261442
modloadmsg = self.cfg['modloadmsg']
14271443
if modloadmsg:
14281444
# add trailing newline to prevent that shell prompt is 'glued' to module load message

0 commit comments

Comments
 (0)