Mercurial > cpython-lru_cache-weakref
annotate Misc/python-config.in @ 80661:94de77bd0b4b 2.7
Issue #16194: document imp.load_dynamic problems
when read several extension modules from the same binary object file.
| author | Andrew Svetlov <andrew.svetlov@gmail.com> |
|---|---|
| date | Thu, 29 Nov 2012 19:51:28 +0200 |
| parents | 77f853fe3cf2 |
| children | bab708624dc4 |
| 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 |
|
59714
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
8 valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags', |
|
37730
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): |
|
59714
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
12 print >>sys.stderr, "Usage: %s [%s]" % (sys.argv[0], |
|
37730
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 pyver = sysconfig.get_config_var('VERSION') |
|
5304059e7de3
Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
25 getvar = sysconfig.get_config_var |
|
5304059e7de3
Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
26 |
|
59714
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
27 opt_flags = [flag for (flag, val) in opts] |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
28 |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
29 if '--help' in opt_flags: |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
30 exit_with_usage(code=0) |
|
37730
5304059e7de3
Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
31 |
|
59714
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
32 for opt in opt_flags: |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
33 if opt == '--prefix': |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
34 print sysconfig.PREFIX |
|
37730
5304059e7de3
Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
35 |
|
59714
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
36 elif opt == '--exec-prefix': |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
37 print sysconfig.EXEC_PREFIX |
|
37730
5304059e7de3
Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
38 |
|
59714
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
39 elif opt in ('--includes', '--cflags'): |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
40 flags = ['-I' + sysconfig.get_python_inc(), |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
41 '-I' + sysconfig.get_python_inc(plat_specific=True)] |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
42 if opt == '--cflags': |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
43 flags.extend(getvar('CFLAGS').split()) |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
44 print ' '.join(flags) |
|
37730
5304059e7de3
Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
45 |
|
59714
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
46 elif opt in ('--libs', '--ldflags'): |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
47 libs = getvar('LIBS').split() + getvar('SYSLIBS').split() |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
48 libs.append('-lpython'+pyver) |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
49 # add the prefix/lib/pythonX.Y/config dir, but only if there is no |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
50 # shared library in prefix/lib/. |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
51 if opt == '--ldflags': |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
52 if not getvar('Py_ENABLE_SHARED'): |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
53 libs.insert(0, '-L' + getvar('LIBPL')) |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
54 libs.extend(getvar('LINKFORSHARED').split()) |
|
77f853fe3cf2
Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag.
Collin Winter <collinw@gmail.com>
parents:
41554
diff
changeset
|
55 print ' '.join(libs) |
|
37730
5304059e7de3
Patch #1161914: Add python-config.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
56 |
