I am creating a simple bash script to download and install a python Nagios plugin. On some older servers the script may need to install the subprocess module and as a result I need to make sure the correct python-devel files are installed.
What is an appropriate and cross platform method of checking for these files. Would like to stay away from rpm or apt.
If you can tell me how to do the check from within python that would work. Thanks!
Update:
This is the best I have come up with. Anyone know a better or more conclusive method?
if [ ! -e $(python -c 'from distutils.sysconfig import get_makefile_filename as m; print m()') ]; then echo "Sorry"; fi
That would be pretty much how I would go about doing it. Seems reasonable simple.
However, if I need to be really sure that
python-develfiles are installed for the current version of Python, I would look for the relevantPython.hfile. Something along the lines of:Note:
distutils.sysconfigmay not be supported on all platforms so not the most portable solution, but still better than trying to cater for variations inapt,rpmand the likes.If you really need to support all platforms, it might be worth exploring what is done in the AX_PYTHON_DEVEL m4 module. This module can be used in a
configure.acscript to incorporate checks forpython-develduring the./configurestage of an autotools-based build.