annotate Misc/python-config.in @ 39161:02fa1015cbcc legacy-trunk

Patch #1523356: fix determining include dirs in python-config. Also don't install "python-config" when doing altinstall, but always install "python-config2.x" and make a link to it like with the main executable.
author Georg Brandl <georg@python.org>
date Mon, 24 Jul 2006 13:28:57 +0000
parents 5304059e7de3
children 06145fbc7ab9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39161
02fa1015cbcc Patch #1523356: fix determining include dirs in python-config.
Georg Brandl <georg@python.org>
parents: 37730
diff changeset
1 #!@EXENAME@
37730
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
2
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
3 import sys
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
4 import os
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
5 import getopt
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
6 from distutils import sysconfig
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
7
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
8 valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
9 'ldflags', 'help']
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
10
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
11 def exit_with_usage(code=1):
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
12 print >>sys.stderr, "Usage: %s [%s]" % (sys.argv[0],
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
13 '|'.join('--'+opt for opt in valid_opts))
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
14 sys.exit(code)
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
15
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
16 try:
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
17 opts, args = getopt.getopt(sys.argv[1:], '', valid_opts)
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
18 except getopt.error:
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
19 exit_with_usage()
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
20
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
21 if not opts:
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
22 exit_with_usage()
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
23
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
24 opt = opts[0][0]
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
25
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
26 pyver = sysconfig.get_config_var('VERSION')
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
27 getvar = sysconfig.get_config_var
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
28
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
29 if opt == '--help':
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
30 exit_with_usage(0)
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
31
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
32 elif opt == '--prefix':
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
33 print sysconfig.PREFIX
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
34
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
35 elif opt == '--exec-prefix':
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
36 print sysconfig.EXEC_PREFIX
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
37
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
38 elif opt in ('--includes', '--cflags'):
39161
02fa1015cbcc Patch #1523356: fix determining include dirs in python-config.
Georg Brandl <georg@python.org>
parents: 37730
diff changeset
39 flags = ['-I' + sysconfig.get_python_inc(),
02fa1015cbcc Patch #1523356: fix determining include dirs in python-config.
Georg Brandl <georg@python.org>
parents: 37730
diff changeset
40 '-I' + sysconfig.get_python_inc(plat_specific=True)]
37730
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
41 if opt == '--cflags':
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
42 flags.extend(getvar('CFLAGS').split())
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
43 print ' '.join(flags)
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
44
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
45 elif opt in ('--libs', '--ldflags'):
39161
02fa1015cbcc Patch #1523356: fix determining include dirs in python-config.
Georg Brandl <georg@python.org>
parents: 37730
diff changeset
46 libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
37730
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
47 libs.append('-lpython'+pyver)
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
48 if opt == '--ldflags':
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
49 libs.insert(0, '-L' + getvar('LIBPL'))
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
50 print ' '.join(libs)
5304059e7de3 Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
51