Skip to content

Commit f5bf63d

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

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

easybuild/framework/easyblock.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,21 @@ 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.keys and 'EBPYTHONPREFIXES' not in self.module_generator.keys:
1428+
python_paths = [path for path in glob.glob('lib*/python*/site-packages')
1429+
if re.match(r'lib(64)?/python\d+\.\d+/site-packages', path)]
1430+
use_ebpythonprefixes = get_software_root('Python') and build_option('prefer_ebpythonprefixes') and \
1431+
self.cfg['prefer_ebpythonprefixes']
1432+
1433+
if len(python_paths) > 1 and not use_ebpythonprefixes:
1434+
raise EasyBuildError('Multiple python paths requires EBPYHONPREFIXES: ' + ', '.join(python_paths))
1435+
elif python_paths:
1436+
if use_ebpythonprefixes:
1437+
lines.append(self.module_generator.append_paths('EBPYHONPREFIXES', '.'))
1438+
else:
1439+
lines.append(self.module_generator.append_paths('PYTHONPATH', python_paths))
1440+
14261441
modloadmsg = self.cfg['modloadmsg']
14271442
if modloadmsg:
14281443
# add trailing newline to prevent that shell prompt is 'glued' to module load message

0 commit comments

Comments
 (0)