3

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:

  1. cython --embed exec.py
  2. cython apkg.py
  3. cython bpkg.py
  4. gcc -shared -fPIC -O3 -I/usr/include/python3.5m -lpython3.5m apkg.c -o apkg.so
  5. gcc -shared -fPIC -O3 -I/usr/include/python3.5m -lpython3.5m bpkg.c -o bpkg.so
  6. gcc -c -O3 -I/usr/include/python3.5m -lpython3.5m exec.c
  7. 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 include python-config

  • User pkg-config: again, Windows compatibility issue.

Simón Oroño
  • 1,060
  • 3
  • 14
  • 24

0 Answers0