Skip to content

Commit

Permalink
Merge pull request #4 from boegel/ebpythonprefixes
Browse files Browse the repository at this point in the history
don't use `force_pythonpath` + clarify why we're keeping logic on `$PYTHONPATH` vs `$EBPYTHONPREFIXES` in `PythonBundle` + `PythonPackage` easyblocks
  • Loading branch information
Micket authored Sep 30, 2024
2 parents e4f8a31 + bc1d2b1 commit 64d7ec3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
13 changes: 9 additions & 4 deletions easybuild/easyblocks/generic/pythonbundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,16 @@ def make_module_extra(self, *args, **kwargs):
txt = super(Bundle, self).make_module_extra(*args, **kwargs)

# update $EBPYTHONPREFIXES rather than $PYTHONPATH
# if this Python package was installed for multiple Python versions
# or if we prefer it
# if this Python package was installed for multiple Python versions, or if we prefer it
use_ebpythonprefixes = False
runtime_deps = [dep['name'] for dep in self.cfg.dependencies(runtime_only=True)]
use_ebpythonprefixes = 'Python' in runtime_deps and \
build_option('prefer_python_search_path') == EBPYTHONPREFIXES and not self.cfg['force_pythonpath']

if 'Python' in runtime_deps:
self.log.info("Found Python runtime dependency, so considering $EBPYTHONPREFIXES...")
if build_option('prefer_python_search_path') == EBPYTHONPREFIXES:
self.log.info("Preferred Python search path is $EBPYTHONPREFIXES, so using that")
use_ebpythonprefixes = True

if self.multi_python or use_ebpythonprefixes:
path = '' # EBPYTHONPREFIXES are relative to the install dir
if path not in self.module_generator.added_paths_per_key[EBPYTHONPREFIXES]:
Expand Down
15 changes: 11 additions & 4 deletions easybuild/easyblocks/generic/pythonpackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,11 +1162,18 @@ def make_module_extra(self, *args, **kwargs):
txt = ''

# update $EBPYTHONPREFIXES rather than $PYTHONPATH
# if this Python package was installed for multiple Python versions
# or if we prefer it
# if this Python package was installed for multiple Python versions, or if we prefer it;
# note: although EasyBuild framework also has logic for this in EasyBlock.make_module_extra,
# we retain full control here, since the logic is slightly different
use_ebpythonprefixes = False
runtime_deps = [dep['name'] for dep in self.cfg.dependencies(runtime_only=True)]
use_ebpythonprefixes = 'Python' in runtime_deps and \
build_option('prefer_python_search_path') == EBPYTHONPREFIXES and not self.cfg['force_pythonpath']

if 'Python' in runtime_deps:
self.log.info("Found Python runtime dependency, so considering $EBPYTHONPREFIXES...")
if build_option('prefer_python_search_path') == EBPYTHONPREFIXES:
self.log.info("Preferred Python search path is $EBPYTHONPREFIXES, so using that")
use_ebpythonprefixes = True

if self.multi_python or use_ebpythonprefixes:
path = '' # EBPYTHONPREFIXES are relative to the install dir
txt += self.module_generator.prepend_paths(EBPYTHONPREFIXES, path)
Expand Down

0 comments on commit 64d7ec3

Please sign in to comment.