Fix to allow pip install -e . to work seamlessly with newer pip/setuptools versions#4884
Fix to allow pip install -e . to work seamlessly with newer pip/setuptools versions#4884Crivella wants to merge 2 commits intoeasybuilders:developfrom
pip install -e . to work seamlessly with newer pip/setuptools versions#4884Conversation
pip install -e . to work seamlessly with newer pip/setuptools versionspip install -e . to work seamlessly with newer pip/setuptools versions
| try: | ||
| mod = importlib.import_module(namespace) | ||
| except ImportError as err: | ||
| raise EasyBuildError("import_available_modules: Failed to import %s: %s", namespace, err) |
There was a problem hiding this comment.
This changes the semantics of import_available_modules, since no hard error was being raised before when the specified namespace didn't exist?
There was a problem hiding this comment.
For what i can see import_available_modules is always used to import all sub-modules of a specific namespace similar to doing a from NAMESPACE import *.
In particular for #4451 the failure would be obfuscated as something EB requires missing
I did not see a use in framework where this is expected to fail the import with it not being a problem.
If we really wanted to preserve the original behavior we could add a strict parameter to the call that default to False and set it to true everywhere this is used
|
On a sidenote we could also modernize the fetching of the submodules using pkg_util.iter_modules following an approach similar to https://www.tutorialspoint.com/how-do-i-import-all-the-submodules-of-a-python-namespace-package EGImporting installed packageImporting from current dirWith python 3.6 in a docker containerRan @boegel What do you think? Happy to add it in this or another PR (rewriting the 1-line version to be clearer) |
Fixes
ebcommand fails outside of framework source folder #4451The idea here is instead of relying on
sys.pathwhich might not include everything python knows how to import, we rely on python's import functions to determine if a module is importable or not and than pick the path from the imported module