Add skip_import to PythonPackage and use it in py-nilearn (#32664)

* Add skip_import to PythonPackage and use it in py-nilearn

* Fix dependencies
This commit is contained in:
Manuela Kuhn
2022-09-18 01:02:30 +02:00
committed by GitHub
parent 2c7c749986
commit d4c13b0f8f
3 changed files with 58 additions and 36 deletions

View File

@@ -138,12 +138,28 @@ def import_modules(self):
path.replace(root + os.sep, "", 1).replace(".py", "").replace("/", ".")
)
modules = [mod for mod in modules if re.match("[a-zA-Z0-9._]+$", mod)]
modules = [
mod
for mod in modules
if re.match("[a-zA-Z0-9._]+$", mod) and not any(map(mod.startswith, self.skip_modules))
]
tty.debug("Detected the following modules: {0}".format(modules))
return modules
@property
def skip_modules(self):
"""Names of modules that should be skipped when running tests.
These are a subset of import_modules. If a module has submodules,
they are skipped as well (meaning a.b is skipped if a is contained).
Returns:
list: list of strings of module names
"""
return []
@property
def build_directory(self):
"""The root directory of the Python package.