Skip to content

Commit f78c6f6

Browse files
committed
Fix failing sanity check due to (fake) module not being loaded
1 parent 6a890da commit f78c6f6

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

easybuild/easyblocks/generic/pythonbundle.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,12 @@ def sanity_check_step(self, *args, **kwargs):
166166
"""Custom sanity check for bundle of Python package."""
167167

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

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

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

186-
# After the super-call self.ext_instances is initialized, so we can check the extensions
188+
def _sanity_check_step_extensions(self):
189+
"""Run the pip check for extensions if enabled"""
190+
super(PythonBundle, self)._sanity_check_step_extensions()
191+
187192
sanity_pip_check = self.cfg['sanity_pip_check']
188193
unversioned_packages = set(self.cfg['unversioned_packages'])
194+
195+
# The options should be set in the main EC and cannot be different between extensions.
196+
# For backwards compatibility and to avoid surprises enable the pip-check if it is enabled
197+
# in the main EC or any extension and build the union of all unversioned_packages.
189198
has_sanity_pip_check_mismatch = False
190199
all_unversioned_packages = unversioned_packages.copy()
191200
for ext in self.ext_instances:
@@ -201,5 +210,6 @@ def sanity_check_step(self, *args, **kwargs):
201210
if all_unversioned_packages != unversioned_packages:
202211
self.log.deprecated('For bundles of PythonPackage the unversioned_packages option '
203212
'in the main EasyConfig must be used', '5.0')
213+
204214
if sanity_pip_check:
205215
run_pip_check(self.log, self.python_cmd, all_unversioned_packages)

easybuild/easyblocks/generic/pythonpackage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,10 +1061,10 @@ def sanity_check_step(self, *args, **kwargs):
10611061
# load module early ourselves rather than letting parent sanity_check_step method do so,
10621062
# since custom actions taken below require that environment is set up properly already
10631063
# (especially when using --sanity-check-only)
1064-
if hasattr(self, 'sanity_check_module_loaded') and not self.sanity_check_module_loaded:
1064+
if not self.sanity_check_module_loaded:
10651065
extension = self.is_extension or kwargs.get('extension', False)
10661066
extra_modules = kwargs.get('extra_modules', None)
1067-
self.fake_mod_data = self.sanity_check_load_module(extension=extension, extra_modules=extra_modules)
1067+
self.sanity_check_load_module(extension=extension, extra_modules=extra_modules)
10681068

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

0 commit comments

Comments
 (0)