Prelude
In linux one can run:
$ pkg-config --cflags --libs python3
and get as result:
-I/usr/include/python3.5m -lpython3.5m
Problem
I want to get this result programatically from a Python script in both Linux and Windows.
Motivation
I have several Python scripts that I want to compile as C using cython. I'm trying to create a Python script that would handle this compilation process.
Having three files: exec.py
, apkg.py
, bpkg.py
; the desired execution order would be:
cython --embed exec.py
cython apkg.py
cython bpkg.py
gcc -shared -fPIC -O3 -I/usr/include/python3.5m -lpython3.5m apkg.c -o apkg.so
gcc -shared -fPIC -O3 -I/usr/include/python3.5m -lpython3.5m bpkg.c -o bpkg.so
gcc -c -O3 -I/usr/include/python3.5m -lpython3.5m exec.c
gcc -o exec exec.o
And exec
would be a compiled executable that needs apkg.so and bpkg.so in the same directory to run.
Posible answers
Use
python-config
: as of version 3.5, the Python installer for Windows (tried in 64 bits) does not includepython-config
User
pkg-config
: again, Windows compatibility issue.