Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion easybuild/tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
'map_toolchains',
'modules_tool_version_check',
'mpi_tests',
'prefer_ebpythonprefix_over_pythonpath',
'pre_create_installdir',
'replace_pythonpath',
'show_progress_bar',
'trace',
],
Expand Down
32 changes: 18 additions & 14 deletions easybuild/tools/module_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from contextlib import contextmanager
from easybuild.tools import LooseVersion
from textwrap import wrap
from typing import Union, Sequence

from easybuild.base import fancylogger
from easybuild.tools.build_log import EasyBuildError, print_warning
Expand Down Expand Up @@ -205,8 +206,10 @@ def get_modules_path(self, fake=False, mod_path_suffix=None):

return os.path.join(mod_path, mod_path_suffix)

def _filter_paths(self, key, paths):
def _filter_paths(self, key: str, paths: list) -> list:
"""Filter out paths already added to key and return the remaining ones"""
assert isinstance(paths, list)

if self.added_paths_per_key is None:
# For compatibility this is only a warning for now and we don't filter any paths
print_warning('Module creation has not been started. Call start_module_creation first!')
Expand All @@ -221,7 +224,7 @@ def _filter_paths(self, key, paths):
log=self.log)
return filtered_paths

def append_paths(self, key, paths, allow_abs=False, expand_relpaths=True):
def append_paths(self, key: str, paths: Union[str, Sequence[str]], allow_abs=False, expand_relpaths=True) -> str:
"""
Generate append-path statements for the given list of paths.

Expand All @@ -232,23 +235,24 @@ def append_paths(self, key, paths, allow_abs=False, expand_relpaths=True):
"""
return self.update_paths(key, paths, prepend=False, allow_abs=allow_abs, expand_relpaths=expand_relpaths)

def prepend_paths(self, key, paths, allow_abs=False, expand_relpaths=True):
def prepend_paths(self, key: str, paths: Union[str, Sequence[str]], allow_abs=False, expand_relpaths=True) -> str:
"""
Generate prepend-path statements for the given list of paths.

:param key: environment variable to append paths to
:param paths: single or list of paths to append
:param paths: single or list of paths to prepend
:param allow_abs: allow providing of absolute paths
:param expand_relpaths: expand relative paths into absolute paths (by prefixing install dir)
"""
return self.update_paths(key, paths, prepend=True, allow_abs=allow_abs, expand_relpaths=expand_relpaths)

def update_paths(self, key, paths, prepend=True, allow_abs=False, expand_relpaths=True):
def update_paths(self, key: str, paths: Union[str, Sequence[str]], prepend=True, allow_abs=False,
expand_relpaths=True) -> str:
"""
Generate append/prepend-path statements for the given list of paths.

:param key: environment variable to append paths to
:param paths: single or list of paths to append
:param paths: single or list of paths to add
:param allow_abs: allow providing of absolute paths
:param expand_relpaths: expand relative paths into absolute paths (by prefixing install dir)
"""
Expand All @@ -264,8 +268,8 @@ def update_paths(self, key, paths, prepend=True, allow_abs=False, expand_relpath
raise EasyBuildError('Found multiple paths for PYTHONPATH: ' + ', '.join(python_paths))

# Special condition for PYTHONPATHs that match the standard pattern,
# replace with EBPYTHONPREFIX which is added to python sys path at runtime
if python_paths and build_option('prefer_ebpythonprefix_over_pythonpath'):
# replace with EBPYTHONPREFIXES which is added to python sys path at runtime via sitecustomize.py
if python_paths and build_option('replace_pythonpath'):
python_path = python_paths[0]
self.log.info("Replaced PYTHONPATH %s with EBPYTHONPREFIXES", python_path)
ret = self._update_paths('EBPYTHONPREFIXES', [''], prepend, allow_abs, expand_relpaths)
Expand Down Expand Up @@ -564,12 +568,12 @@ def unload_module(self, mod_name):
"""
raise NotImplementedError

def _update_paths(self, key, paths, prepend=True, allow_abs=False, expand_relpaths=True):
def _update_paths(self, key: str, paths: list, prepend=True, allow_abs=False, expand_relpaths=True) -> str:
"""
Generate prepend-path or append-path statements for the given list of paths.

:param key: environment variable to prepend/append paths to
:param paths: list of paths to prepend
:param paths: list of paths to add
:param prepend: whether to prepend (True) or append (False) paths
:param allow_abs: allow providing of absolute paths
:param expand_relpaths: expand relative paths into absolute paths (by prefixing install dir)
Expand Down Expand Up @@ -968,12 +972,12 @@ def msg_on_unload(self, msg):
print_cmd = "puts stderr %s" % quote_str(msg, tcl=True)
return '\n'.join(['', self.conditional_statement("module-info mode unload", print_cmd, indent=False)])

def _update_paths(self, key, paths, prepend=True, allow_abs=False, expand_relpaths=True):
def _update_paths(self, key: str, paths: list, prepend=True, allow_abs=False, expand_relpaths=True) -> str:
"""
Generate prepend-path or append-path statements for the given list of paths.

:param key: environment variable to prepend/append paths to
:param paths: list of paths to prepend/append
:param paths: list of paths to add
:param prepend: whether to prepend (True) or append (False) paths
:param allow_abs: allow providing of absolute paths
:param expand_relpaths: expand relative paths into absolute paths (by prefixing install dir)
Expand Down Expand Up @@ -1437,12 +1441,12 @@ def modulerc(self, module_version=None, filepath=None, modulerc_txt=None):
return super(ModuleGeneratorLua, self).modulerc(module_version=module_version, filepath=filepath,
modulerc_txt=modulerc_txt)

def _update_paths(self, key, paths, prepend=True, allow_abs=False, expand_relpaths=True):
def _update_paths(self, key: str, paths: list, prepend=True, allow_abs=False, expand_relpaths=True) -> str:
"""
Generate prepend_path or append_path statements for the given list of paths

:param key: environment variable to prepend/append paths to
:param paths: list of paths to prepend/append
:param paths: list of paths to add
:param prepend: whether to prepend (True) or append (False) paths
:param allow_abs: allow providing of absolute paths
:param expand_relpaths: expand relative paths into absolute paths (by prefixing install dir)
Expand Down
4 changes: 2 additions & 2 deletions easybuild/tools/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,6 @@ def override_options(self):
'int', 'store', None),
'parallel-extensions-install': ("Install list of extensions in parallel (if supported)",
None, 'store_true', False),
'prefer-ebpythonprefix-over-pythonpath': ("Replaces PYTHONPATH with EBPYTHONPREFIX when possible",
None, 'store_true', True),
'pre-create-installdir': ("Create installation directory before submitting build jobs",
None, 'store_true', True),
'pretend': (("Does the build/installation in a test directory located in $HOME/easybuildinstall"),
Expand All @@ -491,6 +489,8 @@ def override_options(self):
'remove-ghost-install-dirs': ("Remove ghost installation directories when --force or --rebuild is used, "
"rather than just warning about them",
None, 'store_true', False),
'replace-pythonpath': ("Replaces PYTHONPATH with EBPYTHONPREFIXES in modules when possible",
None, 'store_true', True),
'required-linked-shared-libs': ("Comma-separated list of shared libraries (names, file names, or paths) "
"which must be linked in all installed binaries/libraries",
'strlist', 'extend', None),
Expand Down