Skip to content

Commit

Permalink
Replace PYTHONPATHs with EBPYTHONPREFIX when possible
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Grund <Flamefire@users.noreply.github.com>
  • Loading branch information
Micket and Flamefire committed Apr 4, 2024
1 parent ec6a627 commit 4cf7362
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions easybuild/tools/module_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,17 @@ def update_paths(self, key, paths, prepend=True, allow_abs=False, expand_relpath
paths = self._filter_paths(key, paths)
if paths is None:
return ''
if key == 'PYTHONPATH':
# Special condition for PYTHONPATHs that match the standard pattern,
# replace with EBPYTHONPREFIX which is added to python sys path at runtime
python_paths = {path for path in paths if re.match(r'lib/python\d+\.\d+/site-packages', path)}
if python_paths:
self.log.info("Replaced PYTHONPATH %s with EBPYTHONPREFIX", python_paths)
paths = [path for path in paths if path not in python_paths]
ret = self._update_paths('EBPYTHONPREFIX', [''], prepend, allow_abs, expand_relpaths)
if paths:
ret += self._update_paths(key, paths, prepend, allow_abs, expand_relpaths)
return ret
return self._update_paths(key, paths, prepend, allow_abs, expand_relpaths)

def _modulerc_check_module_version(self, module_version):
Expand Down

0 comments on commit 4cf7362

Please sign in to comment.