From 78eadaaf425bc159f529cb18a6b40d24213f4825 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Wed, 7 Jul 2021 14:39:06 +0200 Subject: [PATCH] Only set PYTHONPATH when ebpythonprefixes is set Also set the path in prepare_step --- easybuild/easyblocks/p/python.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/easybuild/easyblocks/p/python.py b/easybuild/easyblocks/p/python.py index b413ae54674..2af2937a993 100644 --- a/easybuild/easyblocks/p/python.py +++ b/easybuild/easyblocks/p/python.py @@ -144,11 +144,6 @@ def __init__(self, *args, **kwargs): self.pyshortver = '.'.join(self.version.split('.')[:2]) - self.pythonpath = None - if self.cfg['ebpythonprefixes']: - easybuild_subdir = log_path() - self.pythonpath = os.path.join(easybuild_subdir, 'python') - ext_defaults = { # Use PYPI_SOURCE as the default for source_urls of extensions. 'source_urls': [url for name, url, _ in TEMPLATE_CONSTANTS if name == 'PYPI_SOURCE'], @@ -182,6 +177,15 @@ def _get_pip_ext_version(self): return ext[1] return None + def prepare_step(self, *args, **kwargs): + super(EB_Python, self).prepare_step(*args, **kwargs) + + if self.cfg['ebpythonprefixes']: + easybuild_subdir = log_path() + self.pythonpath = os.path.join(easybuild_subdir, 'python') + else: + self.pythonpath = None + def patch_step(self, *args, **kwargs): """ Custom patch step for Python: @@ -583,7 +587,7 @@ def make_module_extra(self, *args, **kwargs): """Add path to sitecustomize.py to $PYTHONPATH""" txt = super(EB_Python, self).make_module_extra() - if self.pythonpath: + if self.cfg['ebpythonprefixes']: txt += self.module_generator.prepend_paths('PYTHONPATH', self.pythonpath) return txt