6 from distutils import sysconfig
8 valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
11 def exit_with_usage(code=1):
12 print >>sys.stderr, "Usage: %s [%s]" % (sys.argv[0],
13 '|'.join('--'+opt for opt in valid_opts))
17 opts, args = getopt.getopt(sys.argv[1:], '', valid_opts)
26 pyver = sysconfig.get_config_var('VERSION')
27 getvar = sysconfig.get_config_var
32 elif opt == '--prefix':
33 print sysconfig.PREFIX
35 elif opt == '--exec-prefix':
36 print sysconfig.EXEC_PREFIX
38 elif opt in ('--includes', '--cflags'):
39 flags = ['-I' + sysconfig.get_python_inc(),
40 '-I' + sysconfig.get_python_inc(plat_specific=True)]
42 flags.extend(getvar('CFLAGS').split())
45 elif opt in ('--libs', '--ldflags'):
46 libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
47 libs.append('-lpython'+pyver)
48 # add the prefix/lib/pythonX.Y/config dir, but only if there is no
49 # shared library in prefix/lib/.
50 if opt == '--ldflags' and not getvar('Py_ENABLE_SHARED'):
51 libs.insert(0, '-L' + getvar('LIBPL'))