annotate Misc/python-config.in @ 70817:dd775b1561ba

Fix markup.
author Georg Brandl <georg@python.org>
date Tue, 14 Jun 2011 21:09:55 +0200
parents 82b083c96a39
children 2d4f290ea71c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1 #!@EXENAME@
65527
82b083c96a39 One more change for issue 9807, by Matthias Klose.
Barry Warsaw <barry@python.org>
parents: 65389
diff changeset
2 # -*- python -*-
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
3
60420
712970b019f7 Fix python-config to use the new sysconfig module; silences deprecation warnings.
Collin Winter <collinw@gmail.com>
parents: 59739
diff changeset
4 import getopt
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
5 import os
60420
712970b019f7 Fix python-config to use the new sysconfig module; silences deprecation warnings.
Collin Winter <collinw@gmail.com>
parents: 59739
diff changeset
6 import sys
712970b019f7 Fix python-config to use the new sysconfig module; silences deprecation warnings.
Collin Winter <collinw@gmail.com>
parents: 59739
diff changeset
7 import sysconfig
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
8
43169
ee1b3eb7a013 Bug #1074: make python-config with Py3k.
Georg Brandl <georg@python.org>
parents: 41554
diff changeset
9 valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
65389
932f97bfbdc0 First (uncontroversial) part of issue 9807.
Barry Warsaw <barry@python.org>
parents: 64686
diff changeset
10 'ldflags', 'extension-suffix', 'help', 'abiflags']
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
11
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
12 def exit_with_usage(code=1):
43169
ee1b3eb7a013 Bug #1074: make python-config with Py3k.
Georg Brandl <georg@python.org>
parents: 41554
diff changeset
13 print("Usage: {0} [{1}]".format(
ee1b3eb7a013 Bug #1074: make python-config with Py3k.
Georg Brandl <georg@python.org>
parents: 41554
diff changeset
14 sys.argv[0], '|'.join('--'+opt for opt in valid_opts)), file=sys.stderr)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
15 sys.exit(code)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
16
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
17 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
18 opts, args = getopt.getopt(sys.argv[1:], '', valid_opts)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
19 except getopt.error:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
20 exit_with_usage()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
21
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
22 if not opts:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
23 exit_with_usage()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
24
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
25 pyver = sysconfig.get_config_var('VERSION')
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
26 getvar = sysconfig.get_config_var
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
27
59739
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
28 opt_flags = [flag for (flag, val) in opts]
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
29
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
30 if '--help' in opt_flags:
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
31 exit_with_usage(code=0)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
32
59739
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
33 for opt in opt_flags:
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
34 if opt == '--prefix':
60420
712970b019f7 Fix python-config to use the new sysconfig module; silences deprecation warnings.
Collin Winter <collinw@gmail.com>
parents: 59739
diff changeset
35 print(sysconfig.get_config_var('prefix'))
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
36
59739
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
37 elif opt == '--exec-prefix':
60420
712970b019f7 Fix python-config to use the new sysconfig module; silences deprecation warnings.
Collin Winter <collinw@gmail.com>
parents: 59739
diff changeset
38 print(sysconfig.get_config_var('exec_prefix'))
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
39
59739
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
40 elif opt in ('--includes', '--cflags'):
60420
712970b019f7 Fix python-config to use the new sysconfig module; silences deprecation warnings.
Collin Winter <collinw@gmail.com>
parents: 59739
diff changeset
41 flags = ['-I' + sysconfig.get_path('include'),
712970b019f7 Fix python-config to use the new sysconfig module; silences deprecation warnings.
Collin Winter <collinw@gmail.com>
parents: 59739
diff changeset
42 '-I' + sysconfig.get_path('platinclude')]
59739
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
43 if opt == '--cflags':
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
44 flags.extend(getvar('CFLAGS').split())
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
45 print(' '.join(flags))
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
46
59739
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
47 elif opt in ('--libs', '--ldflags'):
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
48 libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
65527
82b083c96a39 One more change for issue 9807, by Matthias Klose.
Barry Warsaw <barry@python.org>
parents: 65389
diff changeset
49 libs.append('-lpython' + pyver + sys.abiflags)
59739
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
50 # add the prefix/lib/pythonX.Y/config dir, but only if there is no
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
51 # shared library in prefix/lib/.
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
52 if opt == '--ldflags':
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
53 if not getvar('Py_ENABLE_SHARED'):
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
54 libs.insert(0, '-L' + getvar('LIBPL'))
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
55 libs.extend(getvar('LINKFORSHARED').split())
e43233d80064 Merged revisions 79082,79084 via svnmerge from
Collin Winter <collinw@gmail.com>
parents: 43169
diff changeset
56 print(' '.join(libs))
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
57
64682
6d282b58d90a 9806: add --extension-suffix option to python-config.
Georg Brandl <georg@python.org>
parents: 60420
diff changeset
58 elif opt == '--extension-suffix':
64686
c1b709076bf6 Get rid of tabs.
Georg Brandl <georg@python.org>
parents: 64682
diff changeset
59 print(sysconfig.get_config_var('SO'))
65389
932f97bfbdc0 First (uncontroversial) part of issue 9807.
Barry Warsaw <barry@python.org>
parents: 64686
diff changeset
60
932f97bfbdc0 First (uncontroversial) part of issue 9807.
Barry Warsaw <barry@python.org>
parents: 64686
diff changeset
61 elif opt == '--abiflags':
932f97bfbdc0 First (uncontroversial) part of issue 9807.
Barry Warsaw <barry@python.org>
parents: 64686
diff changeset
62 print(sys.abiflags)