Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,16 @@ them to a local data structure.

Logging Blocked Imports
-----------------------
To see which modules Vext is blocking set VEXT_LOG_BLOCKS instead of
standard ImportErrors, you will get ones like this:
To see which modules Vext is blocking set VEXT_LOG_BLOCKS. Instead of
standard ModuleNotFoundErrors, you will get ones like this:


```bash
$ VEXT_LOG_BLOCKS=1
```
```python
>>> import pyaudio
ImportError("Vext blocked import of pyaudio")
ModuleNotFoundError("Vext blocked import of pyaudio")
```

Remembering Blocked Imports
Expand All @@ -252,7 +252,7 @@ vext.remember_blocks to True:
>>> vext.blocked_imports
set([])
>>> import pygtk
ImportError:
ModuleNotFoundError:
>>> vext.blocked_imports
set(["pygtk"])
```
Expand Down Expand Up @@ -281,4 +281,3 @@ Thanks
ruamel/venvgtk - for showing something like this is possible

pymotw article on modules and imports

1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ def run(self):
'vext.install',
],

python_requires=">=3.6",
setup_requires=["setuptools>=18.0.1", "pip>=1.5.6"],
install_requires=["ruamel.yaml>=0.11.10"],

Expand Down
8 changes: 4 additions & 4 deletions vext/gatekeeper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def __init__(self, module_info, sitedir):
def load_module(self, name):
"""
Only lets modules in allowed_modules be loaded, others
will get an ImportError
will get a ModuleNotFoundError (a type of ImportError)
"""

# Get the name relative to SITEDIR ..
Expand All @@ -198,10 +198,10 @@ def load_module(self, name):
if remember_blocks:
blocked_imports.add(fullname)
if log_blocks:
raise ImportError("Vext blocked import of '%s'" % modulename)
raise ModuleNotFoundError("Vext blocked import of '%s'" % modulename)
else:
# Standard error message
raise ImportError("No module named %s" % modulename)
raise ModuleNotFoundError("No module named %s" % modulename)

if name not in sys.modules:
try:
Expand Down Expand Up @@ -229,7 +229,7 @@ def __init__(self, path_entry):
except Exception as e:
sys.stderr.write("Vext disabled: There was an issue getting the system site packages.\n")
raise ImportError()

if path_entry in (sitedir, GatekeeperFinder.PATH_TRIGGER):
logger.debug("handle entry %s", path_entry)
return
Expand Down