Skip to content

Commit 7b7a59f

Browse files
committed
Rename options and parameters for ebpythonprefixes change
1 parent 1d78e6c commit 7b7a59f

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

easybuild/framework/easyblock.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
from easybuild.tools.build_details import get_build_stats
7373
from easybuild.tools.build_log import EasyBuildError, EasyBuildExit, dry_run_msg, dry_run_warning, dry_run_set_dirs
7474
from easybuild.tools.build_log import print_error, print_msg, print_warning
75-
from easybuild.tools.config import CHECKSUM_PRIORITY_JSON, DEFAULT_ENVVAR_USERS_MODULES
75+
from easybuild.tools.config import CHECKSUM_PRIORITY_JSON, DEFAULT_ENVVAR_USERS_MODULES, PYTHONPATH, EBPYTHONPREFIXES
7676
from easybuild.tools.config import FORCE_DOWNLOAD_ALL, FORCE_DOWNLOAD_PATCHES, FORCE_DOWNLOAD_SOURCES
7777
from easybuild.tools.config import EASYBUILD_SOURCES_URL # noqa
7878
from easybuild.tools.config import build_option, build_path, get_log_filename, get_repository, get_repositorypath
@@ -1446,17 +1446,18 @@ def make_module_extra(self, altroot=None, altversion=None):
14461446

14471447
runtime_deps = [dep['name'] for dep in self.cfg.dependencies(runtime_only=True)]
14481448
use_ebpythonprefixes = 'Python' in runtime_deps and \
1449-
build_option('prefer_ebpythonprefixes') and self.cfg['prefer_ebpythonprefixes']
1449+
build_option('prefer_python_search_path') == EBPYTHONPREFIXES and not self.cfg['force_pythonpath']
14501450

14511451
if python_paths:
14521452
# Add paths unless they were already added
14531453
if use_ebpythonprefixes:
1454-
if '' not in self.module_generator.added_paths_per_key['EBPYTHONPREFIXES']:
1455-
lines.append(self.module_generator.prepend_paths('EBPYTHONPREFIXES', ''))
1454+
path = '' # EBPYTHONPREFIXES are relative to the install dir
1455+
if path not in self.module_generator.added_paths_per_key[EBPYTHONPREFIXES]:
1456+
lines.append(self.module_generator.prepend_paths(EBPYTHONPREFIXES, path))
14561457
else:
14571458
for python_path in python_paths:
1458-
if python_path not in self.module_generator.added_paths_per_key['PYTHONPATH']:
1459-
lines.append(self.module_generator.prepend_paths('PYTHONPATH', python_path))
1459+
if python_path not in self.module_generator.added_paths_per_key[PYTHONPATH]:
1460+
lines.append(self.module_generator.prepend_paths(PYTHONPATH, python_path))
14601461

14611462
modloadmsg = self.cfg['modloadmsg']
14621463
if modloadmsg:

easybuild/framework/easyconfig/default.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
'patches': [[], "List of patches to apply", BUILD],
116116
'prebuildopts': ['', 'Extra options pre-passed to build command.', BUILD],
117117
'preconfigopts': ['', 'Extra options pre-passed to configure.', BUILD],
118-
'prefer_ebpythonprefixes': [True, "Prefer EBPYTHONPREFIXES over PYTHONPATH when possible.", BUILD],
118+
'force_pythonpath': [False, "Force use of PYTHONPATH for python seearch path when possible.", BUILD],
119119
'preinstallopts': ['', 'Extra prefix options for installation.', BUILD],
120120
'pretestopts': ['', 'Extra prefix options for test.', BUILD],
121121
'postinstallcmds': [[], 'Commands to run after the install step.', BUILD],

easybuild/tools/config.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@
175175
OUTPUT_STYLE_RICH = 'rich'
176176
OUTPUT_STYLES = (OUTPUT_STYLE_AUTO, OUTPUT_STYLE_BASIC, OUTPUT_STYLE_NO_COLOR, OUTPUT_STYLE_RICH)
177177

178+
PYTHONPATH = 'PYTHONPATH'
179+
EBPYTHONPREFIXES = 'EBPYTHONPREFIXES'
180+
PYTHON_SEARCH_PATH_TYPES = [PYTHONPATH, EBPYTHONPREFIXES]
181+
178182

179183
class Singleton(ABCMeta):
180184
"""Serves as metaclass for classes that should implement the Singleton pattern.
@@ -336,7 +340,6 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
336340
'modules_tool_version_check',
337341
'mpi_tests',
338342
'pre_create_installdir',
339-
'prefer_ebpythonprefixes',
340343
'show_progress_bar',
341344
'trace',
342345
],
@@ -408,6 +411,9 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
408411
OUTPUT_STYLE_AUTO: [
409412
'output_style',
410413
],
414+
PYTHONPATH: [
415+
'prefer_python_search_path',
416+
]
411417
}
412418
# build option that do not have a perfectly matching command line option
413419
BUILD_OPTIONS_OTHER = {

easybuild/tools/options.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
from easybuild.tools.config import OUTPUT_STYLE_AUTO, OUTPUT_STYLES, WARN
7979
from easybuild.tools.config import get_pretend_installpath, init, init_build_options, mk_full_default_path
8080
from easybuild.tools.config import BuildOptions, ConfigurationVariables
81+
from easybuild.tools.config import PYTHON_SEARCH_PATH_TYPES, PYTHONPATH
8182
from easybuild.tools.configobj import ConfigObj, ConfigObjError
8283
from easybuild.tools.docs import FORMAT_JSON, FORMAT_MD, FORMAT_RST, FORMAT_TXT
8384
from easybuild.tools.docs import avail_cfgfile_constants, avail_easyconfig_constants, avail_easyconfig_licenses
@@ -490,8 +491,10 @@ def override_options(self):
490491
None, 'store_true', False),
491492
'pre-create-installdir': ("Create installation directory before submitting build jobs",
492493
None, 'store_true', True),
493-
'prefer-ebpythonprefixes': (("Prefer EBPYTHONPREFIXES over PYTHONPATH when possible"),
494-
None, 'store_true', False),
494+
'prefer-python-search-path': (("Prefer using specified environment variable when possible to specify where"
495+
" Python packages were installed; see also "
496+
"https://docs.easybuild.io/python-search-path"),
497+
'choice', 'store_or_None', PYTHONPATH, PYTHON_SEARCH_PATH_TYPES),
495498
'pretend': (("Does the build/installation in a test directory located in $HOME/easybuildinstall"),
496499
None, 'store_true', False, 'p'),
497500
'read-only-installdir': ("Set read-only permissions on installation directory after installation",

0 commit comments

Comments
 (0)