1 | n/a | #!/usr/bin/env python |
---|
2 | n/a | """ |
---|
3 | n/a | This script is used to build "official" universal installers on Mac OS X. |
---|
4 | n/a | It requires at least Mac OS X 10.5, Xcode 3, and the 10.4u SDK for |
---|
5 | n/a | 32-bit builds. 64-bit or four-way universal builds require at least |
---|
6 | n/a | OS X 10.5 and the 10.5 SDK. |
---|
7 | n/a | |
---|
8 | n/a | Please ensure that this script keeps working with Python 2.5, to avoid |
---|
9 | n/a | bootstrap issues (/usr/bin/python is Python 2.5 on OSX 10.5). Sphinx, |
---|
10 | n/a | which is used to build the documentation, currently requires at least |
---|
11 | n/a | Python 2.4. However, as of Python 3.4.1, Doc builds require an external |
---|
12 | n/a | sphinx-build and the current versions of Sphinx now require at least |
---|
13 | n/a | Python 2.6. |
---|
14 | n/a | |
---|
15 | n/a | In addition to what is supplied with OS X 10.5+ and Xcode 3+, the script |
---|
16 | n/a | requires an installed version of hg and a third-party version of |
---|
17 | n/a | Tcl/Tk 8.4 (for OS X 10.4 and 10.5 deployment targets) or Tcl/TK 8.5 |
---|
18 | n/a | (for 10.6 or later) installed in /Library/Frameworks. When installed, |
---|
19 | n/a | the Python built by this script will attempt to dynamically link first to |
---|
20 | n/a | Tcl and Tk frameworks in /Library/Frameworks if available otherwise fall |
---|
21 | n/a | back to the ones in /System/Library/Framework. For the build, we recommend |
---|
22 | n/a | installing the most recent ActiveTcl 8.4 or 8.5 version. |
---|
23 | n/a | |
---|
24 | n/a | 32-bit-only installer builds are still possible on OS X 10.4 with Xcode 2.5 |
---|
25 | n/a | and the installation of additional components, such as a newer Python |
---|
26 | n/a | (2.5 is needed for Python parser updates), hg, and for the documentation |
---|
27 | n/a | build either svn (pre-3.4.1) or sphinx-build (3.4.1 and later). |
---|
28 | n/a | |
---|
29 | n/a | Usage: see USAGE variable in the script. |
---|
30 | n/a | """ |
---|
31 | n/a | import platform, os, sys, getopt, textwrap, shutil, stat, time, pwd, grp |
---|
32 | n/a | try: |
---|
33 | n/a | import urllib2 as urllib_request |
---|
34 | n/a | except ImportError: |
---|
35 | n/a | import urllib.request as urllib_request |
---|
36 | n/a | |
---|
37 | n/a | STAT_0o755 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
---|
38 | n/a | | stat.S_IRGRP | stat.S_IXGRP |
---|
39 | n/a | | stat.S_IROTH | stat.S_IXOTH ) |
---|
40 | n/a | |
---|
41 | n/a | STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
---|
42 | n/a | | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP |
---|
43 | n/a | | stat.S_IROTH | stat.S_IXOTH ) |
---|
44 | n/a | |
---|
45 | n/a | INCLUDE_TIMESTAMP = 1 |
---|
46 | n/a | VERBOSE = 1 |
---|
47 | n/a | |
---|
48 | n/a | from plistlib import Plist |
---|
49 | n/a | |
---|
50 | n/a | try: |
---|
51 | n/a | from plistlib import writePlist |
---|
52 | n/a | except ImportError: |
---|
53 | n/a | # We're run using python2.3 |
---|
54 | n/a | def writePlist(plist, path): |
---|
55 | n/a | plist.write(path) |
---|
56 | n/a | |
---|
57 | n/a | def shellQuote(value): |
---|
58 | n/a | """ |
---|
59 | n/a | Return the string value in a form that can safely be inserted into |
---|
60 | n/a | a shell command. |
---|
61 | n/a | """ |
---|
62 | n/a | return "'%s'"%(value.replace("'", "'\"'\"'")) |
---|
63 | n/a | |
---|
64 | n/a | def grepValue(fn, variable): |
---|
65 | n/a | """ |
---|
66 | n/a | Return the unquoted value of a variable from a file.. |
---|
67 | n/a | QUOTED_VALUE='quotes' -> str('quotes') |
---|
68 | n/a | UNQUOTED_VALUE=noquotes -> str('noquotes') |
---|
69 | n/a | """ |
---|
70 | n/a | variable = variable + '=' |
---|
71 | n/a | for ln in open(fn, 'r'): |
---|
72 | n/a | if ln.startswith(variable): |
---|
73 | n/a | value = ln[len(variable):].strip() |
---|
74 | n/a | return value.strip("\"'") |
---|
75 | n/a | raise RuntimeError("Cannot find variable %s" % variable[:-1]) |
---|
76 | n/a | |
---|
77 | n/a | _cache_getVersion = None |
---|
78 | n/a | |
---|
79 | n/a | def getVersion(): |
---|
80 | n/a | global _cache_getVersion |
---|
81 | n/a | if _cache_getVersion is None: |
---|
82 | n/a | _cache_getVersion = grepValue( |
---|
83 | n/a | os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION') |
---|
84 | n/a | return _cache_getVersion |
---|
85 | n/a | |
---|
86 | n/a | def getVersionMajorMinor(): |
---|
87 | n/a | return tuple([int(n) for n in getVersion().split('.', 2)]) |
---|
88 | n/a | |
---|
89 | n/a | _cache_getFullVersion = None |
---|
90 | n/a | |
---|
91 | n/a | def getFullVersion(): |
---|
92 | n/a | global _cache_getFullVersion |
---|
93 | n/a | if _cache_getFullVersion is not None: |
---|
94 | n/a | return _cache_getFullVersion |
---|
95 | n/a | fn = os.path.join(SRCDIR, 'Include', 'patchlevel.h') |
---|
96 | n/a | for ln in open(fn): |
---|
97 | n/a | if 'PY_VERSION' in ln: |
---|
98 | n/a | _cache_getFullVersion = ln.split()[-1][1:-1] |
---|
99 | n/a | return _cache_getFullVersion |
---|
100 | n/a | raise RuntimeError("Cannot find full version??") |
---|
101 | n/a | |
---|
102 | n/a | FW_PREFIX = ["Library", "Frameworks", "Python.framework"] |
---|
103 | n/a | FW_VERSION_PREFIX = "--undefined--" # initialized in parseOptions |
---|
104 | n/a | FW_SSL_DIRECTORY = "--undefined--" # initialized in parseOptions |
---|
105 | n/a | |
---|
106 | n/a | # The directory we'll use to create the build (will be erased and recreated) |
---|
107 | n/a | WORKDIR = "/tmp/_py" |
---|
108 | n/a | |
---|
109 | n/a | # The directory we'll use to store third-party sources. Set this to something |
---|
110 | n/a | # else if you don't want to re-fetch required libraries every time. |
---|
111 | n/a | DEPSRC = os.path.join(WORKDIR, 'third-party') |
---|
112 | n/a | DEPSRC = os.path.expanduser('~/Universal/other-sources') |
---|
113 | n/a | |
---|
114 | n/a | # Location of the preferred SDK |
---|
115 | n/a | |
---|
116 | n/a | ### There are some issues with the SDK selection below here, |
---|
117 | n/a | ### The resulting binary doesn't work on all platforms that |
---|
118 | n/a | ### it should. Always default to the 10.4u SDK until that |
---|
119 | n/a | ### issue is resolved. |
---|
120 | n/a | ### |
---|
121 | n/a | ##if int(os.uname()[2].split('.')[0]) == 8: |
---|
122 | n/a | ## # Explicitly use the 10.4u (universal) SDK when |
---|
123 | n/a | ## # building on 10.4, the system headers are not |
---|
124 | n/a | ## # useable for a universal build |
---|
125 | n/a | ## SDKPATH = "/Developer/SDKs/MacOSX10.4u.sdk" |
---|
126 | n/a | ##else: |
---|
127 | n/a | ## SDKPATH = "/" |
---|
128 | n/a | |
---|
129 | n/a | SDKPATH = "/Developer/SDKs/MacOSX10.4u.sdk" |
---|
130 | n/a | |
---|
131 | n/a | universal_opts_map = { '32-bit': ('i386', 'ppc',), |
---|
132 | n/a | '64-bit': ('x86_64', 'ppc64',), |
---|
133 | n/a | 'intel': ('i386', 'x86_64'), |
---|
134 | n/a | '3-way': ('ppc', 'i386', 'x86_64'), |
---|
135 | n/a | 'all': ('i386', 'ppc', 'x86_64', 'ppc64',) } |
---|
136 | n/a | default_target_map = { |
---|
137 | n/a | '64-bit': '10.5', |
---|
138 | n/a | '3-way': '10.5', |
---|
139 | n/a | 'intel': '10.5', |
---|
140 | n/a | 'all': '10.5', |
---|
141 | n/a | } |
---|
142 | n/a | |
---|
143 | n/a | UNIVERSALOPTS = tuple(universal_opts_map.keys()) |
---|
144 | n/a | |
---|
145 | n/a | UNIVERSALARCHS = '32-bit' |
---|
146 | n/a | |
---|
147 | n/a | ARCHLIST = universal_opts_map[UNIVERSALARCHS] |
---|
148 | n/a | |
---|
149 | n/a | # Source directory (assume we're in Mac/BuildScript) |
---|
150 | n/a | SRCDIR = os.path.dirname( |
---|
151 | n/a | os.path.dirname( |
---|
152 | n/a | os.path.dirname( |
---|
153 | n/a | os.path.abspath(__file__ |
---|
154 | n/a | )))) |
---|
155 | n/a | |
---|
156 | n/a | # $MACOSX_DEPLOYMENT_TARGET -> minimum OS X level |
---|
157 | n/a | DEPTARGET = '10.3' |
---|
158 | n/a | |
---|
159 | n/a | def getDeptargetTuple(): |
---|
160 | n/a | return tuple([int(n) for n in DEPTARGET.split('.')[0:2]]) |
---|
161 | n/a | |
---|
162 | n/a | def getTargetCompilers(): |
---|
163 | n/a | target_cc_map = { |
---|
164 | n/a | '10.3': ('gcc-4.0', 'g++-4.0'), |
---|
165 | n/a | '10.4': ('gcc-4.0', 'g++-4.0'), |
---|
166 | n/a | '10.5': ('gcc-4.2', 'g++-4.2'), |
---|
167 | n/a | '10.6': ('gcc-4.2', 'g++-4.2'), |
---|
168 | n/a | } |
---|
169 | n/a | return target_cc_map.get(DEPTARGET, ('clang', 'clang++') ) |
---|
170 | n/a | |
---|
171 | n/a | CC, CXX = getTargetCompilers() |
---|
172 | n/a | |
---|
173 | n/a | PYTHON_3 = getVersionMajorMinor() >= (3, 0) |
---|
174 | n/a | |
---|
175 | n/a | USAGE = textwrap.dedent("""\ |
---|
176 | n/a | Usage: build_python [options] |
---|
177 | n/a | |
---|
178 | n/a | Options: |
---|
179 | n/a | -? or -h: Show this message |
---|
180 | n/a | -b DIR |
---|
181 | n/a | --build-dir=DIR: Create build here (default: %(WORKDIR)r) |
---|
182 | n/a | --third-party=DIR: Store third-party sources here (default: %(DEPSRC)r) |
---|
183 | n/a | --sdk-path=DIR: Location of the SDK (default: %(SDKPATH)r) |
---|
184 | n/a | --src-dir=DIR: Location of the Python sources (default: %(SRCDIR)r) |
---|
185 | n/a | --dep-target=10.n OS X deployment target (default: %(DEPTARGET)r) |
---|
186 | n/a | --universal-archs=x universal architectures (options: %(UNIVERSALOPTS)r, default: %(UNIVERSALARCHS)r) |
---|
187 | n/a | """)% globals() |
---|
188 | n/a | |
---|
189 | n/a | # Dict of object file names with shared library names to check after building. |
---|
190 | n/a | # This is to ensure that we ended up dynamically linking with the shared |
---|
191 | n/a | # library paths and versions we expected. For example: |
---|
192 | n/a | # EXPECTED_SHARED_LIBS['_tkinter.so'] = [ |
---|
193 | n/a | # '/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl', |
---|
194 | n/a | # '/Library/Frameworks/Tk.framework/Versions/8.5/Tk'] |
---|
195 | n/a | EXPECTED_SHARED_LIBS = {} |
---|
196 | n/a | |
---|
197 | n/a | # List of names of third party software built with this installer. |
---|
198 | n/a | # The names will be inserted into the rtf version of the License. |
---|
199 | n/a | THIRD_PARTY_LIBS = [] |
---|
200 | n/a | |
---|
201 | n/a | # Instructions for building libraries that are necessary for building a |
---|
202 | n/a | # batteries included python. |
---|
203 | n/a | # [The recipes are defined here for convenience but instantiated later after |
---|
204 | n/a | # command line options have been processed.] |
---|
205 | n/a | def library_recipes(): |
---|
206 | n/a | result = [] |
---|
207 | n/a | |
---|
208 | n/a | LT_10_5 = bool(getDeptargetTuple() < (10, 5)) |
---|
209 | n/a | |
---|
210 | n/a | # Since Apple removed the header files for the deprecated system |
---|
211 | n/a | # OpenSSL as of the Xcode 7 release (for OS X 10.10+), we do not |
---|
212 | n/a | # have much choice but to build our own copy here, too. |
---|
213 | n/a | |
---|
214 | n/a | result.extend([ |
---|
215 | n/a | dict( |
---|
216 | n/a | name="OpenSSL 1.0.2j", |
---|
217 | n/a | url="https://www.openssl.org/source/openssl-1.0.2j.tar.gz", |
---|
218 | n/a | checksum='96322138f0b69e61b7212bc53d5e912b', |
---|
219 | n/a | patches=[ |
---|
220 | n/a | "openssl_sdk_makedepend.patch", |
---|
221 | n/a | ], |
---|
222 | n/a | buildrecipe=build_universal_openssl, |
---|
223 | n/a | configure=None, |
---|
224 | n/a | install=None, |
---|
225 | n/a | ), |
---|
226 | n/a | ]) |
---|
227 | n/a | |
---|
228 | n/a | # Disable for now |
---|
229 | n/a | if False: # if getDeptargetTuple() > (10, 5): |
---|
230 | n/a | result.extend([ |
---|
231 | n/a | dict( |
---|
232 | n/a | name="Tcl 8.5.15", |
---|
233 | n/a | url="ftp://ftp.tcl.tk/pub/tcl//tcl8_5/tcl8.5.15-src.tar.gz", |
---|
234 | n/a | checksum='f3df162f92c69b254079c4d0af7a690f', |
---|
235 | n/a | buildDir="unix", |
---|
236 | n/a | configure_pre=[ |
---|
237 | n/a | '--enable-shared', |
---|
238 | n/a | '--enable-threads', |
---|
239 | n/a | '--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib'%(getVersion(),), |
---|
240 | n/a | ], |
---|
241 | n/a | useLDFlags=False, |
---|
242 | n/a | install='make TCL_LIBRARY=%(TCL_LIBRARY)s && make install TCL_LIBRARY=%(TCL_LIBRARY)s DESTDIR=%(DESTDIR)s'%{ |
---|
243 | n/a | "DESTDIR": shellQuote(os.path.join(WORKDIR, 'libraries')), |
---|
244 | n/a | "TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.5'%(getVersion())), |
---|
245 | n/a | }, |
---|
246 | n/a | ), |
---|
247 | n/a | dict( |
---|
248 | n/a | name="Tk 8.5.15", |
---|
249 | n/a | url="ftp://ftp.tcl.tk/pub/tcl//tcl8_5/tk8.5.15-src.tar.gz", |
---|
250 | n/a | checksum='55b8e33f903210a4e1c8bce0f820657f', |
---|
251 | n/a | patches=[ |
---|
252 | n/a | "issue19373_tk_8_5_15_source.patch", |
---|
253 | n/a | ], |
---|
254 | n/a | buildDir="unix", |
---|
255 | n/a | configure_pre=[ |
---|
256 | n/a | '--enable-aqua', |
---|
257 | n/a | '--enable-shared', |
---|
258 | n/a | '--enable-threads', |
---|
259 | n/a | '--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib'%(getVersion(),), |
---|
260 | n/a | ], |
---|
261 | n/a | useLDFlags=False, |
---|
262 | n/a | install='make TCL_LIBRARY=%(TCL_LIBRARY)s TK_LIBRARY=%(TK_LIBRARY)s && make install TCL_LIBRARY=%(TCL_LIBRARY)s TK_LIBRARY=%(TK_LIBRARY)s DESTDIR=%(DESTDIR)s'%{ |
---|
263 | n/a | "DESTDIR": shellQuote(os.path.join(WORKDIR, 'libraries')), |
---|
264 | n/a | "TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.5'%(getVersion())), |
---|
265 | n/a | "TK_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tk8.5'%(getVersion())), |
---|
266 | n/a | }, |
---|
267 | n/a | ), |
---|
268 | n/a | ]) |
---|
269 | n/a | |
---|
270 | n/a | if PYTHON_3: |
---|
271 | n/a | result.extend([ |
---|
272 | n/a | dict( |
---|
273 | n/a | name="XZ 5.2.2", |
---|
274 | n/a | url="http://tukaani.org/xz/xz-5.2.2.tar.gz", |
---|
275 | n/a | checksum='7cf6a8544a7dae8e8106fdf7addfa28c', |
---|
276 | n/a | configure_pre=[ |
---|
277 | n/a | '--disable-dependency-tracking', |
---|
278 | n/a | ] |
---|
279 | n/a | ), |
---|
280 | n/a | ]) |
---|
281 | n/a | |
---|
282 | n/a | result.extend([ |
---|
283 | n/a | dict( |
---|
284 | n/a | name="NCurses 5.9", |
---|
285 | n/a | url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz", |
---|
286 | n/a | checksum='8cb9c412e5f2d96bc6f459aa8c6282a1', |
---|
287 | n/a | configure_pre=[ |
---|
288 | n/a | "--enable-widec", |
---|
289 | n/a | "--without-cxx", |
---|
290 | n/a | "--without-cxx-binding", |
---|
291 | n/a | "--without-ada", |
---|
292 | n/a | "--without-curses-h", |
---|
293 | n/a | "--enable-shared", |
---|
294 | n/a | "--with-shared", |
---|
295 | n/a | "--without-debug", |
---|
296 | n/a | "--without-normal", |
---|
297 | n/a | "--without-tests", |
---|
298 | n/a | "--without-manpages", |
---|
299 | n/a | "--datadir=/usr/share", |
---|
300 | n/a | "--sysconfdir=/etc", |
---|
301 | n/a | "--sharedstatedir=/usr/com", |
---|
302 | n/a | "--with-terminfo-dirs=/usr/share/terminfo", |
---|
303 | n/a | "--with-default-terminfo-dir=/usr/share/terminfo", |
---|
304 | n/a | "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),), |
---|
305 | n/a | ], |
---|
306 | n/a | patchscripts=[ |
---|
307 | n/a | ("ftp://invisible-island.net/ncurses//5.9/ncurses-5.9-20120616-patch.sh.bz2", |
---|
308 | n/a | "f54bf02a349f96a7c4f0d00922f3a0d4"), |
---|
309 | n/a | ], |
---|
310 | n/a | useLDFlags=False, |
---|
311 | n/a | install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%( |
---|
312 | n/a | shellQuote(os.path.join(WORKDIR, 'libraries')), |
---|
313 | n/a | shellQuote(os.path.join(WORKDIR, 'libraries')), |
---|
314 | n/a | getVersion(), |
---|
315 | n/a | ), |
---|
316 | n/a | ), |
---|
317 | n/a | dict( |
---|
318 | n/a | name="SQLite 3.14.2", |
---|
319 | n/a | url="https://www.sqlite.org/2016/sqlite-autoconf-3140200.tar.gz", |
---|
320 | n/a | checksum='90c53cacb811db27f990b8292bd96159', |
---|
321 | n/a | extra_cflags=('-Os ' |
---|
322 | n/a | '-DSQLITE_ENABLE_FTS5 ' |
---|
323 | n/a | '-DSQLITE_ENABLE_FTS4 ' |
---|
324 | n/a | '-DSQLITE_ENABLE_FTS3_PARENTHESIS ' |
---|
325 | n/a | '-DSQLITE_ENABLE_RTREE ' |
---|
326 | n/a | '-DSQLITE_TCL=0 ' |
---|
327 | n/a | '%s' % ('','-DSQLITE_WITHOUT_ZONEMALLOC ')[LT_10_5]), |
---|
328 | n/a | configure_pre=[ |
---|
329 | n/a | '--enable-threadsafe', |
---|
330 | n/a | '--enable-shared=no', |
---|
331 | n/a | '--enable-static=yes', |
---|
332 | n/a | '--disable-readline', |
---|
333 | n/a | '--disable-dependency-tracking', |
---|
334 | n/a | ] |
---|
335 | n/a | ), |
---|
336 | n/a | ]) |
---|
337 | n/a | |
---|
338 | n/a | if getDeptargetTuple() < (10, 5): |
---|
339 | n/a | result.extend([ |
---|
340 | n/a | dict( |
---|
341 | n/a | name="Bzip2 1.0.6", |
---|
342 | n/a | url="http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz", |
---|
343 | n/a | checksum='00b516f4704d4a7cb50a1d97e6e8e15b', |
---|
344 | n/a | configure=None, |
---|
345 | n/a | install='make install CC=%s CXX=%s, PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( |
---|
346 | n/a | CC, CXX, |
---|
347 | n/a | shellQuote(os.path.join(WORKDIR, 'libraries')), |
---|
348 | n/a | ' -arch '.join(ARCHLIST), |
---|
349 | n/a | SDKPATH, |
---|
350 | n/a | ), |
---|
351 | n/a | ), |
---|
352 | n/a | dict( |
---|
353 | n/a | name="ZLib 1.2.3", |
---|
354 | n/a | url="http://www.gzip.org/zlib/zlib-1.2.3.tar.gz", |
---|
355 | n/a | checksum='debc62758716a169df9f62e6ab2bc634', |
---|
356 | n/a | configure=None, |
---|
357 | n/a | install='make install CC=%s CXX=%s, prefix=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( |
---|
358 | n/a | CC, CXX, |
---|
359 | n/a | shellQuote(os.path.join(WORKDIR, 'libraries')), |
---|
360 | n/a | ' -arch '.join(ARCHLIST), |
---|
361 | n/a | SDKPATH, |
---|
362 | n/a | ), |
---|
363 | n/a | ), |
---|
364 | n/a | dict( |
---|
365 | n/a | # Note that GNU readline is GPL'd software |
---|
366 | n/a | name="GNU Readline 6.1.2", |
---|
367 | n/a | url="http://ftp.gnu.org/pub/gnu/readline/readline-6.1.tar.gz" , |
---|
368 | n/a | checksum='fc2f7e714fe792db1ce6ddc4c9fb4ef3', |
---|
369 | n/a | patchlevel='0', |
---|
370 | n/a | patches=[ |
---|
371 | n/a | # The readline maintainers don't do actual micro releases, but |
---|
372 | n/a | # just ship a set of patches. |
---|
373 | n/a | ('http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-001', |
---|
374 | n/a | 'c642f2e84d820884b0bf9fd176bc6c3f'), |
---|
375 | n/a | ('http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-002', |
---|
376 | n/a | '1a76781a1ea734e831588285db7ec9b1'), |
---|
377 | n/a | ] |
---|
378 | n/a | ), |
---|
379 | n/a | ]) |
---|
380 | n/a | |
---|
381 | n/a | if not PYTHON_3: |
---|
382 | n/a | result.extend([ |
---|
383 | n/a | dict( |
---|
384 | n/a | name="Sleepycat DB 4.7.25", |
---|
385 | n/a | url="http://download.oracle.com/berkeley-db/db-4.7.25.tar.gz", |
---|
386 | n/a | checksum='ec2b87e833779681a0c3a814aa71359e', |
---|
387 | n/a | buildDir="build_unix", |
---|
388 | n/a | configure="../dist/configure", |
---|
389 | n/a | configure_pre=[ |
---|
390 | n/a | '--includedir=/usr/local/include/db4', |
---|
391 | n/a | ] |
---|
392 | n/a | ), |
---|
393 | n/a | ]) |
---|
394 | n/a | |
---|
395 | n/a | return result |
---|
396 | n/a | |
---|
397 | n/a | |
---|
398 | n/a | # Instructions for building packages inside the .mpkg. |
---|
399 | n/a | def pkg_recipes(): |
---|
400 | n/a | unselected_for_python3 = ('selected', 'unselected')[PYTHON_3] |
---|
401 | n/a | result = [ |
---|
402 | n/a | dict( |
---|
403 | n/a | name="PythonFramework", |
---|
404 | n/a | long_name="Python Framework", |
---|
405 | n/a | source="/Library/Frameworks/Python.framework", |
---|
406 | n/a | readme="""\ |
---|
407 | n/a | This package installs Python.framework, that is the python |
---|
408 | n/a | interpreter and the standard library. This also includes Python |
---|
409 | n/a | wrappers for lots of Mac OS X API's. |
---|
410 | n/a | """, |
---|
411 | n/a | postflight="scripts/postflight.framework", |
---|
412 | n/a | selected='selected', |
---|
413 | n/a | ), |
---|
414 | n/a | dict( |
---|
415 | n/a | name="PythonApplications", |
---|
416 | n/a | long_name="GUI Applications", |
---|
417 | n/a | source="/Applications/Python %(VER)s", |
---|
418 | n/a | readme="""\ |
---|
419 | n/a | This package installs IDLE (an interactive Python IDE), |
---|
420 | n/a | Python Launcher and Build Applet (create application bundles |
---|
421 | n/a | from python scripts). |
---|
422 | n/a | |
---|
423 | n/a | It also installs a number of examples and demos. |
---|
424 | n/a | """, |
---|
425 | n/a | required=False, |
---|
426 | n/a | selected='selected', |
---|
427 | n/a | ), |
---|
428 | n/a | dict( |
---|
429 | n/a | name="PythonUnixTools", |
---|
430 | n/a | long_name="UNIX command-line tools", |
---|
431 | n/a | source="/usr/local/bin", |
---|
432 | n/a | readme="""\ |
---|
433 | n/a | This package installs the unix tools in /usr/local/bin for |
---|
434 | n/a | compatibility with older releases of Python. This package |
---|
435 | n/a | is not necessary to use Python. |
---|
436 | n/a | """, |
---|
437 | n/a | required=False, |
---|
438 | n/a | selected='selected', |
---|
439 | n/a | ), |
---|
440 | n/a | dict( |
---|
441 | n/a | name="PythonDocumentation", |
---|
442 | n/a | long_name="Python Documentation", |
---|
443 | n/a | topdir="/Library/Frameworks/Python.framework/Versions/%(VER)s/Resources/English.lproj/Documentation", |
---|
444 | n/a | source="/pydocs", |
---|
445 | n/a | readme="""\ |
---|
446 | n/a | This package installs the python documentation at a location |
---|
447 | n/a | that is useable for pydoc and IDLE. |
---|
448 | n/a | """, |
---|
449 | n/a | postflight="scripts/postflight.documentation", |
---|
450 | n/a | required=False, |
---|
451 | n/a | selected='selected', |
---|
452 | n/a | ), |
---|
453 | n/a | dict( |
---|
454 | n/a | name="PythonProfileChanges", |
---|
455 | n/a | long_name="Shell profile updater", |
---|
456 | n/a | readme="""\ |
---|
457 | n/a | This packages updates your shell profile to make sure that |
---|
458 | n/a | the Python tools are found by your shell in preference of |
---|
459 | n/a | the system provided Python tools. |
---|
460 | n/a | |
---|
461 | n/a | If you don't install this package you'll have to add |
---|
462 | n/a | "/Library/Frameworks/Python.framework/Versions/%(VER)s/bin" |
---|
463 | n/a | to your PATH by hand. |
---|
464 | n/a | """, |
---|
465 | n/a | postflight="scripts/postflight.patch-profile", |
---|
466 | n/a | topdir="/Library/Frameworks/Python.framework", |
---|
467 | n/a | source="/empty-dir", |
---|
468 | n/a | required=False, |
---|
469 | n/a | selected='selected', |
---|
470 | n/a | ), |
---|
471 | n/a | dict( |
---|
472 | n/a | name="PythonInstallPip", |
---|
473 | n/a | long_name="Install or upgrade pip", |
---|
474 | n/a | readme="""\ |
---|
475 | n/a | This package installs (or upgrades from an earlier version) |
---|
476 | n/a | pip, a tool for installing and managing Python packages. |
---|
477 | n/a | """, |
---|
478 | n/a | postflight="scripts/postflight.ensurepip", |
---|
479 | n/a | topdir="/Library/Frameworks/Python.framework", |
---|
480 | n/a | source="/empty-dir", |
---|
481 | n/a | required=False, |
---|
482 | n/a | selected='selected', |
---|
483 | n/a | ), |
---|
484 | n/a | ] |
---|
485 | n/a | |
---|
486 | n/a | if getDeptargetTuple() < (10, 4) and not PYTHON_3: |
---|
487 | n/a | result.append( |
---|
488 | n/a | dict( |
---|
489 | n/a | name="PythonSystemFixes", |
---|
490 | n/a | long_name="Fix system Python", |
---|
491 | n/a | readme="""\ |
---|
492 | n/a | This package updates the system python installation on |
---|
493 | n/a | Mac OS X 10.3 to ensure that you can build new python extensions |
---|
494 | n/a | using that copy of python after installing this version. |
---|
495 | n/a | """, |
---|
496 | n/a | postflight="../Tools/fixapplepython23.py", |
---|
497 | n/a | topdir="/Library/Frameworks/Python.framework", |
---|
498 | n/a | source="/empty-dir", |
---|
499 | n/a | required=False, |
---|
500 | n/a | selected=unselected_for_python3, |
---|
501 | n/a | ) |
---|
502 | n/a | ) |
---|
503 | n/a | |
---|
504 | n/a | return result |
---|
505 | n/a | |
---|
506 | n/a | def fatal(msg): |
---|
507 | n/a | """ |
---|
508 | n/a | A fatal error, bail out. |
---|
509 | n/a | """ |
---|
510 | n/a | sys.stderr.write('FATAL: ') |
---|
511 | n/a | sys.stderr.write(msg) |
---|
512 | n/a | sys.stderr.write('\n') |
---|
513 | n/a | sys.exit(1) |
---|
514 | n/a | |
---|
515 | n/a | def fileContents(fn): |
---|
516 | n/a | """ |
---|
517 | n/a | Return the contents of the named file |
---|
518 | n/a | """ |
---|
519 | n/a | return open(fn, 'r').read() |
---|
520 | n/a | |
---|
521 | n/a | def runCommand(commandline): |
---|
522 | n/a | """ |
---|
523 | n/a | Run a command and raise RuntimeError if it fails. Output is suppressed |
---|
524 | n/a | unless the command fails. |
---|
525 | n/a | """ |
---|
526 | n/a | fd = os.popen(commandline, 'r') |
---|
527 | n/a | data = fd.read() |
---|
528 | n/a | xit = fd.close() |
---|
529 | n/a | if xit is not None: |
---|
530 | n/a | sys.stdout.write(data) |
---|
531 | n/a | raise RuntimeError("command failed: %s"%(commandline,)) |
---|
532 | n/a | |
---|
533 | n/a | if VERBOSE: |
---|
534 | n/a | sys.stdout.write(data); sys.stdout.flush() |
---|
535 | n/a | |
---|
536 | n/a | def captureCommand(commandline): |
---|
537 | n/a | fd = os.popen(commandline, 'r') |
---|
538 | n/a | data = fd.read() |
---|
539 | n/a | xit = fd.close() |
---|
540 | n/a | if xit is not None: |
---|
541 | n/a | sys.stdout.write(data) |
---|
542 | n/a | raise RuntimeError("command failed: %s"%(commandline,)) |
---|
543 | n/a | |
---|
544 | n/a | return data |
---|
545 | n/a | |
---|
546 | n/a | def getTclTkVersion(configfile, versionline): |
---|
547 | n/a | """ |
---|
548 | n/a | search Tcl or Tk configuration file for version line |
---|
549 | n/a | """ |
---|
550 | n/a | try: |
---|
551 | n/a | f = open(configfile, "r") |
---|
552 | n/a | except OSError: |
---|
553 | n/a | fatal("Framework configuration file not found: %s" % configfile) |
---|
554 | n/a | |
---|
555 | n/a | for l in f: |
---|
556 | n/a | if l.startswith(versionline): |
---|
557 | n/a | f.close() |
---|
558 | n/a | return l |
---|
559 | n/a | |
---|
560 | n/a | fatal("Version variable %s not found in framework configuration file: %s" |
---|
561 | n/a | % (versionline, configfile)) |
---|
562 | n/a | |
---|
563 | n/a | def checkEnvironment(): |
---|
564 | n/a | """ |
---|
565 | n/a | Check that we're running on a supported system. |
---|
566 | n/a | """ |
---|
567 | n/a | |
---|
568 | n/a | if sys.version_info[0:2] < (2, 4): |
---|
569 | n/a | fatal("This script must be run with Python 2.4 or later") |
---|
570 | n/a | |
---|
571 | n/a | if platform.system() != 'Darwin': |
---|
572 | n/a | fatal("This script should be run on a Mac OS X 10.4 (or later) system") |
---|
573 | n/a | |
---|
574 | n/a | if int(platform.release().split('.')[0]) < 8: |
---|
575 | n/a | fatal("This script should be run on a Mac OS X 10.4 (or later) system") |
---|
576 | n/a | |
---|
577 | n/a | if not os.path.exists(SDKPATH): |
---|
578 | n/a | fatal("Please install the latest version of Xcode and the %s SDK"%( |
---|
579 | n/a | os.path.basename(SDKPATH[:-4]))) |
---|
580 | n/a | |
---|
581 | n/a | # Because we only support dynamic load of only one major/minor version of |
---|
582 | n/a | # Tcl/Tk, ensure: |
---|
583 | n/a | # 1. there are no user-installed frameworks of Tcl/Tk with version |
---|
584 | n/a | # higher than the Apple-supplied system version in |
---|
585 | n/a | # SDKROOT/System/Library/Frameworks |
---|
586 | n/a | # 2. there is a user-installed framework (usually ActiveTcl) in (or linked |
---|
587 | n/a | # in) SDKROOT/Library/Frameworks with the same version as the system |
---|
588 | n/a | # version. This allows users to choose to install a newer patch level. |
---|
589 | n/a | |
---|
590 | n/a | frameworks = {} |
---|
591 | n/a | for framework in ['Tcl', 'Tk']: |
---|
592 | n/a | fwpth = 'Library/Frameworks/%s.framework/Versions/Current' % framework |
---|
593 | n/a | sysfw = os.path.join(SDKPATH, 'System', fwpth) |
---|
594 | n/a | libfw = os.path.join(SDKPATH, fwpth) |
---|
595 | n/a | usrfw = os.path.join(os.getenv('HOME'), fwpth) |
---|
596 | n/a | frameworks[framework] = os.readlink(sysfw) |
---|
597 | n/a | if not os.path.exists(libfw): |
---|
598 | n/a | fatal("Please install a link to a current %s %s as %s so " |
---|
599 | n/a | "the user can override the system framework." |
---|
600 | n/a | % (framework, frameworks[framework], libfw)) |
---|
601 | n/a | if os.readlink(libfw) != os.readlink(sysfw): |
---|
602 | n/a | fatal("Version of %s must match %s" % (libfw, sysfw) ) |
---|
603 | n/a | if os.path.exists(usrfw): |
---|
604 | n/a | fatal("Please rename %s to avoid possible dynamic load issues." |
---|
605 | n/a | % usrfw) |
---|
606 | n/a | |
---|
607 | n/a | if frameworks['Tcl'] != frameworks['Tk']: |
---|
608 | n/a | fatal("The Tcl and Tk frameworks are not the same version.") |
---|
609 | n/a | |
---|
610 | n/a | # add files to check after build |
---|
611 | n/a | EXPECTED_SHARED_LIBS['_tkinter.so'] = [ |
---|
612 | n/a | "/Library/Frameworks/Tcl.framework/Versions/%s/Tcl" |
---|
613 | n/a | % frameworks['Tcl'], |
---|
614 | n/a | "/Library/Frameworks/Tk.framework/Versions/%s/Tk" |
---|
615 | n/a | % frameworks['Tk'], |
---|
616 | n/a | ] |
---|
617 | n/a | |
---|
618 | n/a | # Remove inherited environment variables which might influence build |
---|
619 | n/a | environ_var_prefixes = ['CPATH', 'C_INCLUDE_', 'DYLD_', 'LANG', 'LC_', |
---|
620 | n/a | 'LD_', 'LIBRARY_', 'PATH', 'PYTHON'] |
---|
621 | n/a | for ev in list(os.environ): |
---|
622 | n/a | for prefix in environ_var_prefixes: |
---|
623 | n/a | if ev.startswith(prefix) : |
---|
624 | n/a | print("INFO: deleting environment variable %s=%s" % ( |
---|
625 | n/a | ev, os.environ[ev])) |
---|
626 | n/a | del os.environ[ev] |
---|
627 | n/a | |
---|
628 | n/a | base_path = '/bin:/sbin:/usr/bin:/usr/sbin' |
---|
629 | n/a | if 'SDK_TOOLS_BIN' in os.environ: |
---|
630 | n/a | base_path = os.environ['SDK_TOOLS_BIN'] + ':' + base_path |
---|
631 | n/a | # Xcode 2.5 on OS X 10.4 does not include SetFile in its usr/bin; |
---|
632 | n/a | # add its fixed location here if it exists |
---|
633 | n/a | OLD_DEVELOPER_TOOLS = '/Developer/Tools' |
---|
634 | n/a | if os.path.isdir(OLD_DEVELOPER_TOOLS): |
---|
635 | n/a | base_path = base_path + ':' + OLD_DEVELOPER_TOOLS |
---|
636 | n/a | os.environ['PATH'] = base_path |
---|
637 | n/a | print("Setting default PATH: %s"%(os.environ['PATH'])) |
---|
638 | n/a | # Ensure ws have access to hg and to sphinx-build. |
---|
639 | n/a | # You may have to create links in /usr/bin for them. |
---|
640 | n/a | runCommand('hg --version') |
---|
641 | n/a | runCommand('sphinx-build --version') |
---|
642 | n/a | |
---|
643 | n/a | def parseOptions(args=None): |
---|
644 | n/a | """ |
---|
645 | n/a | Parse arguments and update global settings. |
---|
646 | n/a | """ |
---|
647 | n/a | global WORKDIR, DEPSRC, SDKPATH, SRCDIR, DEPTARGET |
---|
648 | n/a | global UNIVERSALOPTS, UNIVERSALARCHS, ARCHLIST, CC, CXX |
---|
649 | n/a | global FW_VERSION_PREFIX |
---|
650 | n/a | global FW_SSL_DIRECTORY |
---|
651 | n/a | |
---|
652 | n/a | if args is None: |
---|
653 | n/a | args = sys.argv[1:] |
---|
654 | n/a | |
---|
655 | n/a | try: |
---|
656 | n/a | options, args = getopt.getopt(args, '?hb', |
---|
657 | n/a | [ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir=', |
---|
658 | n/a | 'dep-target=', 'universal-archs=', 'help' ]) |
---|
659 | n/a | except getopt.GetoptError: |
---|
660 | n/a | print(sys.exc_info()[1]) |
---|
661 | n/a | sys.exit(1) |
---|
662 | n/a | |
---|
663 | n/a | if args: |
---|
664 | n/a | print("Additional arguments") |
---|
665 | n/a | sys.exit(1) |
---|
666 | n/a | |
---|
667 | n/a | deptarget = None |
---|
668 | n/a | for k, v in options: |
---|
669 | n/a | if k in ('-h', '-?', '--help'): |
---|
670 | n/a | print(USAGE) |
---|
671 | n/a | sys.exit(0) |
---|
672 | n/a | |
---|
673 | n/a | elif k in ('-d', '--build-dir'): |
---|
674 | n/a | WORKDIR=v |
---|
675 | n/a | |
---|
676 | n/a | elif k in ('--third-party',): |
---|
677 | n/a | DEPSRC=v |
---|
678 | n/a | |
---|
679 | n/a | elif k in ('--sdk-path',): |
---|
680 | n/a | SDKPATH=v |
---|
681 | n/a | |
---|
682 | n/a | elif k in ('--src-dir',): |
---|
683 | n/a | SRCDIR=v |
---|
684 | n/a | |
---|
685 | n/a | elif k in ('--dep-target', ): |
---|
686 | n/a | DEPTARGET=v |
---|
687 | n/a | deptarget=v |
---|
688 | n/a | |
---|
689 | n/a | elif k in ('--universal-archs', ): |
---|
690 | n/a | if v in UNIVERSALOPTS: |
---|
691 | n/a | UNIVERSALARCHS = v |
---|
692 | n/a | ARCHLIST = universal_opts_map[UNIVERSALARCHS] |
---|
693 | n/a | if deptarget is None: |
---|
694 | n/a | # Select alternate default deployment |
---|
695 | n/a | # target |
---|
696 | n/a | DEPTARGET = default_target_map.get(v, '10.3') |
---|
697 | n/a | else: |
---|
698 | n/a | raise NotImplementedError(v) |
---|
699 | n/a | |
---|
700 | n/a | else: |
---|
701 | n/a | raise NotImplementedError(k) |
---|
702 | n/a | |
---|
703 | n/a | SRCDIR=os.path.abspath(SRCDIR) |
---|
704 | n/a | WORKDIR=os.path.abspath(WORKDIR) |
---|
705 | n/a | SDKPATH=os.path.abspath(SDKPATH) |
---|
706 | n/a | DEPSRC=os.path.abspath(DEPSRC) |
---|
707 | n/a | |
---|
708 | n/a | CC, CXX = getTargetCompilers() |
---|
709 | n/a | |
---|
710 | n/a | FW_VERSION_PREFIX = FW_PREFIX[:] + ["Versions", getVersion()] |
---|
711 | n/a | FW_SSL_DIRECTORY = FW_VERSION_PREFIX[:] + ["etc", "openssl"] |
---|
712 | n/a | |
---|
713 | n/a | print("-- Settings:") |
---|
714 | n/a | print(" * Source directory: %s" % SRCDIR) |
---|
715 | n/a | print(" * Build directory: %s" % WORKDIR) |
---|
716 | n/a | print(" * SDK location: %s" % SDKPATH) |
---|
717 | n/a | print(" * Third-party source: %s" % DEPSRC) |
---|
718 | n/a | print(" * Deployment target: %s" % DEPTARGET) |
---|
719 | n/a | print(" * Universal archs: %s" % str(ARCHLIST)) |
---|
720 | n/a | print(" * C compiler: %s" % CC) |
---|
721 | n/a | print(" * C++ compiler: %s" % CXX) |
---|
722 | n/a | print("") |
---|
723 | n/a | print(" -- Building a Python %s framework at patch level %s" |
---|
724 | n/a | % (getVersion(), getFullVersion())) |
---|
725 | n/a | print("") |
---|
726 | n/a | |
---|
727 | n/a | def extractArchive(builddir, archiveName): |
---|
728 | n/a | """ |
---|
729 | n/a | Extract a source archive into 'builddir'. Returns the path of the |
---|
730 | n/a | extracted archive. |
---|
731 | n/a | |
---|
732 | n/a | XXX: This function assumes that archives contain a toplevel directory |
---|
733 | n/a | that is has the same name as the basename of the archive. This is |
---|
734 | n/a | safe enough for almost anything we use. Unfortunately, it does not |
---|
735 | n/a | work for current Tcl and Tk source releases where the basename of |
---|
736 | n/a | the archive ends with "-src" but the uncompressed directory does not. |
---|
737 | n/a | For now, just special case Tcl and Tk tar.gz downloads. |
---|
738 | n/a | """ |
---|
739 | n/a | curdir = os.getcwd() |
---|
740 | n/a | try: |
---|
741 | n/a | os.chdir(builddir) |
---|
742 | n/a | if archiveName.endswith('.tar.gz'): |
---|
743 | n/a | retval = os.path.basename(archiveName[:-7]) |
---|
744 | n/a | if ((retval.startswith('tcl') or retval.startswith('tk')) |
---|
745 | n/a | and retval.endswith('-src')): |
---|
746 | n/a | retval = retval[:-4] |
---|
747 | n/a | if os.path.exists(retval): |
---|
748 | n/a | shutil.rmtree(retval) |
---|
749 | n/a | fp = os.popen("tar zxf %s 2>&1"%(shellQuote(archiveName),), 'r') |
---|
750 | n/a | |
---|
751 | n/a | elif archiveName.endswith('.tar.bz2'): |
---|
752 | n/a | retval = os.path.basename(archiveName[:-8]) |
---|
753 | n/a | if os.path.exists(retval): |
---|
754 | n/a | shutil.rmtree(retval) |
---|
755 | n/a | fp = os.popen("tar jxf %s 2>&1"%(shellQuote(archiveName),), 'r') |
---|
756 | n/a | |
---|
757 | n/a | elif archiveName.endswith('.tar'): |
---|
758 | n/a | retval = os.path.basename(archiveName[:-4]) |
---|
759 | n/a | if os.path.exists(retval): |
---|
760 | n/a | shutil.rmtree(retval) |
---|
761 | n/a | fp = os.popen("tar xf %s 2>&1"%(shellQuote(archiveName),), 'r') |
---|
762 | n/a | |
---|
763 | n/a | elif archiveName.endswith('.zip'): |
---|
764 | n/a | retval = os.path.basename(archiveName[:-4]) |
---|
765 | n/a | if os.path.exists(retval): |
---|
766 | n/a | shutil.rmtree(retval) |
---|
767 | n/a | fp = os.popen("unzip %s 2>&1"%(shellQuote(archiveName),), 'r') |
---|
768 | n/a | |
---|
769 | n/a | data = fp.read() |
---|
770 | n/a | xit = fp.close() |
---|
771 | n/a | if xit is not None: |
---|
772 | n/a | sys.stdout.write(data) |
---|
773 | n/a | raise RuntimeError("Cannot extract %s"%(archiveName,)) |
---|
774 | n/a | |
---|
775 | n/a | return os.path.join(builddir, retval) |
---|
776 | n/a | |
---|
777 | n/a | finally: |
---|
778 | n/a | os.chdir(curdir) |
---|
779 | n/a | |
---|
780 | n/a | def downloadURL(url, fname): |
---|
781 | n/a | """ |
---|
782 | n/a | Download the contents of the url into the file. |
---|
783 | n/a | """ |
---|
784 | n/a | fpIn = urllib_request.urlopen(url) |
---|
785 | n/a | fpOut = open(fname, 'wb') |
---|
786 | n/a | block = fpIn.read(10240) |
---|
787 | n/a | try: |
---|
788 | n/a | while block: |
---|
789 | n/a | fpOut.write(block) |
---|
790 | n/a | block = fpIn.read(10240) |
---|
791 | n/a | fpIn.close() |
---|
792 | n/a | fpOut.close() |
---|
793 | n/a | except: |
---|
794 | n/a | try: |
---|
795 | n/a | os.unlink(fname) |
---|
796 | n/a | except OSError: |
---|
797 | n/a | pass |
---|
798 | n/a | |
---|
799 | n/a | def verifyThirdPartyFile(url, checksum, fname): |
---|
800 | n/a | """ |
---|
801 | n/a | Download file from url to filename fname if it does not already exist. |
---|
802 | n/a | Abort if file contents does not match supplied md5 checksum. |
---|
803 | n/a | """ |
---|
804 | n/a | name = os.path.basename(fname) |
---|
805 | n/a | if os.path.exists(fname): |
---|
806 | n/a | print("Using local copy of %s"%(name,)) |
---|
807 | n/a | else: |
---|
808 | n/a | print("Did not find local copy of %s"%(name,)) |
---|
809 | n/a | print("Downloading %s"%(name,)) |
---|
810 | n/a | downloadURL(url, fname) |
---|
811 | n/a | print("Archive for %s stored as %s"%(name, fname)) |
---|
812 | n/a | if os.system( |
---|
813 | n/a | 'MD5=$(openssl md5 %s) ; test "${MD5##*= }" = "%s"' |
---|
814 | n/a | % (shellQuote(fname), checksum) ): |
---|
815 | n/a | fatal('MD5 checksum mismatch for file %s' % fname) |
---|
816 | n/a | |
---|
817 | n/a | def build_universal_openssl(basedir, archList): |
---|
818 | n/a | """ |
---|
819 | n/a | Special case build recipe for universal build of openssl. |
---|
820 | n/a | |
---|
821 | n/a | The upstream OpenSSL build system does not directly support |
---|
822 | n/a | OS X universal builds. We need to build each architecture |
---|
823 | n/a | separately then lipo them together into fat libraries. |
---|
824 | n/a | """ |
---|
825 | n/a | |
---|
826 | n/a | # OpenSSL fails to build with Xcode 2.5 (on OS X 10.4). |
---|
827 | n/a | # If we are building on a 10.4.x or earlier system, |
---|
828 | n/a | # unilaterally disable assembly code building to avoid the problem. |
---|
829 | n/a | no_asm = int(platform.release().split(".")[0]) < 9 |
---|
830 | n/a | |
---|
831 | n/a | def build_openssl_arch(archbase, arch): |
---|
832 | n/a | "Build one architecture of openssl" |
---|
833 | n/a | arch_opts = { |
---|
834 | n/a | "i386": ["darwin-i386-cc"], |
---|
835 | n/a | "x86_64": ["darwin64-x86_64-cc", "enable-ec_nistp_64_gcc_128"], |
---|
836 | n/a | "ppc": ["darwin-ppc-cc"], |
---|
837 | n/a | "ppc64": ["darwin64-ppc-cc"], |
---|
838 | n/a | } |
---|
839 | n/a | configure_opts = [ |
---|
840 | n/a | "no-krb5", |
---|
841 | n/a | "no-idea", |
---|
842 | n/a | "no-mdc2", |
---|
843 | n/a | "no-rc5", |
---|
844 | n/a | "no-zlib", |
---|
845 | n/a | "enable-tlsext", |
---|
846 | n/a | "no-ssl2", |
---|
847 | n/a | "no-ssl3", |
---|
848 | n/a | "no-ssl3-method", |
---|
849 | n/a | # "enable-unit-test", |
---|
850 | n/a | "shared", |
---|
851 | n/a | "--install_prefix=%s"%shellQuote(archbase), |
---|
852 | n/a | "--prefix=%s"%os.path.join("/", *FW_VERSION_PREFIX), |
---|
853 | n/a | "--openssldir=%s"%os.path.join("/", *FW_SSL_DIRECTORY), |
---|
854 | n/a | ] |
---|
855 | n/a | if no_asm: |
---|
856 | n/a | configure_opts.append("no-asm") |
---|
857 | n/a | runCommand(" ".join(["perl", "Configure"] |
---|
858 | n/a | + arch_opts[arch] + configure_opts)) |
---|
859 | n/a | runCommand("make depend OSX_SDK=%s" % SDKPATH) |
---|
860 | n/a | runCommand("make all OSX_SDK=%s" % SDKPATH) |
---|
861 | n/a | runCommand("make install_sw OSX_SDK=%s" % SDKPATH) |
---|
862 | n/a | # runCommand("make test") |
---|
863 | n/a | return |
---|
864 | n/a | |
---|
865 | n/a | srcdir = os.getcwd() |
---|
866 | n/a | universalbase = os.path.join(srcdir, "..", |
---|
867 | n/a | os.path.basename(srcdir) + "-universal") |
---|
868 | n/a | os.mkdir(universalbase) |
---|
869 | n/a | archbasefws = [] |
---|
870 | n/a | for arch in archList: |
---|
871 | n/a | # fresh copy of the source tree |
---|
872 | n/a | archsrc = os.path.join(universalbase, arch, "src") |
---|
873 | n/a | shutil.copytree(srcdir, archsrc, symlinks=True) |
---|
874 | n/a | # install base for this arch |
---|
875 | n/a | archbase = os.path.join(universalbase, arch, "root") |
---|
876 | n/a | os.mkdir(archbase) |
---|
877 | n/a | # Python framework base within install_prefix: |
---|
878 | n/a | # the build will install into this framework.. |
---|
879 | n/a | # This is to ensure that the resulting shared libs have |
---|
880 | n/a | # the desired real install paths built into them. |
---|
881 | n/a | archbasefw = os.path.join(archbase, *FW_VERSION_PREFIX) |
---|
882 | n/a | |
---|
883 | n/a | # build one architecture |
---|
884 | n/a | os.chdir(archsrc) |
---|
885 | n/a | build_openssl_arch(archbase, arch) |
---|
886 | n/a | os.chdir(srcdir) |
---|
887 | n/a | archbasefws.append(archbasefw) |
---|
888 | n/a | |
---|
889 | n/a | # copy arch-independent files from last build into the basedir framework |
---|
890 | n/a | basefw = os.path.join(basedir, *FW_VERSION_PREFIX) |
---|
891 | n/a | shutil.copytree( |
---|
892 | n/a | os.path.join(archbasefw, "include", "openssl"), |
---|
893 | n/a | os.path.join(basefw, "include", "openssl") |
---|
894 | n/a | ) |
---|
895 | n/a | |
---|
896 | n/a | shlib_version_number = grepValue(os.path.join(archsrc, "Makefile"), |
---|
897 | n/a | "SHLIB_VERSION_NUMBER") |
---|
898 | n/a | # e.g. -> "1.0.0" |
---|
899 | n/a | libcrypto = "libcrypto.dylib" |
---|
900 | n/a | libcrypto_versioned = libcrypto.replace(".", "."+shlib_version_number+".") |
---|
901 | n/a | # e.g. -> "libcrypto.1.0.0.dylib" |
---|
902 | n/a | libssl = "libssl.dylib" |
---|
903 | n/a | libssl_versioned = libssl.replace(".", "."+shlib_version_number+".") |
---|
904 | n/a | # e.g. -> "libssl.1.0.0.dylib" |
---|
905 | n/a | |
---|
906 | n/a | try: |
---|
907 | n/a | os.mkdir(os.path.join(basefw, "lib")) |
---|
908 | n/a | except OSError: |
---|
909 | n/a | pass |
---|
910 | n/a | |
---|
911 | n/a | # merge the individual arch-dependent shared libs into a fat shared lib |
---|
912 | n/a | archbasefws.insert(0, basefw) |
---|
913 | n/a | for (lib_unversioned, lib_versioned) in [ |
---|
914 | n/a | (libcrypto, libcrypto_versioned), |
---|
915 | n/a | (libssl, libssl_versioned) |
---|
916 | n/a | ]: |
---|
917 | n/a | runCommand("lipo -create -output " + |
---|
918 | n/a | " ".join(shellQuote( |
---|
919 | n/a | os.path.join(fw, "lib", lib_versioned)) |
---|
920 | n/a | for fw in archbasefws)) |
---|
921 | n/a | # and create an unversioned symlink of it |
---|
922 | n/a | os.symlink(lib_versioned, os.path.join(basefw, "lib", lib_unversioned)) |
---|
923 | n/a | |
---|
924 | n/a | # Create links in the temp include and lib dirs that will be injected |
---|
925 | n/a | # into the Python build so that setup.py can find them while building |
---|
926 | n/a | # and the versioned links so that the setup.py post-build import test |
---|
927 | n/a | # does not fail. |
---|
928 | n/a | relative_path = os.path.join("..", "..", "..", *FW_VERSION_PREFIX) |
---|
929 | n/a | for fn in [ |
---|
930 | n/a | ["include", "openssl"], |
---|
931 | n/a | ["lib", libcrypto], |
---|
932 | n/a | ["lib", libssl], |
---|
933 | n/a | ["lib", libcrypto_versioned], |
---|
934 | n/a | ["lib", libssl_versioned], |
---|
935 | n/a | ]: |
---|
936 | n/a | os.symlink( |
---|
937 | n/a | os.path.join(relative_path, *fn), |
---|
938 | n/a | os.path.join(basedir, "usr", "local", *fn) |
---|
939 | n/a | ) |
---|
940 | n/a | |
---|
941 | n/a | return |
---|
942 | n/a | |
---|
943 | n/a | def buildRecipe(recipe, basedir, archList): |
---|
944 | n/a | """ |
---|
945 | n/a | Build software using a recipe. This function does the |
---|
946 | n/a | 'configure;make;make install' dance for C software, with a possibility |
---|
947 | n/a | to customize this process, basically a poor-mans DarwinPorts. |
---|
948 | n/a | """ |
---|
949 | n/a | curdir = os.getcwd() |
---|
950 | n/a | |
---|
951 | n/a | name = recipe['name'] |
---|
952 | n/a | THIRD_PARTY_LIBS.append(name) |
---|
953 | n/a | url = recipe['url'] |
---|
954 | n/a | configure = recipe.get('configure', './configure') |
---|
955 | n/a | buildrecipe = recipe.get('buildrecipe', None) |
---|
956 | n/a | install = recipe.get('install', 'make && make install DESTDIR=%s'%( |
---|
957 | n/a | shellQuote(basedir))) |
---|
958 | n/a | |
---|
959 | n/a | archiveName = os.path.split(url)[-1] |
---|
960 | n/a | sourceArchive = os.path.join(DEPSRC, archiveName) |
---|
961 | n/a | |
---|
962 | n/a | if not os.path.exists(DEPSRC): |
---|
963 | n/a | os.mkdir(DEPSRC) |
---|
964 | n/a | |
---|
965 | n/a | verifyThirdPartyFile(url, recipe['checksum'], sourceArchive) |
---|
966 | n/a | print("Extracting archive for %s"%(name,)) |
---|
967 | n/a | buildDir=os.path.join(WORKDIR, '_bld') |
---|
968 | n/a | if not os.path.exists(buildDir): |
---|
969 | n/a | os.mkdir(buildDir) |
---|
970 | n/a | |
---|
971 | n/a | workDir = extractArchive(buildDir, sourceArchive) |
---|
972 | n/a | os.chdir(workDir) |
---|
973 | n/a | |
---|
974 | n/a | for patch in recipe.get('patches', ()): |
---|
975 | n/a | if isinstance(patch, tuple): |
---|
976 | n/a | url, checksum = patch |
---|
977 | n/a | fn = os.path.join(DEPSRC, os.path.basename(url)) |
---|
978 | n/a | verifyThirdPartyFile(url, checksum, fn) |
---|
979 | n/a | else: |
---|
980 | n/a | # patch is a file in the source directory |
---|
981 | n/a | fn = os.path.join(curdir, patch) |
---|
982 | n/a | runCommand('patch -p%s < %s'%(recipe.get('patchlevel', 1), |
---|
983 | n/a | shellQuote(fn),)) |
---|
984 | n/a | |
---|
985 | n/a | for patchscript in recipe.get('patchscripts', ()): |
---|
986 | n/a | if isinstance(patchscript, tuple): |
---|
987 | n/a | url, checksum = patchscript |
---|
988 | n/a | fn = os.path.join(DEPSRC, os.path.basename(url)) |
---|
989 | n/a | verifyThirdPartyFile(url, checksum, fn) |
---|
990 | n/a | else: |
---|
991 | n/a | # patch is a file in the source directory |
---|
992 | n/a | fn = os.path.join(curdir, patchscript) |
---|
993 | n/a | if fn.endswith('.bz2'): |
---|
994 | n/a | runCommand('bunzip2 -fk %s' % shellQuote(fn)) |
---|
995 | n/a | fn = fn[:-4] |
---|
996 | n/a | runCommand('sh %s' % shellQuote(fn)) |
---|
997 | n/a | os.unlink(fn) |
---|
998 | n/a | |
---|
999 | n/a | if 'buildDir' in recipe: |
---|
1000 | n/a | os.chdir(recipe['buildDir']) |
---|
1001 | n/a | |
---|
1002 | n/a | if configure is not None: |
---|
1003 | n/a | configure_args = [ |
---|
1004 | n/a | "--prefix=/usr/local", |
---|
1005 | n/a | "--enable-static", |
---|
1006 | n/a | "--disable-shared", |
---|
1007 | n/a | #"CPP=gcc -arch %s -E"%(' -arch '.join(archList,),), |
---|
1008 | n/a | ] |
---|
1009 | n/a | |
---|
1010 | n/a | if 'configure_pre' in recipe: |
---|
1011 | n/a | args = list(recipe['configure_pre']) |
---|
1012 | n/a | if '--disable-static' in args: |
---|
1013 | n/a | configure_args.remove('--enable-static') |
---|
1014 | n/a | if '--enable-shared' in args: |
---|
1015 | n/a | configure_args.remove('--disable-shared') |
---|
1016 | n/a | configure_args.extend(args) |
---|
1017 | n/a | |
---|
1018 | n/a | if recipe.get('useLDFlags', 1): |
---|
1019 | n/a | configure_args.extend([ |
---|
1020 | n/a | "CFLAGS=%s-mmacosx-version-min=%s -arch %s -isysroot %s " |
---|
1021 | n/a | "-I%s/usr/local/include"%( |
---|
1022 | n/a | recipe.get('extra_cflags', ''), |
---|
1023 | n/a | DEPTARGET, |
---|
1024 | n/a | ' -arch '.join(archList), |
---|
1025 | n/a | shellQuote(SDKPATH)[1:-1], |
---|
1026 | n/a | shellQuote(basedir)[1:-1],), |
---|
1027 | n/a | "LDFLAGS=-mmacosx-version-min=%s -isysroot %s -L%s/usr/local/lib -arch %s"%( |
---|
1028 | n/a | DEPTARGET, |
---|
1029 | n/a | shellQuote(SDKPATH)[1:-1], |
---|
1030 | n/a | shellQuote(basedir)[1:-1], |
---|
1031 | n/a | ' -arch '.join(archList)), |
---|
1032 | n/a | ]) |
---|
1033 | n/a | else: |
---|
1034 | n/a | configure_args.extend([ |
---|
1035 | n/a | "CFLAGS=%s-mmacosx-version-min=%s -arch %s -isysroot %s " |
---|
1036 | n/a | "-I%s/usr/local/include"%( |
---|
1037 | n/a | recipe.get('extra_cflags', ''), |
---|
1038 | n/a | DEPTARGET, |
---|
1039 | n/a | ' -arch '.join(archList), |
---|
1040 | n/a | shellQuote(SDKPATH)[1:-1], |
---|
1041 | n/a | shellQuote(basedir)[1:-1],), |
---|
1042 | n/a | ]) |
---|
1043 | n/a | |
---|
1044 | n/a | if 'configure_post' in recipe: |
---|
1045 | n/a | configure_args = configure_args + list(recipe['configure_post']) |
---|
1046 | n/a | |
---|
1047 | n/a | configure_args.insert(0, configure) |
---|
1048 | n/a | configure_args = [ shellQuote(a) for a in configure_args ] |
---|
1049 | n/a | |
---|
1050 | n/a | print("Running configure for %s"%(name,)) |
---|
1051 | n/a | runCommand(' '.join(configure_args) + ' 2>&1') |
---|
1052 | n/a | |
---|
1053 | n/a | if buildrecipe is not None: |
---|
1054 | n/a | # call special-case build recipe, e.g. for openssl |
---|
1055 | n/a | buildrecipe(basedir, archList) |
---|
1056 | n/a | |
---|
1057 | n/a | if install is not None: |
---|
1058 | n/a | print("Running install for %s"%(name,)) |
---|
1059 | n/a | runCommand('{ ' + install + ' ;} 2>&1') |
---|
1060 | n/a | |
---|
1061 | n/a | print("Done %s"%(name,)) |
---|
1062 | n/a | print("") |
---|
1063 | n/a | |
---|
1064 | n/a | os.chdir(curdir) |
---|
1065 | n/a | |
---|
1066 | n/a | def buildLibraries(): |
---|
1067 | n/a | """ |
---|
1068 | n/a | Build our dependencies into $WORKDIR/libraries/usr/local |
---|
1069 | n/a | """ |
---|
1070 | n/a | print("") |
---|
1071 | n/a | print("Building required libraries") |
---|
1072 | n/a | print("") |
---|
1073 | n/a | universal = os.path.join(WORKDIR, 'libraries') |
---|
1074 | n/a | os.mkdir(universal) |
---|
1075 | n/a | os.makedirs(os.path.join(universal, 'usr', 'local', 'lib')) |
---|
1076 | n/a | os.makedirs(os.path.join(universal, 'usr', 'local', 'include')) |
---|
1077 | n/a | |
---|
1078 | n/a | for recipe in library_recipes(): |
---|
1079 | n/a | buildRecipe(recipe, universal, ARCHLIST) |
---|
1080 | n/a | |
---|
1081 | n/a | |
---|
1082 | n/a | |
---|
1083 | n/a | def buildPythonDocs(): |
---|
1084 | n/a | # This stores the documentation as Resources/English.lproj/Documentation |
---|
1085 | n/a | # inside the framwork. pydoc and IDLE will pick it up there. |
---|
1086 | n/a | print("Install python documentation") |
---|
1087 | n/a | rootDir = os.path.join(WORKDIR, '_root') |
---|
1088 | n/a | buildDir = os.path.join('../../Doc') |
---|
1089 | n/a | docdir = os.path.join(rootDir, 'pydocs') |
---|
1090 | n/a | curDir = os.getcwd() |
---|
1091 | n/a | os.chdir(buildDir) |
---|
1092 | n/a | # The Doc build changed for 3.4 (technically, for 3.4.1) and for 2.7.9 |
---|
1093 | n/a | runCommand('make clean') |
---|
1094 | n/a | # Assume sphinx-build is on our PATH, checked in checkEnvironment |
---|
1095 | n/a | runCommand('make html') |
---|
1096 | n/a | os.chdir(curDir) |
---|
1097 | n/a | if not os.path.exists(docdir): |
---|
1098 | n/a | os.mkdir(docdir) |
---|
1099 | n/a | os.rename(os.path.join(buildDir, 'build', 'html'), docdir) |
---|
1100 | n/a | |
---|
1101 | n/a | |
---|
1102 | n/a | def buildPython(): |
---|
1103 | n/a | print("Building a universal python for %s architectures" % UNIVERSALARCHS) |
---|
1104 | n/a | |
---|
1105 | n/a | buildDir = os.path.join(WORKDIR, '_bld', 'python') |
---|
1106 | n/a | rootDir = os.path.join(WORKDIR, '_root') |
---|
1107 | n/a | |
---|
1108 | n/a | if os.path.exists(buildDir): |
---|
1109 | n/a | shutil.rmtree(buildDir) |
---|
1110 | n/a | if os.path.exists(rootDir): |
---|
1111 | n/a | shutil.rmtree(rootDir) |
---|
1112 | n/a | os.makedirs(buildDir) |
---|
1113 | n/a | os.makedirs(rootDir) |
---|
1114 | n/a | os.makedirs(os.path.join(rootDir, 'empty-dir')) |
---|
1115 | n/a | curdir = os.getcwd() |
---|
1116 | n/a | os.chdir(buildDir) |
---|
1117 | n/a | |
---|
1118 | n/a | # Not sure if this is still needed, the original build script |
---|
1119 | n/a | # claims that parts of the install assume python.exe exists. |
---|
1120 | n/a | os.symlink('python', os.path.join(buildDir, 'python.exe')) |
---|
1121 | n/a | |
---|
1122 | n/a | # Extract the version from the configure file, needed to calculate |
---|
1123 | n/a | # several paths. |
---|
1124 | n/a | version = getVersion() |
---|
1125 | n/a | |
---|
1126 | n/a | # Since the extra libs are not in their installed framework location |
---|
1127 | n/a | # during the build, augment the library path so that the interpreter |
---|
1128 | n/a | # will find them during its extension import sanity checks. |
---|
1129 | n/a | os.environ['DYLD_LIBRARY_PATH'] = os.path.join(WORKDIR, |
---|
1130 | n/a | 'libraries', 'usr', 'local', 'lib') |
---|
1131 | n/a | print("Running configure...") |
---|
1132 | n/a | runCommand("%s -C --enable-framework --enable-universalsdk=%s " |
---|
1133 | n/a | "--with-universal-archs=%s " |
---|
1134 | n/a | "%s " |
---|
1135 | n/a | "%s " |
---|
1136 | n/a | "LDFLAGS='-g -L%s/libraries/usr/local/lib' " |
---|
1137 | n/a | "CFLAGS='-g -I%s/libraries/usr/local/include' 2>&1"%( |
---|
1138 | n/a | shellQuote(os.path.join(SRCDIR, 'configure')), shellQuote(SDKPATH), |
---|
1139 | n/a | UNIVERSALARCHS, |
---|
1140 | n/a | (' ', '--with-computed-gotos ')[PYTHON_3], |
---|
1141 | n/a | (' ', '--without-ensurepip ')[PYTHON_3], |
---|
1142 | n/a | shellQuote(WORKDIR)[1:-1], |
---|
1143 | n/a | shellQuote(WORKDIR)[1:-1])) |
---|
1144 | n/a | |
---|
1145 | n/a | print("Running make touch") |
---|
1146 | n/a | runCommand("make touch") |
---|
1147 | n/a | |
---|
1148 | n/a | print("Running make") |
---|
1149 | n/a | runCommand("make") |
---|
1150 | n/a | |
---|
1151 | n/a | print("Running make install") |
---|
1152 | n/a | runCommand("make install DESTDIR=%s"%( |
---|
1153 | n/a | shellQuote(rootDir))) |
---|
1154 | n/a | |
---|
1155 | n/a | print("Running make frameworkinstallextras") |
---|
1156 | n/a | runCommand("make frameworkinstallextras DESTDIR=%s"%( |
---|
1157 | n/a | shellQuote(rootDir))) |
---|
1158 | n/a | |
---|
1159 | n/a | del os.environ['DYLD_LIBRARY_PATH'] |
---|
1160 | n/a | print("Copying required shared libraries") |
---|
1161 | n/a | if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')): |
---|
1162 | n/a | runCommand("mv %s/* %s"%( |
---|
1163 | n/a | shellQuote(os.path.join( |
---|
1164 | n/a | WORKDIR, 'libraries', 'Library', 'Frameworks', |
---|
1165 | n/a | 'Python.framework', 'Versions', getVersion(), |
---|
1166 | n/a | 'lib')), |
---|
1167 | n/a | shellQuote(os.path.join(WORKDIR, '_root', 'Library', 'Frameworks', |
---|
1168 | n/a | 'Python.framework', 'Versions', getVersion(), |
---|
1169 | n/a | 'lib')))) |
---|
1170 | n/a | |
---|
1171 | n/a | frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework') |
---|
1172 | n/a | frmDirVersioned = os.path.join(frmDir, 'Versions', version) |
---|
1173 | n/a | path_to_lib = os.path.join(frmDirVersioned, 'lib', 'python%s'%(version,)) |
---|
1174 | n/a | # create directory for OpenSSL certificates |
---|
1175 | n/a | sslDir = os.path.join(frmDirVersioned, 'etc', 'openssl') |
---|
1176 | n/a | os.makedirs(sslDir) |
---|
1177 | n/a | |
---|
1178 | n/a | print("Fix file modes") |
---|
1179 | n/a | gid = grp.getgrnam('admin').gr_gid |
---|
1180 | n/a | |
---|
1181 | n/a | shared_lib_error = False |
---|
1182 | n/a | for dirpath, dirnames, filenames in os.walk(frmDir): |
---|
1183 | n/a | for dn in dirnames: |
---|
1184 | n/a | os.chmod(os.path.join(dirpath, dn), STAT_0o775) |
---|
1185 | n/a | os.chown(os.path.join(dirpath, dn), -1, gid) |
---|
1186 | n/a | |
---|
1187 | n/a | for fn in filenames: |
---|
1188 | n/a | if os.path.islink(fn): |
---|
1189 | n/a | continue |
---|
1190 | n/a | |
---|
1191 | n/a | # "chmod g+w $fn" |
---|
1192 | n/a | p = os.path.join(dirpath, fn) |
---|
1193 | n/a | st = os.stat(p) |
---|
1194 | n/a | os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IWGRP) |
---|
1195 | n/a | os.chown(p, -1, gid) |
---|
1196 | n/a | |
---|
1197 | n/a | if fn in EXPECTED_SHARED_LIBS: |
---|
1198 | n/a | # check to see that this file was linked with the |
---|
1199 | n/a | # expected library path and version |
---|
1200 | n/a | data = captureCommand("otool -L %s" % shellQuote(p)) |
---|
1201 | n/a | for sl in EXPECTED_SHARED_LIBS[fn]: |
---|
1202 | n/a | if ("\t%s " % sl) not in data: |
---|
1203 | n/a | print("Expected shared lib %s was not linked with %s" |
---|
1204 | n/a | % (sl, p)) |
---|
1205 | n/a | shared_lib_error = True |
---|
1206 | n/a | |
---|
1207 | n/a | if shared_lib_error: |
---|
1208 | n/a | fatal("Unexpected shared library errors.") |
---|
1209 | n/a | |
---|
1210 | n/a | if PYTHON_3: |
---|
1211 | n/a | LDVERSION=None |
---|
1212 | n/a | VERSION=None |
---|
1213 | n/a | ABIFLAGS=None |
---|
1214 | n/a | |
---|
1215 | n/a | fp = open(os.path.join(buildDir, 'Makefile'), 'r') |
---|
1216 | n/a | for ln in fp: |
---|
1217 | n/a | if ln.startswith('VERSION='): |
---|
1218 | n/a | VERSION=ln.split()[1] |
---|
1219 | n/a | if ln.startswith('ABIFLAGS='): |
---|
1220 | n/a | ABIFLAGS=ln.split()[1] |
---|
1221 | n/a | if ln.startswith('LDVERSION='): |
---|
1222 | n/a | LDVERSION=ln.split()[1] |
---|
1223 | n/a | fp.close() |
---|
1224 | n/a | |
---|
1225 | n/a | LDVERSION = LDVERSION.replace('$(VERSION)', VERSION) |
---|
1226 | n/a | LDVERSION = LDVERSION.replace('$(ABIFLAGS)', ABIFLAGS) |
---|
1227 | n/a | config_suffix = '-' + LDVERSION |
---|
1228 | n/a | if getVersionMajorMinor() >= (3, 6): |
---|
1229 | n/a | config_suffix = config_suffix + '-darwin' |
---|
1230 | n/a | else: |
---|
1231 | n/a | config_suffix = '' # Python 2.x |
---|
1232 | n/a | |
---|
1233 | n/a | # We added some directories to the search path during the configure |
---|
1234 | n/a | # phase. Remove those because those directories won't be there on |
---|
1235 | n/a | # the end-users system. Also remove the directories from _sysconfigdata.py |
---|
1236 | n/a | # (added in 3.3) if it exists. |
---|
1237 | n/a | |
---|
1238 | n/a | include_path = '-I%s/libraries/usr/local/include' % (WORKDIR,) |
---|
1239 | n/a | lib_path = '-L%s/libraries/usr/local/lib' % (WORKDIR,) |
---|
1240 | n/a | |
---|
1241 | n/a | # fix Makefile |
---|
1242 | n/a | path = os.path.join(path_to_lib, 'config' + config_suffix, 'Makefile') |
---|
1243 | n/a | fp = open(path, 'r') |
---|
1244 | n/a | data = fp.read() |
---|
1245 | n/a | fp.close() |
---|
1246 | n/a | |
---|
1247 | n/a | for p in (include_path, lib_path): |
---|
1248 | n/a | data = data.replace(" " + p, '') |
---|
1249 | n/a | data = data.replace(p + " ", '') |
---|
1250 | n/a | |
---|
1251 | n/a | fp = open(path, 'w') |
---|
1252 | n/a | fp.write(data) |
---|
1253 | n/a | fp.close() |
---|
1254 | n/a | |
---|
1255 | n/a | # fix _sysconfigdata |
---|
1256 | n/a | # |
---|
1257 | n/a | # TODO: make this more robust! test_sysconfig_module of |
---|
1258 | n/a | # distutils.tests.test_sysconfig.SysconfigTestCase tests that |
---|
1259 | n/a | # the output from get_config_var in both sysconfig and |
---|
1260 | n/a | # distutils.sysconfig is exactly the same for both CFLAGS and |
---|
1261 | n/a | # LDFLAGS. The fixing up is now complicated by the pretty |
---|
1262 | n/a | # printing in _sysconfigdata.py. Also, we are using the |
---|
1263 | n/a | # pprint from the Python running the installer build which |
---|
1264 | n/a | # may not cosmetically format the same as the pprint in the Python |
---|
1265 | n/a | # being built (and which is used to originally generate |
---|
1266 | n/a | # _sysconfigdata.py). |
---|
1267 | n/a | |
---|
1268 | n/a | import pprint |
---|
1269 | n/a | if getVersionMajorMinor() >= (3, 6): |
---|
1270 | n/a | # XXX this is extra-fragile |
---|
1271 | n/a | path = os.path.join(path_to_lib, '_sysconfigdata_m_darwin_darwin.py') |
---|
1272 | n/a | else: |
---|
1273 | n/a | path = os.path.join(path_to_lib, '_sysconfigdata.py') |
---|
1274 | n/a | fp = open(path, 'r') |
---|
1275 | n/a | data = fp.read() |
---|
1276 | n/a | fp.close() |
---|
1277 | n/a | # create build_time_vars dict |
---|
1278 | n/a | exec(data) |
---|
1279 | n/a | vars = {} |
---|
1280 | n/a | for k, v in build_time_vars.items(): |
---|
1281 | n/a | if type(v) == type(''): |
---|
1282 | n/a | for p in (include_path, lib_path): |
---|
1283 | n/a | v = v.replace(' ' + p, '') |
---|
1284 | n/a | v = v.replace(p + ' ', '') |
---|
1285 | n/a | vars[k] = v |
---|
1286 | n/a | |
---|
1287 | n/a | fp = open(path, 'w') |
---|
1288 | n/a | # duplicated from sysconfig._generate_posix_vars() |
---|
1289 | n/a | fp.write('# system configuration generated and used by' |
---|
1290 | n/a | ' the sysconfig module\n') |
---|
1291 | n/a | fp.write('build_time_vars = ') |
---|
1292 | n/a | pprint.pprint(vars, stream=fp) |
---|
1293 | n/a | fp.close() |
---|
1294 | n/a | |
---|
1295 | n/a | # Add symlinks in /usr/local/bin, using relative links |
---|
1296 | n/a | usr_local_bin = os.path.join(rootDir, 'usr', 'local', 'bin') |
---|
1297 | n/a | to_framework = os.path.join('..', '..', '..', 'Library', 'Frameworks', |
---|
1298 | n/a | 'Python.framework', 'Versions', version, 'bin') |
---|
1299 | n/a | if os.path.exists(usr_local_bin): |
---|
1300 | n/a | shutil.rmtree(usr_local_bin) |
---|
1301 | n/a | os.makedirs(usr_local_bin) |
---|
1302 | n/a | for fn in os.listdir( |
---|
1303 | n/a | os.path.join(frmDir, 'Versions', version, 'bin')): |
---|
1304 | n/a | os.symlink(os.path.join(to_framework, fn), |
---|
1305 | n/a | os.path.join(usr_local_bin, fn)) |
---|
1306 | n/a | |
---|
1307 | n/a | os.chdir(curdir) |
---|
1308 | n/a | |
---|
1309 | n/a | if PYTHON_3: |
---|
1310 | n/a | # Remove the 'Current' link, that way we don't accidentally mess |
---|
1311 | n/a | # with an already installed version of python 2 |
---|
1312 | n/a | os.unlink(os.path.join(rootDir, 'Library', 'Frameworks', |
---|
1313 | n/a | 'Python.framework', 'Versions', 'Current')) |
---|
1314 | n/a | |
---|
1315 | n/a | def patchFile(inPath, outPath): |
---|
1316 | n/a | data = fileContents(inPath) |
---|
1317 | n/a | data = data.replace('$FULL_VERSION', getFullVersion()) |
---|
1318 | n/a | data = data.replace('$VERSION', getVersion()) |
---|
1319 | n/a | data = data.replace('$MACOSX_DEPLOYMENT_TARGET', ''.join((DEPTARGET, ' or later'))) |
---|
1320 | n/a | data = data.replace('$ARCHITECTURES', ", ".join(universal_opts_map[UNIVERSALARCHS])) |
---|
1321 | n/a | data = data.replace('$INSTALL_SIZE', installSize()) |
---|
1322 | n/a | data = data.replace('$THIRD_PARTY_LIBS', "\\\n".join(THIRD_PARTY_LIBS)) |
---|
1323 | n/a | |
---|
1324 | n/a | # This one is not handy as a template variable |
---|
1325 | n/a | data = data.replace('$PYTHONFRAMEWORKINSTALLDIR', '/Library/Frameworks/Python.framework') |
---|
1326 | n/a | fp = open(outPath, 'w') |
---|
1327 | n/a | fp.write(data) |
---|
1328 | n/a | fp.close() |
---|
1329 | n/a | |
---|
1330 | n/a | def patchScript(inPath, outPath): |
---|
1331 | n/a | major, minor = getVersionMajorMinor() |
---|
1332 | n/a | data = fileContents(inPath) |
---|
1333 | n/a | data = data.replace('@PYMAJOR@', str(major)) |
---|
1334 | n/a | data = data.replace('@PYVER@', getVersion()) |
---|
1335 | n/a | fp = open(outPath, 'w') |
---|
1336 | n/a | fp.write(data) |
---|
1337 | n/a | fp.close() |
---|
1338 | n/a | os.chmod(outPath, STAT_0o755) |
---|
1339 | n/a | |
---|
1340 | n/a | |
---|
1341 | n/a | |
---|
1342 | n/a | def packageFromRecipe(targetDir, recipe): |
---|
1343 | n/a | curdir = os.getcwd() |
---|
1344 | n/a | try: |
---|
1345 | n/a | # The major version (such as 2.5) is included in the package name |
---|
1346 | n/a | # because having two version of python installed at the same time is |
---|
1347 | n/a | # common. |
---|
1348 | n/a | pkgname = '%s-%s'%(recipe['name'], getVersion()) |
---|
1349 | n/a | srcdir = recipe.get('source') |
---|
1350 | n/a | pkgroot = recipe.get('topdir', srcdir) |
---|
1351 | n/a | postflight = recipe.get('postflight') |
---|
1352 | n/a | readme = textwrap.dedent(recipe['readme']) |
---|
1353 | n/a | isRequired = recipe.get('required', True) |
---|
1354 | n/a | |
---|
1355 | n/a | print("- building package %s"%(pkgname,)) |
---|
1356 | n/a | |
---|
1357 | n/a | # Substitute some variables |
---|
1358 | n/a | textvars = dict( |
---|
1359 | n/a | VER=getVersion(), |
---|
1360 | n/a | FULLVER=getFullVersion(), |
---|
1361 | n/a | ) |
---|
1362 | n/a | readme = readme % textvars |
---|
1363 | n/a | |
---|
1364 | n/a | if pkgroot is not None: |
---|
1365 | n/a | pkgroot = pkgroot % textvars |
---|
1366 | n/a | else: |
---|
1367 | n/a | pkgroot = '/' |
---|
1368 | n/a | |
---|
1369 | n/a | if srcdir is not None: |
---|
1370 | n/a | srcdir = os.path.join(WORKDIR, '_root', srcdir[1:]) |
---|
1371 | n/a | srcdir = srcdir % textvars |
---|
1372 | n/a | |
---|
1373 | n/a | if postflight is not None: |
---|
1374 | n/a | postflight = os.path.abspath(postflight) |
---|
1375 | n/a | |
---|
1376 | n/a | packageContents = os.path.join(targetDir, pkgname + '.pkg', 'Contents') |
---|
1377 | n/a | os.makedirs(packageContents) |
---|
1378 | n/a | |
---|
1379 | n/a | if srcdir is not None: |
---|
1380 | n/a | os.chdir(srcdir) |
---|
1381 | n/a | runCommand("pax -wf %s . 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.pax')),)) |
---|
1382 | n/a | runCommand("gzip -9 %s 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.pax')),)) |
---|
1383 | n/a | runCommand("mkbom . %s 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.bom')),)) |
---|
1384 | n/a | |
---|
1385 | n/a | fn = os.path.join(packageContents, 'PkgInfo') |
---|
1386 | n/a | fp = open(fn, 'w') |
---|
1387 | n/a | fp.write('pmkrpkg1') |
---|
1388 | n/a | fp.close() |
---|
1389 | n/a | |
---|
1390 | n/a | rsrcDir = os.path.join(packageContents, "Resources") |
---|
1391 | n/a | os.mkdir(rsrcDir) |
---|
1392 | n/a | fp = open(os.path.join(rsrcDir, 'ReadMe.txt'), 'w') |
---|
1393 | n/a | fp.write(readme) |
---|
1394 | n/a | fp.close() |
---|
1395 | n/a | |
---|
1396 | n/a | if postflight is not None: |
---|
1397 | n/a | patchScript(postflight, os.path.join(rsrcDir, 'postflight')) |
---|
1398 | n/a | |
---|
1399 | n/a | vers = getFullVersion() |
---|
1400 | n/a | major, minor = getVersionMajorMinor() |
---|
1401 | n/a | pl = Plist( |
---|
1402 | n/a | CFBundleGetInfoString="Python.%s %s"%(pkgname, vers,), |
---|
1403 | n/a | CFBundleIdentifier='org.python.Python.%s'%(pkgname,), |
---|
1404 | n/a | CFBundleName='Python.%s'%(pkgname,), |
---|
1405 | n/a | CFBundleShortVersionString=vers, |
---|
1406 | n/a | IFMajorVersion=major, |
---|
1407 | n/a | IFMinorVersion=minor, |
---|
1408 | n/a | IFPkgFormatVersion=0.10000000149011612, |
---|
1409 | n/a | IFPkgFlagAllowBackRev=False, |
---|
1410 | n/a | IFPkgFlagAuthorizationAction="RootAuthorization", |
---|
1411 | n/a | IFPkgFlagDefaultLocation=pkgroot, |
---|
1412 | n/a | IFPkgFlagFollowLinks=True, |
---|
1413 | n/a | IFPkgFlagInstallFat=True, |
---|
1414 | n/a | IFPkgFlagIsRequired=isRequired, |
---|
1415 | n/a | IFPkgFlagOverwritePermissions=False, |
---|
1416 | n/a | IFPkgFlagRelocatable=False, |
---|
1417 | n/a | IFPkgFlagRestartAction="NoRestart", |
---|
1418 | n/a | IFPkgFlagRootVolumeOnly=True, |
---|
1419 | n/a | IFPkgFlagUpdateInstalledLangauges=False, |
---|
1420 | n/a | ) |
---|
1421 | n/a | writePlist(pl, os.path.join(packageContents, 'Info.plist')) |
---|
1422 | n/a | |
---|
1423 | n/a | pl = Plist( |
---|
1424 | n/a | IFPkgDescriptionDescription=readme, |
---|
1425 | n/a | IFPkgDescriptionTitle=recipe.get('long_name', "Python.%s"%(pkgname,)), |
---|
1426 | n/a | IFPkgDescriptionVersion=vers, |
---|
1427 | n/a | ) |
---|
1428 | n/a | writePlist(pl, os.path.join(packageContents, 'Resources', 'Description.plist')) |
---|
1429 | n/a | |
---|
1430 | n/a | finally: |
---|
1431 | n/a | os.chdir(curdir) |
---|
1432 | n/a | |
---|
1433 | n/a | |
---|
1434 | n/a | def makeMpkgPlist(path): |
---|
1435 | n/a | |
---|
1436 | n/a | vers = getFullVersion() |
---|
1437 | n/a | major, minor = getVersionMajorMinor() |
---|
1438 | n/a | |
---|
1439 | n/a | pl = Plist( |
---|
1440 | n/a | CFBundleGetInfoString="Python %s"%(vers,), |
---|
1441 | n/a | CFBundleIdentifier='org.python.Python', |
---|
1442 | n/a | CFBundleName='Python', |
---|
1443 | n/a | CFBundleShortVersionString=vers, |
---|
1444 | n/a | IFMajorVersion=major, |
---|
1445 | n/a | IFMinorVersion=minor, |
---|
1446 | n/a | IFPkgFlagComponentDirectory="Contents/Packages", |
---|
1447 | n/a | IFPkgFlagPackageList=[ |
---|
1448 | n/a | dict( |
---|
1449 | n/a | IFPkgFlagPackageLocation='%s-%s.pkg'%(item['name'], getVersion()), |
---|
1450 | n/a | IFPkgFlagPackageSelection=item.get('selected', 'selected'), |
---|
1451 | n/a | ) |
---|
1452 | n/a | for item in pkg_recipes() |
---|
1453 | n/a | ], |
---|
1454 | n/a | IFPkgFormatVersion=0.10000000149011612, |
---|
1455 | n/a | IFPkgFlagBackgroundScaling="proportional", |
---|
1456 | n/a | IFPkgFlagBackgroundAlignment="left", |
---|
1457 | n/a | IFPkgFlagAuthorizationAction="RootAuthorization", |
---|
1458 | n/a | ) |
---|
1459 | n/a | |
---|
1460 | n/a | writePlist(pl, path) |
---|
1461 | n/a | |
---|
1462 | n/a | |
---|
1463 | n/a | def buildInstaller(): |
---|
1464 | n/a | |
---|
1465 | n/a | # Zap all compiled files |
---|
1466 | n/a | for dirpath, _, filenames in os.walk(os.path.join(WORKDIR, '_root')): |
---|
1467 | n/a | for fn in filenames: |
---|
1468 | n/a | if fn.endswith('.pyc') or fn.endswith('.pyo'): |
---|
1469 | n/a | os.unlink(os.path.join(dirpath, fn)) |
---|
1470 | n/a | |
---|
1471 | n/a | outdir = os.path.join(WORKDIR, 'installer') |
---|
1472 | n/a | if os.path.exists(outdir): |
---|
1473 | n/a | shutil.rmtree(outdir) |
---|
1474 | n/a | os.mkdir(outdir) |
---|
1475 | n/a | |
---|
1476 | n/a | pkgroot = os.path.join(outdir, 'Python.mpkg', 'Contents') |
---|
1477 | n/a | pkgcontents = os.path.join(pkgroot, 'Packages') |
---|
1478 | n/a | os.makedirs(pkgcontents) |
---|
1479 | n/a | for recipe in pkg_recipes(): |
---|
1480 | n/a | packageFromRecipe(pkgcontents, recipe) |
---|
1481 | n/a | |
---|
1482 | n/a | rsrcDir = os.path.join(pkgroot, 'Resources') |
---|
1483 | n/a | |
---|
1484 | n/a | fn = os.path.join(pkgroot, 'PkgInfo') |
---|
1485 | n/a | fp = open(fn, 'w') |
---|
1486 | n/a | fp.write('pmkrpkg1') |
---|
1487 | n/a | fp.close() |
---|
1488 | n/a | |
---|
1489 | n/a | os.mkdir(rsrcDir) |
---|
1490 | n/a | |
---|
1491 | n/a | makeMpkgPlist(os.path.join(pkgroot, 'Info.plist')) |
---|
1492 | n/a | pl = Plist( |
---|
1493 | n/a | IFPkgDescriptionTitle="Python", |
---|
1494 | n/a | IFPkgDescriptionVersion=getVersion(), |
---|
1495 | n/a | ) |
---|
1496 | n/a | |
---|
1497 | n/a | writePlist(pl, os.path.join(pkgroot, 'Resources', 'Description.plist')) |
---|
1498 | n/a | for fn in os.listdir('resources'): |
---|
1499 | n/a | if fn == '.svn': continue |
---|
1500 | n/a | if fn.endswith('.jpg'): |
---|
1501 | n/a | shutil.copy(os.path.join('resources', fn), os.path.join(rsrcDir, fn)) |
---|
1502 | n/a | else: |
---|
1503 | n/a | patchFile(os.path.join('resources', fn), os.path.join(rsrcDir, fn)) |
---|
1504 | n/a | |
---|
1505 | n/a | |
---|
1506 | n/a | def installSize(clear=False, _saved=[]): |
---|
1507 | n/a | if clear: |
---|
1508 | n/a | del _saved[:] |
---|
1509 | n/a | if not _saved: |
---|
1510 | n/a | data = captureCommand("du -ks %s"%( |
---|
1511 | n/a | shellQuote(os.path.join(WORKDIR, '_root')))) |
---|
1512 | n/a | _saved.append("%d"%((0.5 + (int(data.split()[0]) / 1024.0)),)) |
---|
1513 | n/a | return _saved[0] |
---|
1514 | n/a | |
---|
1515 | n/a | |
---|
1516 | n/a | def buildDMG(): |
---|
1517 | n/a | """ |
---|
1518 | n/a | Create DMG containing the rootDir. |
---|
1519 | n/a | """ |
---|
1520 | n/a | outdir = os.path.join(WORKDIR, 'diskimage') |
---|
1521 | n/a | if os.path.exists(outdir): |
---|
1522 | n/a | shutil.rmtree(outdir) |
---|
1523 | n/a | |
---|
1524 | n/a | imagepath = os.path.join(outdir, |
---|
1525 | n/a | 'python-%s-macosx%s'%(getFullVersion(),DEPTARGET)) |
---|
1526 | n/a | if INCLUDE_TIMESTAMP: |
---|
1527 | n/a | imagepath = imagepath + '-%04d-%02d-%02d'%(time.localtime()[:3]) |
---|
1528 | n/a | imagepath = imagepath + '.dmg' |
---|
1529 | n/a | |
---|
1530 | n/a | os.mkdir(outdir) |
---|
1531 | n/a | volname='Python %s'%(getFullVersion()) |
---|
1532 | n/a | runCommand("hdiutil create -format UDRW -volname %s -srcfolder %s %s"%( |
---|
1533 | n/a | shellQuote(volname), |
---|
1534 | n/a | shellQuote(os.path.join(WORKDIR, 'installer')), |
---|
1535 | n/a | shellQuote(imagepath + ".tmp.dmg" ))) |
---|
1536 | n/a | |
---|
1537 | n/a | |
---|
1538 | n/a | if not os.path.exists(os.path.join(WORKDIR, "mnt")): |
---|
1539 | n/a | os.mkdir(os.path.join(WORKDIR, "mnt")) |
---|
1540 | n/a | runCommand("hdiutil attach %s -mountroot %s"%( |
---|
1541 | n/a | shellQuote(imagepath + ".tmp.dmg"), shellQuote(os.path.join(WORKDIR, "mnt")))) |
---|
1542 | n/a | |
---|
1543 | n/a | # Custom icon for the DMG, shown when the DMG is mounted. |
---|
1544 | n/a | shutil.copy("../Icons/Disk Image.icns", |
---|
1545 | n/a | os.path.join(WORKDIR, "mnt", volname, ".VolumeIcon.icns")) |
---|
1546 | n/a | runCommand("SetFile -a C %s/"%( |
---|
1547 | n/a | shellQuote(os.path.join(WORKDIR, "mnt", volname)),)) |
---|
1548 | n/a | |
---|
1549 | n/a | runCommand("hdiutil detach %s"%(shellQuote(os.path.join(WORKDIR, "mnt", volname)))) |
---|
1550 | n/a | |
---|
1551 | n/a | setIcon(imagepath + ".tmp.dmg", "../Icons/Disk Image.icns") |
---|
1552 | n/a | runCommand("hdiutil convert %s -format UDZO -o %s"%( |
---|
1553 | n/a | shellQuote(imagepath + ".tmp.dmg"), shellQuote(imagepath))) |
---|
1554 | n/a | setIcon(imagepath, "../Icons/Disk Image.icns") |
---|
1555 | n/a | |
---|
1556 | n/a | os.unlink(imagepath + ".tmp.dmg") |
---|
1557 | n/a | |
---|
1558 | n/a | return imagepath |
---|
1559 | n/a | |
---|
1560 | n/a | |
---|
1561 | n/a | def setIcon(filePath, icnsPath): |
---|
1562 | n/a | """ |
---|
1563 | n/a | Set the custom icon for the specified file or directory. |
---|
1564 | n/a | """ |
---|
1565 | n/a | |
---|
1566 | n/a | dirPath = os.path.normpath(os.path.dirname(__file__)) |
---|
1567 | n/a | toolPath = os.path.join(dirPath, "seticon.app/Contents/MacOS/seticon") |
---|
1568 | n/a | if not os.path.exists(toolPath) or os.stat(toolPath).st_mtime < os.stat(dirPath + '/seticon.m').st_mtime: |
---|
1569 | n/a | # NOTE: The tool is created inside an .app bundle, otherwise it won't work due |
---|
1570 | n/a | # to connections to the window server. |
---|
1571 | n/a | appPath = os.path.join(dirPath, "seticon.app/Contents/MacOS") |
---|
1572 | n/a | if not os.path.exists(appPath): |
---|
1573 | n/a | os.makedirs(appPath) |
---|
1574 | n/a | runCommand("cc -o %s %s/seticon.m -framework Cocoa"%( |
---|
1575 | n/a | shellQuote(toolPath), shellQuote(dirPath))) |
---|
1576 | n/a | |
---|
1577 | n/a | runCommand("%s %s %s"%(shellQuote(os.path.abspath(toolPath)), shellQuote(icnsPath), |
---|
1578 | n/a | shellQuote(filePath))) |
---|
1579 | n/a | |
---|
1580 | n/a | def main(): |
---|
1581 | n/a | # First parse options and check if we can perform our work |
---|
1582 | n/a | parseOptions() |
---|
1583 | n/a | checkEnvironment() |
---|
1584 | n/a | |
---|
1585 | n/a | os.environ['MACOSX_DEPLOYMENT_TARGET'] = DEPTARGET |
---|
1586 | n/a | os.environ['CC'] = CC |
---|
1587 | n/a | os.environ['CXX'] = CXX |
---|
1588 | n/a | |
---|
1589 | n/a | if os.path.exists(WORKDIR): |
---|
1590 | n/a | shutil.rmtree(WORKDIR) |
---|
1591 | n/a | os.mkdir(WORKDIR) |
---|
1592 | n/a | |
---|
1593 | n/a | os.environ['LC_ALL'] = 'C' |
---|
1594 | n/a | |
---|
1595 | n/a | # Then build third-party libraries such as sleepycat DB4. |
---|
1596 | n/a | buildLibraries() |
---|
1597 | n/a | |
---|
1598 | n/a | # Now build python itself |
---|
1599 | n/a | buildPython() |
---|
1600 | n/a | |
---|
1601 | n/a | # And then build the documentation |
---|
1602 | n/a | # Remove the Deployment Target from the shell |
---|
1603 | n/a | # environment, it's no longer needed and |
---|
1604 | n/a | # an unexpected build target can cause problems |
---|
1605 | n/a | # when Sphinx and its dependencies need to |
---|
1606 | n/a | # be (re-)installed. |
---|
1607 | n/a | del os.environ['MACOSX_DEPLOYMENT_TARGET'] |
---|
1608 | n/a | buildPythonDocs() |
---|
1609 | n/a | |
---|
1610 | n/a | |
---|
1611 | n/a | # Prepare the applications folder |
---|
1612 | n/a | folder = os.path.join(WORKDIR, "_root", "Applications", "Python %s"%( |
---|
1613 | n/a | getVersion(),)) |
---|
1614 | n/a | fn = os.path.join(folder, "License.rtf") |
---|
1615 | n/a | patchFile("resources/License.rtf", fn) |
---|
1616 | n/a | fn = os.path.join(folder, "ReadMe.rtf") |
---|
1617 | n/a | patchFile("resources/ReadMe.rtf", fn) |
---|
1618 | n/a | fn = os.path.join(folder, "Update Shell Profile.command") |
---|
1619 | n/a | patchScript("scripts/postflight.patch-profile", fn) |
---|
1620 | n/a | fn = os.path.join(folder, "Install Certificates.command") |
---|
1621 | n/a | patchScript("resources/install_certificates.command", fn) |
---|
1622 | n/a | os.chmod(folder, STAT_0o755) |
---|
1623 | n/a | setIcon(folder, "../Icons/Python Folder.icns") |
---|
1624 | n/a | |
---|
1625 | n/a | # Create the installer |
---|
1626 | n/a | buildInstaller() |
---|
1627 | n/a | |
---|
1628 | n/a | # And copy the readme into the directory containing the installer |
---|
1629 | n/a | patchFile('resources/ReadMe.rtf', |
---|
1630 | n/a | os.path.join(WORKDIR, 'installer', 'ReadMe.rtf')) |
---|
1631 | n/a | |
---|
1632 | n/a | # Ditto for the license file. |
---|
1633 | n/a | patchFile('resources/License.rtf', |
---|
1634 | n/a | os.path.join(WORKDIR, 'installer', 'License.rtf')) |
---|
1635 | n/a | |
---|
1636 | n/a | fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w') |
---|
1637 | n/a | fp.write("# BUILD INFO\n") |
---|
1638 | n/a | fp.write("# Date: %s\n" % time.ctime()) |
---|
1639 | n/a | fp.write("# By: %s\n" % pwd.getpwuid(os.getuid()).pw_gecos) |
---|
1640 | n/a | fp.close() |
---|
1641 | n/a | |
---|
1642 | n/a | # And copy it to a DMG |
---|
1643 | n/a | buildDMG() |
---|
1644 | n/a | |
---|
1645 | n/a | if __name__ == "__main__": |
---|
1646 | n/a | main() |
---|