Next: , Previous: Verifying the Python version, Up: configure.ac


5.1.3 Checking for a module or function

It's reasonable to assume that many Python packages will have dependencies on other, external modules. With the provided pyconfigure macros, it is simple to check for the presence of dependencies on the system. All you have to do is use the PC_PYTHON_CHECK_MODULE macro as follows:

     PC_PYTHON_CHECK_MODULE([foo])

In this example, we checked for the presence of a module “foo.”

If the module is a hard requirement, you may provide actions to do if it is not present:

     PC_PYTHON_CHECK_MODULE([foo], , AC_MSG_ERROR([Module foo is not installed]))

If you need more fine-grained control, you can also test for a specific function, for example foo.bar(arg1, arg2):

     PC_PYTHON_CHECK_FUNC([foo], [bar], [arg1, arg2])

Remember that you may omit arguments to Autoconf macros: in the previous example, the final two arguments, which correspond to the action to take if the test is successful and if it fails simply are not present in the argument list. Similarly, if you do not need to pass arguments to the test function, you can entirely omit the third argument to the macro:

     PC_PYTHON_CHECK_FUNC([foo], [bar])