How to block import of specific python package?
Question: I need to programmatically block import of a python package and all child
packages.

For example, I need to block loading of the package "foo" and also ensure that
all children of foo such as "foo.bar" cannot be imported.

How can this be achieved in python 2.x without restructuring my site packages
or PYTHONPATH?

For context, the intent is to programmatically avoid the risk of importing
proprietary code into GPL licensed code.


Answer: This might not fit your solution _exactly_ but you can simply mock out the
entire module so the module and all of it's submodules have no effect:

<https://pypi.python.org/pypi/mock>

