Вы можете сгенерировать файл pxi и включить его перед выполнением IF (так же, как и ./configure генерировать config.h). Вот что мы делаем в Kivy setup.py, например:
c_options = {
'use_opengl_es2': True,
'use_opengl_debug': False,
'use_glew': False,
'use_mesagl': False}
print 'Generate config.pxi'
with open(join(dirname(__file__), 'kivy', 'graphics', 'config.pxi'), 'w') as fd:
for k, v in c_options.iteritems():
fd.write('DEF %s = %d\n' % (k.upper(), int(v)))
А потом в вашем pxd:
include "config.pxi"
IF USE_OPENGL_DEBUG == 1:
# do other import or whatever you want