Strip a dependency of unused functions
No, there's no generally applicable way of doing that for Python. There are some heuristics for simple modules, but they're going to fail miserably.
In the specific case of NumPy you'd have to first find out which parts of its underlying C and Fortran code are needed and which aren't, which is a pretty difficult problem in its own right. Even if you can solve that, the fact that NumPy also uses __import__ in several places, including in compiled extension modules, makes it nearly impossible to determine which parts of the code are going to be imported.
I'm just deploying a Django application which uses Matplotlib and Numpy as dependencies. It's a small app, and in the end, the dependency code outweighs the app code by a lot. I'm also getting lots of errors in setting the dependencies in the production environment for methods I'm not directly using in the app.
Is there a method for stripping down a dependecy for it to contain only the things necessary for the app to work?