I have a shell script which installs all required packages for a project. Some of those packages are Python 3 based and require to compile things and for this the Python sources need to be installed1 (e.g. the
python3-dev package in common Debian-based distributions). Otherwise, unintelligible/misleading compile error messages will be displayed (missing header files) which is something I want to prevent.
Now I thought it might be best to try to detect whether the Python 3 sources are already installed and in case they aren't not even attempt to run
pip but instead instruct the user to get the Python sources for his/her distribution and maybe also some instructions for the most common ones.
In short: How can I reliably detect whether the Python 3 header files are installed on various distributions (and maybe even in non-Linux environments going as far as Cygwin)?
1. The package is
mypy and parts of the error messages include:
ast27/Parser/acceler.c:13:25: fatal error: pgenheaders.h: No such file or directory compilation terminated.
Command "/path/to/my/venv/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-x0e2zn8t/typed-ast/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-uythmwn1-record/install-record.txt --single-version-externally-managed --compile --install-headers /path/to/my/venv/include/site/python3.5/typed-ast" failed with error code 1 in /tmp/pip-build-x0e2zn8t/typed-ast/