Fix our module import checks.
Review Request #5846 — Created May 20, 2014 and submitted — Latest diff uploaded
We have a number of checks to see if we can import certain modules. For
these, we use a combination ofimport
statements andimp.find_module
calls. The reason is that some modules would fail to import on some
systems usingimp.find_module
.The reason for that is that
imp.find_module
doesn't use registered
importers, and therefore can't find modules in zipped eggs. Furthermore,
our usage would cause leaked open file handles, since if the module is
represented by a .pyc file,imp.find_module
would pre-import it.Instead of dealing with all this, I've added a new, single function for
checking if modules can be imported. All checks in the codebase now use
this instead, giving us consistency and fixing the issues with zipped
eggs.
Unit tests pass.
The dev server could be run against Pillow, which wasn't working here before.
Hand-tested some of our modules that are more complex (like the S3 support in
django-storages), with and without the module.