Skip to content

Commit

Permalink
Add automatic detection of python site-package dir in installations
Browse files Browse the repository at this point in the history
  • Loading branch information
Micket committed May 23, 2024
1 parent e22fa0b commit f5bf63d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,21 @@ def make_module_extra(self, altroot=None, altversion=None):
value, type(value))
lines.append(self.module_generator.append_paths(key, value, allow_abs=self.cfg['allow_append_abs_path']))

# Add automatic PYTHONPATH or EBPYTHONPREFIXES if they aren't already present
if 'PYTHONPATH' not in self.module_generator.keys and 'EBPYTHONPREFIXES' not in self.module_generator.keys:
python_paths = [path for path in glob.glob('lib*/python*/site-packages')
if re.match(r'lib(64)?/python\d+\.\d+/site-packages', path)]
use_ebpythonprefixes = get_software_root('Python') and build_option('prefer_ebpythonprefixes') and \
self.cfg['prefer_ebpythonprefixes']

if len(python_paths) > 1 and not use_ebpythonprefixes:
raise EasyBuildError('Multiple python paths requires EBPYHONPREFIXES: ' + ', '.join(python_paths))
elif python_paths:
if use_ebpythonprefixes:
lines.append(self.module_generator.append_paths('EBPYHONPREFIXES', '.'))
else:
lines.append(self.module_generator.append_paths('PYTHONPATH', python_paths))

modloadmsg = self.cfg['modloadmsg']
if modloadmsg:
# add trailing newline to prevent that shell prompt is 'glued' to module load message
Expand Down

0 comments on commit f5bf63d

Please sign in to comment.