Here is my modified version of the AC_PYTHON_MODULE GNU Autoconf M4 macro published at
http://autoconf-archive.cryp.to/ac_python_module.html.
The original version of the macro was unable to take care of multiple versions of Python installed on a system. For example I have Python 2.3.5 and Python 2.4.3 on my system, and if I need to check whether a certain module 'foo' is installed for Python 2.4.3 the macro would not work correctly. This was because of the fact that the macro was ignoring the environment variable PYTHON and directly invoking 'python'. Hence clear demarcation between the two versions was not possible.