Skip to content

Commit

Permalink
Fix failing sanity check due to (fake) module not being loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Oct 11, 2024
1 parent 7726432 commit 06ab742
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
20 changes: 15 additions & 5 deletions easybuild/easyblocks/generic/pythonbundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ def sanity_check_step(self, *args, **kwargs):
"""Custom sanity check for bundle of Python package."""

if self.pylibdir is None:
# Python attributes not set up yet, happens e.g. with --sanity-check-only
# Load module first to get the right python command
self.fake_mod_data = self.sanity_check_load_module(extension=kwargs.get('extension', False),
extra_modules=kwargs.get('extra_modules', None))
# Python attributes not set up yet, happens e.g. with --sanity-check-only, so do it now.
# This also ensures the exts_filter option for extensions is set correctly.
# Load module first to get the right python command.
if not self.sanity_check_module_loaded:
self.sanity_check_load_module(extension=kwargs.get('extension', False),
extra_modules=kwargs.get('extra_modules', None))
self.prepare_python()

# inject directory path that uses %(pyshortver)s template into default value for sanity_check_paths
Expand All @@ -181,9 +183,16 @@ def sanity_check_step(self, *args, **kwargs):

super(Bundle, self).sanity_check_step(*args, **kwargs)

# After the super-call self.ext_instances is initialized, so we can check the extensions
def _sanity_check_step_extensions(self):
"""Run the pip check for extensions if enabled"""
super(PythonBundle, self)._sanity_check_step_extensions()

sanity_pip_check = self.cfg['sanity_pip_check']
unversioned_packages = set(self.cfg['unversioned_packages'])

# The options should be set in the main EC and cannot be different between extensions.
# For backwards compatibility and to avoid surprises enable the pip-check if it is enabled
# in the main EC or any extension and build the union of all unversioned_packages.
has_sanity_pip_check_mismatch = False
all_unversioned_packages = unversioned_packages.copy()
for ext in self.ext_instances:
Expand All @@ -199,5 +208,6 @@ def sanity_check_step(self, *args, **kwargs):
if all_unversioned_packages != unversioned_packages:
self.log.deprecated('For bundles of PythonPackage the unversioned_packages option '
'in the main EasyConfig must be used', '5.0')

if sanity_pip_check:
run_pip_check(self.log, self.python_cmd, all_unversioned_packages)
4 changes: 2 additions & 2 deletions easybuild/easyblocks/generic/pythonpackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,10 +1066,10 @@ def sanity_check_step(self, *args, **kwargs):
# load module early ourselves rather than letting parent sanity_check_step method do so,
# since custom actions taken below require that environment is set up properly already
# (especially when using --sanity-check-only)
if hasattr(self, 'sanity_check_module_loaded') and not self.sanity_check_module_loaded:
if not self.sanity_check_module_loaded:
extension = self.is_extension or kwargs.get('extension', False)
extra_modules = kwargs.get('extra_modules', None)
self.fake_mod_data = self.sanity_check_load_module(extension=extension, extra_modules=extra_modules)
self.sanity_check_load_module(extension=extension, extra_modules=extra_modules)

# don't add user site directory to sys.path (equivalent to python -s)
# see https://www.python.org/dev/peps/pep-0370/;
Expand Down

0 comments on commit 06ab742

Please sign in to comment.