Detecting if a library has native dependency
dieter at handshake.de
Mon Aug 17 08:04:20 CEST 2015
Harish Vishwanath <harish.shastry at gmail.com> writes:
> Is there a reliable way to detect if a python library has native dependency
> or native code? For ex. can I programmatically determine that "lxml"
> package has native code and depends on the presence of libxml on the system?
I do not expect a tool that in all cases can reliably determine such
In simple cases (and "lxml" might be such a case), an import of the
package might reveal a potential problem -- usually, via an "ImportError",
resulting from the fact that the Python module binding to the external
C library cannot be imported (either because it was not built or
because it cannot be initialized). Under "*nix", you can often
use "ldd" to determine on which external C libraries a "shared object"
depends on. Thus, in the second case (Python binding available, but
not initializable), you can often find out what is missing.
However, the import of the Python binding might be delayed. Then,
importing the package will not directly reveal the missing dependencies.
In addition, some packages (e.g. "dm.xmlsec.binding") not only
have an external dependency but depend on specific versions of
a native library. Thus, even if a dependency seems to be satisfied,
there might be a version problem.
Thus, I recommend not to rely on program logic but read the installation
More information about the Python-list