Skip to content

Commit 5bf4ceb

Browse files
authored
Merge pull request #3958 from Flamefire/20251014133801_new_pr_python
Move setting of `$PYTHON*` environment variables to `load_module` method in Python easyblock
2 parents 0887b2a + afb99b1 commit 5bf4ceb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

easybuild/easyblocks/p/python.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,6 @@ def prepare_for_extensions(self):
495495
self.cfg['exts_defaultclass'] = "PythonPackage"
496496
self.cfg['exts_filter'] = EXTS_FILTER_PYTHON_PACKAGES
497497

498-
set_py_env_vars(self.log)
499-
500498
# don't pass down any build/install options that may have been specified
501499
# 'make' options do not make sense for when building/installing Python libraries (usually via 'python setup.py')
502500
msg = "Unsetting '%s' easyconfig parameter before building/installing extensions: %s"
@@ -814,6 +812,16 @@ def _sanity_check_ebpythonprefixes(self):
814812
raise EasyBuildError("EasyBuilds sitecustomize.py did not add %s before %s to sys.path (%s)",
815813
temp_site_packages_path, base_site_packages_path, paths)
816814

815+
def load_module(self, *args, **kwargs):
816+
"""(Re)set environment variables after loading module file.
817+
818+
Required here to ensure the variables are also defined for stand-alone installations,
819+
because the environment is reset to the initial environment right before loading the module.
820+
"""
821+
822+
super().load_module(*args, **kwargs)
823+
set_py_env_vars(self.log)
824+
817825
def sanity_check_step(self):
818826
"""Custom sanity check for Python."""
819827

0 commit comments

Comments
 (0)