Fix headers order to avoid compiler warnings.

Python-related headers must be first, otherwise there are warnings about
redefinitions of _POSIX_C_SOURCE and _XOPEN_SOURCE.