@@ -141,10 +141,12 @@ def sanity_check_step(self, *args, **kwargs):
141141 """Custom sanity check for bundle of Python package."""
142142
143143 if self .pylibdir is None :
144- # Python attributes not set up yet, happens e.g. with --sanity-check-only
145- # Load module first to get the right python command
146- self .fake_mod_data = self .sanity_check_load_module (extension = kwargs .get ('extension' , False ),
147- extra_modules = kwargs .get ('extra_modules' , None ))
144+ # Python attributes not set up yet, happens e.g. with --sanity-check-only, so do it now.
145+ # This also ensures the exts_filter option for extensions is set correctly.
146+ # Load module first to get the right python command.
147+ if not self .sanity_check_module_loaded :
148+ self .fake_mod_data = self .sanity_check_load_module (extension = kwargs .get ('extension' , False ),
149+ extra_modules = kwargs .get ('extra_modules' , None ))
148150 self .prepare_python ()
149151
150152 # inject directory path that uses %(pyshortver)s template into default value for sanity_check_paths
@@ -158,9 +160,16 @@ def sanity_check_step(self, *args, **kwargs):
158160
159161 super (Bundle , self ).sanity_check_step (* args , ** kwargs )
160162
161- # After the super-call self.ext_instances is initialized, so we can check the extensions
163+ def _sanity_check_step_extensions (self ):
164+ """Run the pip check for extensions if enabled"""
165+ super (PythonBundle , self )._sanity_check_step_extensions ()
166+
162167 sanity_pip_check = self .cfg ['sanity_pip_check' ]
163168 unversioned_packages = set (self .cfg ['unversioned_packages' ])
169+
170+ # The options should be set in the main EC and cannot be different between extensions.
171+ # For backwards compatibility and to avoid surprises enable the pip-check if it is enabled
172+ # in the main EC or any extension and build the union of all unversioned_packages.
164173 has_sanity_pip_check_mismatch = False
165174 all_unversioned_packages = unversioned_packages .copy ()
166175 for ext in self .ext_instances :
@@ -176,5 +185,6 @@ def sanity_check_step(self, *args, **kwargs):
176185 if all_unversioned_packages != unversioned_packages :
177186 self .log .deprecated ('For bundles of PythonPackage the unversioned_packages option '
178187 'in the main EasyConfig must be used' , '5.0' )
188+
179189 if sanity_pip_check :
180190 run_pip_check (self .log , self .python_cmd , all_unversioned_packages )
0 commit comments