summaryrefslogtreecommitdiff
path: root/data/_python-3.7.3/setup.patch
blob: 6ac2390b709b45a762dca6a0eced2cbfda5c6b99 (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
--- Python-3.7.3/setup.py	2019-03-25 20:21:05.000000000 +0000
+++ Python-3.7.3+iPhone/setup.py	2019-04-11 20:54:37.306532874 +0000
@@ -18,6 +18,9 @@
 
 cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ
 
+#if cross_compiling:
+#    sys.platform = 'darwin'
+
 # Set common compiler and linker flags derived from the Makefile,
 # reserved for building the interpreter and the stdlib modules.
 # See bpo-21121 and bpo-35257
@@ -98,7 +101,7 @@
     cflags = sysconfig.get_config_var('CFLAGS')
     m = re.search(r'-isysroot\s+(\S+)', cflags)
     if m is None:
-        sysroot = '/'
+        sysroot = os.environ['PKG_ROOT'] or '/'
     else:
         sysroot = m.group(1)
     return sysroot
@@ -107,7 +110,7 @@
     """
     Returns True if 'path' can be located in an OSX SDK
     """
-    return ( (path.startswith('/usr/') and not path.startswith('/usr/local'))
+    return ( path.startswith('/usr/')
                 or path.startswith('/System/')
                 or path.startswith('/Library/') )
 
@@ -781,6 +784,9 @@
 
         # readline
         do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
+        if cross_compiling:
+        # Just say yes to this check.
+            do_readline = True
         readline_termcap_library = ""
         curses_library = ""
         # Cannot use os.popen here in py3k.
@@ -789,11 +795,11 @@
             os.makedirs(self.build_temp)
         # Determine if readline is already linked against curses or tinfo.
         if do_readline:
-            if cross_compiling:
+            if cross_compiling and host_platform != 'darwin':
                 ret = os.system("%s -d %s | grep '(NEEDED)' > %s" \
                                 % (sysconfig.get_config_var('READELF'),
                                    do_readline, tmpfile))
-            elif find_executable('ldd'):
+            elif find_executable('ldd') and host_platform != 'darwin':
                 ret = os.system("ldd %s > %s" % (do_readline, tmpfile))
             else:
                 ret = 256
@@ -833,7 +839,7 @@
                 # MacOSX 10.4 has a broken readline. Don't try to build
                 # the readline module unless the user has installed a fixed
                 # readline package
-                if find_file('readline/rlconf.h', inc_dirs, []) is None:
+                if find_file('readline/rlconf.h', inc_dirs, []) is None and not cross_compiling:
                     do_readline = False
         if do_readline:
             if host_platform == 'darwin' and os_release < 9:
@@ -1346,6 +1352,9 @@
         curses_defines = []
         curses_includes = []
         panel_library = 'panel'
+        if cross_compiling:
+           # Default to ncurses here.
+           curses_library = curses_library or 'ncurses'
         if curses_library == 'ncursesw':
             curses_defines.append(('HAVE_NCURSESW', '1'))
             if not cross_compiling:
@@ -1390,7 +1399,7 @@
 
         # If the curses module is enabled, check for the panel module
         if (module_enabled(exts, '_curses') and
-            self.compiler.find_library_file(lib_dirs, panel_library)):
+            self.compiler.find_library_file(lib_dirs, panel_library)) or cross_compiling:
             exts.append( Extension('_curses_panel', ['_curses_panel.c'],
                                    include_dirs=curses_includes,
                                    define_macros=curses_defines,
@@ -1412,22 +1421,24 @@
         # http://www.gzip.org/zlib/
         zlib_inc = find_file('zlib.h', [], inc_dirs)
         have_zlib = False
-        if zlib_inc is not None:
-            zlib_h = zlib_inc[0] + '/zlib.h'
-            version = '"0.0.0"'
+        if zlib_inc is not None or cross_compiling:
+#            zlib_h = zlib_inc[0] + '/zlib.h'
+#            version = '"0.0.0"'
+            version = '"1.1.3"'
             version_req = '"1.1.3"'
-            if host_platform == 'darwin' and is_macosx_sdk_path(zlib_h):
-                zlib_h = os.path.join(macosx_sdk_root(), zlib_h[1:])
-            with open(zlib_h) as fp:
-                while 1:
-                    line = fp.readline()
-                    if not line:
-                        break
-                    if line.startswith('#define ZLIB_VERSION'):
-                        version = line.split()[2]
-                        break
-            if version >= version_req:
-                if (self.compiler.find_library_file(lib_dirs, 'z')):
+#            if host_platform == 'darwin' and is_macosx_sdk_path(zlib_h):
+#                zlib_h = os.path.join(macosx_sdk_root(), zlib_h[1:])
+#            with open(zlib_h) as fp:
+#                while 1:
+#                    line = fp.readline()
+#                    if not line:
+#                        break
+#                    if line.startswith('#define ZLIB_VERSION'):
+#                        version = line.split()[2]
+#                        break
+            if version >= version_req or cross_compiling:
+                # zlib is a default lib on iOS.
+                if (self.compiler.find_library_file(lib_dirs, 'z')) or cross_compiling:
                     if host_platform == "darwin":
                         zlib_extra_link_args = ('-Wl,-search_paths_first',)
                     else:
@@ -1459,7 +1470,8 @@
                                extra_link_args = extra_link_args) )
 
         # Gustavo Niemeyer's bz2 module.
-        if (self.compiler.find_library_file(lib_dirs, 'bz2')):
+        if (self.compiler.find_library_file(lib_dirs, 'bz2')) or cross_compiling:
+            # BZ2 is in the iOS SDK
             if host_platform == "darwin":
                 bz2_extra_link_args = ('-Wl,-search_paths_first',)
             else:
@@ -1471,7 +1483,8 @@
             missing.append('_bz2')
 
         # LZMA compression support.
-        if self.compiler.find_library_file(lib_dirs, 'lzma'):
+        if self.compiler.find_library_file(lib_dirs, 'lzma') or cross_compiling:
+            # LZMA is in the iOS SDK
             exts.append( Extension('_lzma', ['_lzmamodule.c'],
                                    libraries = ['lzma']) )
         else:
@@ -1631,11 +1644,12 @@
 
         # Build the _uuid module if possible
         uuid_incs = find_file("uuid.h", inc_dirs, ["/usr/include/uuid"])
-        if uuid_incs is not None:
-            if self.compiler.find_library_file(lib_dirs, 'uuid'):
-                uuid_libs = ['uuid']
-            else:
-                uuid_libs = []
+        if uuid_incs is not None or cross_compiling:
+        # uuid/uuid.h exists in the iOS SDK.
+#            if self.compiler.find_library_file(lib_dirs, 'uuid'):
+#                uuid_libs = ['uuid']
+#            else:
+            uuid_libs = []
             self.extensions.append(Extension('_uuid', ['_uuidmodule.c'],
                                    libraries=uuid_libs,
                                    include_dirs=uuid_incs))
@@ -1926,6 +1940,9 @@
 
     def configure_ctypes(self, ext):
         if not self.use_system_libffi:
+            if cross_compiling:
+               return True
+               # Bypass the check, assume library path is correct
             if host_platform == 'darwin':
                 return self.configure_ctypes_darwin(ext)
             print('INFO: Could not locate ffi libs and/or headers')
@@ -1984,7 +2001,7 @@
                 return
             # OS X 10.5 comes with libffi.dylib; the include files are
             # in /usr/include/ffi
-            inc_dirs.append('/usr/include/ffi')
+            inc_dirs.append(sysroot + '/usr/include/ffi')
 
         ffi_inc = [sysconfig.get_config_var("LIBFFI_INCLUDEDIR")]
         if not ffi_inc or ffi_inc[0] == '':