Mercurial > cpython-lru_cache-weakref
annotate Lib/ctypes/util.py @ 79691:05c8928362ee
Merge __next__ method link fixes with 3.3.
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Fri, 12 Oct 2012 13:46:37 +0300 |
| parents | 460407f35aa9 |
| children | 73574de2068b |
| rev | line source |
|---|---|
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1 import sys, os |
|
56687
9eb79e94204d
Changed try/finally to contextlib.closing, as discussed in issue 6882.
Eric Smith <eric@trueblade.com>
parents:
56073
diff
changeset
|
2 import contextlib |
|
69533
19d9f0a177de
Issue #11258: Speed up ctypes.util.find_library() under Linux by a factor
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
3 import subprocess |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
4 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
5 # find_library(name) returns the pathname of a library, or None. |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
6 if os.name == "nt": |
|
47230
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
7 |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
8 def _get_build_version(): |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
9 """Return the version of MSVC that was used to build Python. |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
10 |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
11 For Python 2.3 and up, the version number is included in |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
12 sys.version. For earlier versions, assume the compiler is MSVC 6. |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
13 """ |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
14 # This function was copied from Lib/distutils/msvccompiler.py |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
15 prefix = "MSC v." |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
16 i = sys.version.find(prefix) |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
17 if i == -1: |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
18 return 6 |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
19 i = i + len(prefix) |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
20 s, rest = sys.version[i:].split(" ", 1) |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
21 majorVersion = int(s[:-2]) - 6 |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
22 minorVersion = int(s[2:3]) / 10.0 |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
23 # I don't think paths are affected by minor version in version 6 |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
24 if majorVersion == 6: |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
25 minorVersion = 0 |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
26 if majorVersion >= 6: |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
27 return majorVersion + minorVersion |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
28 # else we don't know what version of the compiler this is |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
29 return None |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
30 |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
31 def find_msvcrt(): |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
32 """Return the name of the VC runtime dll""" |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
33 version = _get_build_version() |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
34 if version is None: |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
35 # better be safe than sorry |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
36 return None |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
37 if version <= 6: |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
38 clibname = 'msvcrt' |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
39 else: |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
40 clibname = 'msvcr%d' % (version * 10) |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
41 |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
42 # If python was built with in debug mode |
|
76874
b81ddaf0db47
Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents:
74932
diff
changeset
|
43 import importlib.machinery |
|
b81ddaf0db47
Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents:
74932
diff
changeset
|
44 if '_d.pyd' in importlib.machinery.EXTENSION_SUFFIXES: |
|
47230
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
45 clibname += 'd' |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
46 return clibname+'.dll' |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
47 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
48 def find_library(name): |
|
47230
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
49 if name in ('c', 'm'): |
|
a218d5cb258b
Merged revisions 63395-63396,63511,63522-63523 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
45049
diff
changeset
|
50 return find_msvcrt() |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
51 # See MSDN for the REAL search order. |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
52 for directory in os.environ['PATH'].split(os.pathsep): |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
53 fname = os.path.join(directory, name) |
|
53809
d3ffb3702c3a
Merged revisions 72354 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
50720
diff
changeset
|
54 if os.path.isfile(fname): |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
55 return fname |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
56 if fname.lower().endswith(".dll"): |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
57 continue |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
58 fname = fname + ".dll" |
|
53809
d3ffb3702c3a
Merged revisions 72354 via svnmerge from
Thomas Heller <theller@ctypes.org>
parents:
50720
diff
changeset
|
59 if os.path.isfile(fname): |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
60 return fname |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
61 return None |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
62 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
63 if os.name == "ce": |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
64 # search path according to MSDN: |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
65 # - absolute path specified by filename |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
66 # - The .exe launch directory |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
67 # - the Windows directory |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
68 # - ROM dll files (where are they?) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
69 # - OEM specified search path: HKLM\Loader\SystemPath |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
70 def find_library(name): |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
71 return name |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
72 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
73 if os.name == "posix" and sys.platform == "darwin": |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
74 from ctypes.macholib.dyld import dyld_find as _dyld_find |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
75 def find_library(name): |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
76 possible = ['lib%s.dylib' % name, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
77 '%s.dylib' % name, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
78 '%s.framework/%s' % (name, name)] |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
79 for name in possible: |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
80 try: |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
81 return _dyld_find(name) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
82 except ValueError: |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
83 continue |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
84 return None |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
85 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
86 elif os.name == "posix": |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
87 # Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
88 import re, tempfile, errno |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
89 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
90 def _findLib_gcc(name): |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
91 expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
92 fdout, ccout = tempfile.mkstemp() |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
93 os.close(fdout) |
|
50706
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
94 cmd = 'if type gcc >/dev/null 2>&1; then CC=gcc; elif type cc >/dev/null 2>&1; then CC=cc;else exit 10; fi;' \ |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
95 '$CC -Wl,-t -o ' + ccout + ' 2>&1 -l' + name |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
96 try: |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
97 f = os.popen(cmd) |
|
44280
e176b4aea9c5
Explicitly close pipes so test_ctypes won't appear to randomly leak
Guido van Rossum <guido@python.org>
parents:
44160
diff
changeset
|
98 try: |
|
e176b4aea9c5
Explicitly close pipes so test_ctypes won't appear to randomly leak
Guido van Rossum <guido@python.org>
parents:
44160
diff
changeset
|
99 trace = f.read() |
|
e176b4aea9c5
Explicitly close pipes so test_ctypes won't appear to randomly leak
Guido van Rossum <guido@python.org>
parents:
44160
diff
changeset
|
100 finally: |
|
50706
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
101 rv = f.close() |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
102 finally: |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
103 try: |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
104 os.unlink(ccout) |
|
40587
6b18a095c2e7
SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents:
39442
diff
changeset
|
105 except OSError as e: |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
106 if e.errno != errno.ENOENT: |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
107 raise |
|
50706
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
108 if rv == 10: |
|
50720
0f1e4ab95655
Merged revisions 68511 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
50706
diff
changeset
|
109 raise OSError('gcc or cc command not found') |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
110 res = re.search(expr, trace) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
111 if not res: |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
112 return None |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
113 return res.group(0) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
114 |
|
43400
1bac386c17cc
Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
42253
diff
changeset
|
115 |
|
1bac386c17cc
Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
42253
diff
changeset
|
116 if sys.platform == "sunos5": |
|
1bac386c17cc
Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
42253
diff
changeset
|
117 # use /usr/ccs/bin/dump on solaris |
|
1bac386c17cc
Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
42253
diff
changeset
|
118 def _get_soname(f): |
|
1bac386c17cc
Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
42253
diff
changeset
|
119 if not f: |
|
1bac386c17cc
Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
42253
diff
changeset
|
120 return None |
|
1bac386c17cc
Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
42253
diff
changeset
|
121 cmd = "/usr/ccs/bin/dump -Lpv 2>/dev/null " + f |
|
56687
9eb79e94204d
Changed try/finally to contextlib.closing, as discussed in issue 6882.
Eric Smith <eric@trueblade.com>
parents:
56073
diff
changeset
|
122 with contextlib.closing(os.popen(cmd)) as f: |
|
44280
e176b4aea9c5
Explicitly close pipes so test_ctypes won't appear to randomly leak
Guido van Rossum <guido@python.org>
parents:
44160
diff
changeset
|
123 data = f.read() |
|
e176b4aea9c5
Explicitly close pipes so test_ctypes won't appear to randomly leak
Guido van Rossum <guido@python.org>
parents:
44160
diff
changeset
|
124 res = re.search(r'\[.*\]\sSONAME\s+([^\s]+)', data) |
|
43400
1bac386c17cc
Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
42253
diff
changeset
|
125 if not res: |
|
1bac386c17cc
Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
42253
diff
changeset
|
126 return None |
|
1bac386c17cc
Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
42253
diff
changeset
|
127 return res.group(1) |
|
1bac386c17cc
Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
42253
diff
changeset
|
128 else: |
|
1bac386c17cc
Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
42253
diff
changeset
|
129 def _get_soname(f): |
|
1bac386c17cc
Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
42253
diff
changeset
|
130 # assuming GNU binutils / ELF |
|
1bac386c17cc
Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
42253
diff
changeset
|
131 if not f: |
|
1bac386c17cc
Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
42253
diff
changeset
|
132 return None |
|
50706
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
133 cmd = 'if ! type objdump >/dev/null 2>&1; then exit 10; fi;' \ |
|
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
134 "objdump -p -j .dynamic 2>/dev/null " + f |
|
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
135 f = os.popen(cmd) |
|
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
136 dump = f.read() |
|
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
137 rv = f.close() |
|
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
138 if rv == 10: |
|
50720
0f1e4ab95655
Merged revisions 68511 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
50706
diff
changeset
|
139 raise OSError('objdump command not found') |
|
70376
c540b18b00b9
Issue #12045: Avoid duplicate execution of command in ctypes.util._get_soname().
Antoine Pitrou <solipsis@pitrou.net>
parents:
69534
diff
changeset
|
140 res = re.search(r'\sSONAME\s+([^\s]+)', dump) |
|
43400
1bac386c17cc
Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
42253
diff
changeset
|
141 if not res: |
|
1bac386c17cc
Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
42253
diff
changeset
|
142 return None |
|
1bac386c17cc
Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
42253
diff
changeset
|
143 return res.group(1) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
144 |
|
72011
b5ccdf7c032a
Issue #12326: refactor usage of sys.platform
Victor Stinner <victor.stinner@haypocalc.com>
parents:
70376
diff
changeset
|
145 if sys.platform.startswith(("freebsd", "openbsd", "dragonfly")): |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
146 |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
147 def _num_version(libname): |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
148 # "libxyz.so.MAJOR.MINOR" => [ MAJOR, MINOR ] |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
149 parts = libname.split(".") |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
150 nums = [] |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
151 try: |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
152 while parts: |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
153 nums.insert(0, int(parts.pop())) |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
154 except ValueError: |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
155 pass |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43400
diff
changeset
|
156 return nums or [ sys.maxsize ] |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
157 |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
158 def find_library(name): |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
159 ename = re.escape(name) |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
160 expr = r':-l%s\.\S+ => \S*/(lib%s\.\S+)' % (ename, ename) |
|
56687
9eb79e94204d
Changed try/finally to contextlib.closing, as discussed in issue 6882.
Eric Smith <eric@trueblade.com>
parents:
56073
diff
changeset
|
161 with contextlib.closing(os.popen('/sbin/ldconfig -r 2>/dev/null')) as f: |
|
44280
e176b4aea9c5
Explicitly close pipes so test_ctypes won't appear to randomly leak
Guido van Rossum <guido@python.org>
parents:
44160
diff
changeset
|
162 data = f.read() |
|
e176b4aea9c5
Explicitly close pipes so test_ctypes won't appear to randomly leak
Guido van Rossum <guido@python.org>
parents:
44160
diff
changeset
|
163 res = re.findall(expr, data) |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
164 if not res: |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
165 return _get_soname(_findLib_gcc(name)) |
|
45049
90e86ee3684b
Convert some custom sort comparison functions to equivalent key functions.
Raymond Hettinger <python@rcn.com>
parents:
44280
diff
changeset
|
166 res.sort(key=_num_version) |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
167 return res[-1] |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
168 |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
169 else: |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
170 |
|
50706
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
171 def _findSoname_ldconfig(name): |
|
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
172 import struct |
|
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
173 if struct.calcsize('l') == 4: |
|
77701
460407f35aa9
Issue #15118: Change return value of os.uname() and os.times() from
Larry Hastings <larry@hastings.org>
parents:
76874
diff
changeset
|
174 machine = os.uname().machine + '-32' |
|
50706
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
175 else: |
|
77701
460407f35aa9
Issue #15118: Change return value of os.uname() and os.times() from
Larry Hastings <larry@hastings.org>
parents:
76874
diff
changeset
|
176 machine = os.uname().machine + '-64' |
|
50706
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
177 mach_map = { |
|
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
178 'x86_64-64': 'libc6,x86-64', |
|
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
179 'ppc64-64': 'libc6,64bit', |
|
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
180 'sparc64-64': 'libc6,64bit', |
|
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
181 's390x-64': 'libc6,64bit', |
|
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
182 'ia64-64': 'libc6,IA-64', |
|
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
183 } |
|
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
184 abi_type = mach_map.get(machine, 'libc6') |
|
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
185 |
|
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
186 # XXX assuming GLIBC's ldconfig (with option -p) |
|
69533
19d9f0a177de
Issue #11258: Speed up ctypes.util.find_library() under Linux by a factor
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
187 regex = os.fsencode( |
|
19d9f0a177de
Issue #11258: Speed up ctypes.util.find_library() under Linux by a factor
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
188 '\s+(lib%s\.[^\s]+)\s+\(%s' % (re.escape(name), abi_type)) |
|
19d9f0a177de
Issue #11258: Speed up ctypes.util.find_library() under Linux by a factor
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
189 try: |
|
19d9f0a177de
Issue #11258: Speed up ctypes.util.find_library() under Linux by a factor
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
190 with subprocess.Popen(['/sbin/ldconfig', '-p'], |
|
19d9f0a177de
Issue #11258: Speed up ctypes.util.find_library() under Linux by a factor
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
191 stdin=subprocess.DEVNULL, |
|
19d9f0a177de
Issue #11258: Speed up ctypes.util.find_library() under Linux by a factor
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
192 stderr=subprocess.DEVNULL, |
|
19d9f0a177de
Issue #11258: Speed up ctypes.util.find_library() under Linux by a factor
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
193 stdout=subprocess.PIPE, |
|
19d9f0a177de
Issue #11258: Speed up ctypes.util.find_library() under Linux by a factor
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
194 env={'LC_ALL': 'C', 'LANG': 'C'}) as p: |
|
19d9f0a177de
Issue #11258: Speed up ctypes.util.find_library() under Linux by a factor
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
195 res = re.search(regex, p.stdout.read()) |
|
19d9f0a177de
Issue #11258: Speed up ctypes.util.find_library() under Linux by a factor
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
196 if res: |
|
19d9f0a177de
Issue #11258: Speed up ctypes.util.find_library() under Linux by a factor
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
197 return os.fsdecode(res.group(1)) |
|
19d9f0a177de
Issue #11258: Speed up ctypes.util.find_library() under Linux by a factor
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
198 except OSError: |
|
19d9f0a177de
Issue #11258: Speed up ctypes.util.find_library() under Linux by a factor
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
199 pass |
|
50706
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
200 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40587
diff
changeset
|
201 def find_library(name): |
|
50706
ef4bd7708ad7
Merge r68489 from svn+ssh://pythondev@svn.python.org/python/branches/py3k:
Matthias Klose <doko@ubuntu.com>
parents:
47230
diff
changeset
|
202 return _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name)) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
203 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
204 ################################################################ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
205 # test code |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
206 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
207 def test(): |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
208 from ctypes import cdll |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
209 if os.name == "nt": |
|
40775
4cdf21a0dbbc
Fix most trivially-findable print statements.
Guido van Rossum <guido@python.org>
parents:
40643
diff
changeset
|
210 print(cdll.msvcrt) |
|
4cdf21a0dbbc
Fix most trivially-findable print statements.
Guido van Rossum <guido@python.org>
parents:
40643
diff
changeset
|
211 print(cdll.load("msvcrt")) |
|
4cdf21a0dbbc
Fix most trivially-findable print statements.
Guido van Rossum <guido@python.org>
parents:
40643
diff
changeset
|
212 print(find_library("msvcrt")) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
213 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
214 if os.name == "posix": |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
215 # find and load_version |
|
40775
4cdf21a0dbbc
Fix most trivially-findable print statements.
Guido van Rossum <guido@python.org>
parents:
40643
diff
changeset
|
216 print(find_library("m")) |
|
4cdf21a0dbbc
Fix most trivially-findable print statements.
Guido van Rossum <guido@python.org>
parents:
40643
diff
changeset
|
217 print(find_library("c")) |
|
4cdf21a0dbbc
Fix most trivially-findable print statements.
Guido van Rossum <guido@python.org>
parents:
40643
diff
changeset
|
218 print(find_library("bz2")) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
219 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
220 # getattr |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
221 ## print cdll.m |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
222 ## print cdll.bz2 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
223 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
224 # load |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
225 if sys.platform == "darwin": |
|
40775
4cdf21a0dbbc
Fix most trivially-findable print statements.
Guido van Rossum <guido@python.org>
parents:
40643
diff
changeset
|
226 print(cdll.LoadLibrary("libm.dylib")) |
|
4cdf21a0dbbc
Fix most trivially-findable print statements.
Guido van Rossum <guido@python.org>
parents:
40643
diff
changeset
|
227 print(cdll.LoadLibrary("libcrypto.dylib")) |
|
4cdf21a0dbbc
Fix most trivially-findable print statements.
Guido van Rossum <guido@python.org>
parents:
40643
diff
changeset
|
228 print(cdll.LoadLibrary("libSystem.dylib")) |
|
4cdf21a0dbbc
Fix most trivially-findable print statements.
Guido van Rossum <guido@python.org>
parents:
40643
diff
changeset
|
229 print(cdll.LoadLibrary("System.framework/System")) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
230 else: |
|
40775
4cdf21a0dbbc
Fix most trivially-findable print statements.
Guido van Rossum <guido@python.org>
parents:
40643
diff
changeset
|
231 print(cdll.LoadLibrary("libm.so")) |
|
4cdf21a0dbbc
Fix most trivially-findable print statements.
Guido van Rossum <guido@python.org>
parents:
40643
diff
changeset
|
232 print(cdll.LoadLibrary("libcrypt.so")) |
|
4cdf21a0dbbc
Fix most trivially-findable print statements.
Guido van Rossum <guido@python.org>
parents:
40643
diff
changeset
|
233 print(find_library("crypt")) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
234 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
235 if __name__ == "__main__": |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
236 test() |
