diff --git a/easybuild/easyblocks/generic/pythonbundle.py b/easybuild/easyblocks/generic/pythonbundle.py index feb52cddfe..b1a3fe37d2 100644 --- a/easybuild/easyblocks/generic/pythonbundle.py +++ b/easybuild/easyblocks/generic/pythonbundle.py @@ -151,10 +151,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.fake_mod_data = 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 @@ -168,9 +170,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: @@ -186,5 +195,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) diff --git a/easybuild/easyblocks/generic/pythonpackage.py b/easybuild/easyblocks/generic/pythonpackage.py index 396e66b1d8..d4dde65697 100644 --- a/easybuild/easyblocks/generic/pythonpackage.py +++ b/easybuild/easyblocks/generic/pythonpackage.py @@ -1035,10 +1035,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/;