diff --git a/easybuild/easyblocks/generic/pythonbundle.py b/easybuild/easyblocks/generic/pythonbundle.py index ec13be302f..1d89ee2fbf 100644 --- a/easybuild/easyblocks/generic/pythonbundle.py +++ b/easybuild/easyblocks/generic/pythonbundle.py @@ -31,10 +31,10 @@ import sys from easybuild.easyblocks.generic.bundle import Bundle -from easybuild.easyblocks.generic.pythonpackage import EBPYTHONPREFIXES, EXTS_FILTER_PYTHON_PACKAGES +from easybuild.easyblocks.generic.pythonpackage import EXTS_FILTER_PYTHON_PACKAGES from easybuild.easyblocks.generic.pythonpackage import PythonPackage, get_pylibdirs, pick_python_cmd from easybuild.tools.build_log import EasyBuildError -from easybuild.tools.config import build_option +from easybuild.tools.config import build_option, PYTHONPATH, EBPYTHONPREFIXES from easybuild.tools.filetools import which from easybuild.tools.modules import get_software_root import easybuild.tools.environment as env @@ -145,10 +145,11 @@ def make_module_extra(self, *args, **kwargs): # or if we prefer it runtime_deps = [dep['name'] for dep in self.cfg.dependencies(runtime_only=True)] use_ebpythonprefixes = 'Python' in runtime_deps and \ - build_option('prefer_ebpythonprefixes') and self.cfg['prefer_ebpythonprefixes'] + build_option('prefer_python_search_path') == EBPYTHONPREFIXES and not self.cfg['force_pythonpath'] if self.multi_python or use_ebpythonprefixes: - if EBPYTHONPREFIXES not in self.module_generator.added_paths_per_key: - txt += self.module_generator.prepend_paths(EBPYTHONPREFIXES, '') + path = '' # EBPYTHONPREFIXES are relative to the install dir + if path not in self.module_generator.added_paths_per_key[EBPYTHONPREFIXES]: + txt += self.module_generator.prepend_paths(EBPYTHONPREFIXES, path) else: # the temporary module file that is generated before installing extensions @@ -163,8 +164,8 @@ def make_module_extra(self, *args, **kwargs): ] for pylibdir in new_pylibdirs: - if pylibdir not in self.module_generator.added_paths_per_key['PYTHONPATH']: - txt += self.module_generator.prepend_paths('PYTHONPATH', pylibdir) + if pylibdir not in self.module_generator.added_paths_per_key[PYTHONPATH]: + txt += self.module_generator.prepend_paths(PYTHONPATH, pylibdir) return txt diff --git a/easybuild/easyblocks/generic/pythonpackage.py b/easybuild/easyblocks/generic/pythonpackage.py index c156b97847..2c67b88b7d 100644 --- a/easybuild/easyblocks/generic/pythonpackage.py +++ b/easybuild/easyblocks/generic/pythonpackage.py @@ -42,13 +42,13 @@ import easybuild.tools.environment as env from easybuild.base import fancylogger -from easybuild.easyblocks.python import EBPYTHONPREFIXES, EXTS_FILTER_PYTHON_PACKAGES +from easybuild.easyblocks.python import EXTS_FILTER_PYTHON_PACKAGES from easybuild.framework.easyconfig import CUSTOM from easybuild.framework.easyconfig.default import DEFAULT_CONFIG from easybuild.framework.easyconfig.templates import PYPI_SOURCE from easybuild.framework.extensioneasyblock import ExtensionEasyBlock from easybuild.tools.build_log import EasyBuildError, print_msg -from easybuild.tools.config import build_option +from easybuild.tools.config import build_option, PYTHONPATH, EBPYTHONPREFIXES from easybuild.tools.filetools import change_dir, mkdir, remove_dir, symlink, which from easybuild.tools.modules import get_software_root from easybuild.tools.run import run_shell_cmd, subprocess_popen_text @@ -1143,15 +1143,16 @@ def make_module_extra(self, *args, **kwargs): # or if we prefer it runtime_deps = [dep['name'] for dep in self.cfg.dependencies(runtime_only=True)] use_ebpythonprefixes = 'Python' in runtime_deps and \ - build_option('prefer_ebpythonprefixes') and self.cfg['prefer_ebpythonprefixes'] + build_option('prefer_python_search_path') == EBPYTHONPREFIXES and not self.cfg['force_pythonpath'] if self.multi_python or use_ebpythonprefixes: - txt += self.module_generator.prepend_paths(EBPYTHONPREFIXES, '') + path = '' # EBPYTHONPREFIXES are relative to the install dir + text += self.module_generator.prepend_paths(EBPYTHONPREFIXES, path) elif self.require_python: self.set_pylibdirs() for path in self.all_pylibdirs: fullpath = os.path.join(self.installdir, path) # only extend $PYTHONPATH with existing, non-empty directories if os.path.exists(fullpath) and os.listdir(fullpath): - txt += self.module_generator.prepend_paths('PYTHONPATH', path) + txt += self.module_generator.prepend_paths(PYTHONPATH, path) return super(PythonPackage, self).make_module_extra(txt, *args, **kwargs) diff --git a/easybuild/easyblocks/p/python.py b/easybuild/easyblocks/p/python.py index b450d74c79..01355b23e5 100644 --- a/easybuild/easyblocks/p/python.py +++ b/easybuild/easyblocks/p/python.py @@ -45,7 +45,7 @@ from easybuild.framework.easyconfig import CUSTOM from easybuild.framework.easyconfig.templates import PYPI_SOURCE from easybuild.tools.build_log import EasyBuildError, print_warning -from easybuild.tools.config import build_option, ERROR, log_path +from easybuild.tools.config import build_option, ERROR, log_path, PYTHONPATH, EBPYTHONPREFIXES from easybuild.tools.modules import get_software_libdir, get_software_root, get_software_version from easybuild.tools.filetools import apply_regex_substitutions, change_dir, mkdir from easybuild.tools.filetools import read_file, remove_dir, symlink, write_file @@ -59,8 +59,6 @@ # magic value for unlimited stack size UNLIMITED = 'unlimited' -EBPYTHONPREFIXES = 'EBPYTHONPREFIXES' - # We want the following import order: # 1. Packages installed into VirtualEnv # 2. Packages installed into $EBPYTHONPREFIXES (e.g. our modules) @@ -643,6 +641,6 @@ def make_module_extra(self, *args, **kwargs): txt = super(EB_Python, self).make_module_extra() if self.cfg.get('ebpythonprefixes'): - txt += self.module_generator.prepend_paths('PYTHONPATH', self.pythonpath) + txt += self.module_generator.prepend_paths(PYTHONPATH, self.pythonpath) return txt