Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(23)

Side by Side Diff: Lib/ctypes/util.py

Issue 3871: cross and native build of python for mingw32 with distutils
Patch Set: Created 7 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/ctypes/test/test_functions.py ('k') | Lib/distutils/ccompiler.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import sys, os 1 import sys, os
2 import contextlib 2 import contextlib
3 import subprocess 3 import subprocess
4 4
5 # find_library(name) returns the pathname of a library, or None. 5 # find_library(name) returns the pathname of a library, or None.
6 if os.name == "nt": 6 if os.name == "nt":
7 7
8 def _get_build_version(): 8 def _get_build_version():
9 #***********************************************************
10 # NOTE: As example for GCC(mingw) build sys.version return:
11 # '2.7a0 (trunk:<REVISION>M, <DATE>, <TIME>) \n[GCC 3.4.5 (mingw special )]'
12 # '2.7a0 (trunk:<REVISION>M, <DATE>, <TIME>) \n[GCC 4.4.0]'
13 #***********************************************************
9 """Return the version of MSVC that was used to build Python. 14 """Return the version of MSVC that was used to build Python.
10 15
11 For Python 2.3 and up, the version number is included in 16 For Python 2.3 and up, the version number is included in
12 sys.version. For earlier versions, assume the compiler is MSVC 6. 17 sys.version. For earlier versions, assume the compiler is MSVC 6.
13 """ 18 """
14 # This function was copied from Lib/distutils/msvccompiler.py 19 # This function was copied from Lib/distutils/msvccompiler.py
15 prefix = "MSC v." 20 prefix = "MSC v."
16 i = sys.version.find(prefix) 21 i = sys.version.find(prefix)
17 if i == -1: 22 if i == -1:
18 return 6 23 return 6
19 i = i + len(prefix) 24 i = i + len(prefix)
20 s, rest = sys.version[i:].split(" ", 1) 25 s, rest = sys.version[i:].split(" ", 1)
21 majorVersion = int(s[:-2]) - 6 26 majorVersion = int(s[:-2]) - 6
22 minorVersion = int(s[2:3]) / 10.0 27 minorVersion = int(s[2:3]) / 10.0
23 # I don't think paths are affected by minor version in version 6 28 # I don't think paths are affected by minor version in version 6
24 if majorVersion == 6: 29 if majorVersion == 6:
25 minorVersion = 0 30 minorVersion = 0
26 if majorVersion >= 6: 31 if majorVersion >= 6:
27 return majorVersion + minorVersion 32 return majorVersion + minorVersion
28 # else we don't know what version of the compiler this is 33 # else we don't know what version of the compiler this is
29 return None 34 return None
30 35
31 def find_msvcrt(): 36 def find_msvcrt():
37 #************************************************************
38 # FIXME: For GCC(mingw) runtime don't depend from compiler
39 # version ;). We may use -D__MSVCRT_VERSION__ to detect which
40 # verion is requested by user, but the name of the library
41 # to be default.
42 # As example WXP is with version 7.0 of msvcrt.dll.
43 # Anyway since _get_build_version return 6 in most(standard)
44 # cases this method will return msvcrt{d}. May be not so bad.
45 #************************************************************
32 """Return the name of the VC runtime dll""" 46 """Return the name of the VC runtime dll"""
33 version = _get_build_version() 47 version = _get_build_version()
34 if version is None: 48 if version is None:
35 # better be safe than sorry 49 # better be safe than sorry
36 return None 50 return None
37 if version <= 6: 51 if version <= 6:
38 clibname = 'msvcrt' 52 clibname = 'msvcrt'
39 else: 53 else:
40 clibname = 'msvcr%d' % (version * 10) 54 clibname = 'msvcr%d' % (version * 10)
41 55
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 print(cdll.LoadLibrary("libcrypto.dylib")) 241 print(cdll.LoadLibrary("libcrypto.dylib"))
228 print(cdll.LoadLibrary("libSystem.dylib")) 242 print(cdll.LoadLibrary("libSystem.dylib"))
229 print(cdll.LoadLibrary("System.framework/System")) 243 print(cdll.LoadLibrary("System.framework/System"))
230 else: 244 else:
231 print(cdll.LoadLibrary("libm.so")) 245 print(cdll.LoadLibrary("libm.so"))
232 print(cdll.LoadLibrary("libcrypt.so")) 246 print(cdll.LoadLibrary("libcrypt.so"))
233 print(find_library("crypt")) 247 print(find_library("crypt"))
234 248
235 if __name__ == "__main__": 249 if __name__ == "__main__":
236 test() 250 test()
OLDNEW
« no previous file with comments | « Lib/ctypes/test/test_functions.py ('k') | Lib/distutils/ccompiler.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+