summaryrefslogtreecommitdiff
path: root/package/python2/patches/patch-setup_py
blob: 0cb811de9d11fdf4dc0bcd299ade4ab3eadef39e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
--- Python-2.7.5.orig/setup.py	2013-05-12 05:32:54.000000000 +0200
+++ Python-2.7.5/setup.py	2013-10-30 14:18:23.000000000 +0100
@@ -74,7 +74,7 @@ def find_file(filename, std_dirs, paths)
     'paths' is a list of additional locations to check; if the file is
         found in one of them, the resulting list will contain the directory.
     """
-    if host_platform == 'darwin':
+    if host_platform == 'darwin' and not cross_compiling:
         # Honor the MacOSX SDK setting when one was specified.
         # An SDK is a directory with the same structure as a real
         # system, but with only header files and libraries.
@@ -84,7 +84,7 @@ def find_file(filename, std_dirs, paths)
     for dir in std_dirs:
         f = os.path.join(dir, filename)
 
-        if host_platform == 'darwin' and is_macosx_sdk_path(dir):
+        if host_platform == 'darwin' and is_macosx_sdk_path(dir) and not cross_compiling:
             f = os.path.join(sysroot, dir[1:], filename)
 
         if os.path.exists(f): return []
@@ -93,7 +93,7 @@ def find_file(filename, std_dirs, paths)
     for dir in paths:
         f = os.path.join(dir, filename)
 
-        if host_platform == 'darwin' and is_macosx_sdk_path(dir):
+        if host_platform == 'darwin' and is_macosx_sdk_path(dir) and not cross_compiling:
             f = os.path.join(sysroot, dir[1:], filename)
 
         if os.path.exists(f):
@@ -107,7 +107,7 @@ def find_library_file(compiler, libname,
     if result is None:
         return None
 
-    if host_platform == 'darwin':
+    if host_platform == 'darwin' and not cross_compiling:
         sysroot = macosx_sdk_root()
 
     # Check whether the found file is in one of the standard directories
@@ -116,7 +116,7 @@ def find_library_file(compiler, libname,
         # Ensure path doesn't end with path separator
         p = p.rstrip(os.sep)
 
-        if host_platform == 'darwin' and is_macosx_sdk_path(p):
+        if host_platform == 'darwin' and is_macosx_sdk_path(p) and not cross_compiling:
             if os.path.join(sysroot, p[1:]) == dirname:
                 return [ ]
 
@@ -129,7 +129,7 @@ def find_library_file(compiler, libname,
         # Ensure path doesn't end with path separator
         p = p.rstrip(os.sep)
 
-        if host_platform == 'darwin' and is_macosx_sdk_path(p):
+        if host_platform == 'darwin' and is_macosx_sdk_path(p) and not cross_compiling:
             if os.path.join(sysroot, p[1:]) == dirname:
                 return [ p ]
 
@@ -162,6 +162,7 @@ class PyBuildExt(build_ext):
 
     def build_extensions(self):
 
+        self.compiler.library_dirs = []
         # Detect which modules should be compiled
         missing = self.detect_modules()
 
@@ -281,6 +282,7 @@ class PyBuildExt(build_ext):
 
     def build_extension(self, ext):
 
+
         if ext.name == '_ctypes':
             if not self.configure_ctypes(ext):
                 return
@@ -437,10 +439,12 @@ class PyBuildExt(build_ext):
 
     def detect_modules(self):
         # Ensure that /usr/local is always used
-        add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
-        add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
+        if not cross_compiling:	
+            add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
+            add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
         self.add_gcc_paths()
-        self.add_multiarch_paths()
+        if not cross_compiling:
+            self.add_multiarch_paths()
 
         # Add paths specified in the environment variables LDFLAGS and
         # CPPFLAGS for header and library files.
@@ -477,7 +481,8 @@ class PyBuildExt(build_ext):
                         add_dir_to_list(dir_list, directory)
 
         if os.path.normpath(sys.prefix) != '/usr' \
-                and not sysconfig.get_config_var('PYTHONFRAMEWORK'):
+                and not sysconfig.get_config_var('PYTHONFRAMEWORK') \
+                and not cross_compiling:
             # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework
             # (PYTHONFRAMEWORK is set) to avoid # linking problems when
             # building a framework with different architectures than
@@ -495,8 +500,13 @@ class PyBuildExt(build_ext):
         # lib_dirs and inc_dirs are used to search for files;
         # if a file is found in one of those directories, it can
         # be assumed that no additional -I,-L directives are needed.
+        if cross_compiling:
+            add_dir_to_list(self.compiler.library_dirs,
+                            sysconfig.get_config_var('srcdir'))
+
         inc_dirs = self.compiler.include_dirs[:]
         lib_dirs = self.compiler.library_dirs[:]
+
         if not cross_compiling:
             for d in (
                 '/usr/include',
@@ -530,7 +540,7 @@ class PyBuildExt(build_ext):
         if host_platform == 'hp-ux11':
             lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32']
 
-        if host_platform == 'darwin':
+        if host_platform == 'darwin' and not cross_compiling:
             # This should work on any unixy platform ;-)
             # If the user has bothered specifying additional -I and -L flags
             # in OPT and LDFLAGS we might as well use them here.