-
Notifications
You must be signed in to change notification settings - Fork 17
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
In the pex bootstrap code, the ModuleDirImport class is able to act as a meta path finder owing to its implementation of find_distributions, but only does so if the distribution metadata lookup (e.g. via importlib.metadata.version) occurs after the module in question has been imported by the interpreter. The root cause is the check on whether the module name exists in sys.modules, which for pex-packed modules will have been added in load_module:
python-rules/tools/please_pex/pex/pex_main.py
Line 207 in fba6378
| sys.modules[fullname] = module |
python-rules/tools/please_pex/pex/pex_main.py
Line 253 in fba6378
| if context.name in sys.modules: |
Ultimately, it means that while this succeeds:
import importlib.metadata
import somemodule
importlib.metadata.version("somemodule")This fails:
import importlib.metadata
importlib.metadata.version("somemodule")
# importlib.metadata.PackageNotFoundError: No package metadata was found for somemoduleReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working