-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathxcpython.py
More file actions
522 lines (402 loc) · 16.3 KB
/
xcpython.py
File metadata and controls
522 lines (402 loc) · 16.3 KB
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
import os.path
from typing import ClassVar
import runez
from portable_python import LinkerOutcome, ModuleBuilder, PPG
class Bdb(ModuleBuilder):
"""
See https://docs.python.org/3/library/dbm.html
Known issues:
- macos: fails to build statically, symbol not found: _gdbm_version_number
- linux: fails to get detected unless both Bdb and Gdbm are selected
"""
m_build_cwd = "build_unix"
m_debian = "libgdbm-compat-dev"
m_telltale = "{include}/dbm.h"
xenv_CFLAGS = "-fPIC"
@property
def url(self):
return self.cfg_url(self.version) or f"https://ftp.osuosl.org/pub/blfs/conglomeration/db/db-{self.version}.tar.gz"
@property
def version(self):
# Oracle stopped releasing new versions in May 2020 (18.1.40 was last under AGPL)
# Check https://www.oracle.com/database/technologies/related/berkeleydb-downloads.html
return self.cfg_version("6.2.32")
def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args
else:
yield "--enable-shared=no"
yield "--enable-static=yes"
yield "--enable-dbm"
yield "--with-pic=yes"
def _do_linux_compile(self):
self.run_configure("../dist/configure", self.c_configure_args())
self.run_make()
self.run_make("install")
class Bzip2(ModuleBuilder):
"""
See https://docs.python.org/3/library/bz2.html
"""
m_telltale = "{include}/bzlib.h"
def auto_select_reason(self):
if PPG.target.is_macos and self.setup.python_spec.version < "3.8":
return "Required for versions prior to 3.8"
@property
def url(self):
return self.cfg_url(self.version) or f"https://sourceware.org/pub/bzip2/bzip2-{self.version}.tar.gz"
@property
def version(self):
# Last release was 1.0.8 in 2019, project has very infrequent updates
# Check https://sourceware.org/bzip2/downloads.html
return self.cfg_version("1.0.8")
def _do_linux_compile(self):
self.run_make("install", f"PREFIX={self.deps}", "CFLAGS=-fPIC -O2 -g -D_FILE_OFFSET_BITS=64")
class Gdbm(ModuleBuilder):
"""
See https://docs.python.org/2.7/library/gdbm.html
Known issues:
- macos-x86_64: works if selected WITHOUT Bdb (in which case both bdb and gdbm get statically linked)
- macos-arch64: if selected, then `_dbm` fails to build
- linux: fails to build unless both Bdb and Gdbm are selected, undefined symbol: gdbm_version_number
"""
m_debian = "libgdbm-dev"
m_telltale: ClassVar[list] = ["{include}/gdbm.h"]
@property
def url(self):
return self.cfg_url(self.version) or f"https://ftpmirror.gnu.org/gnu/gdbm/gdbm-{self.version}.tar.gz"
@property
def version(self):
# Check https://www.gnu.org.ua/software/gdbm/
return self.cfg_version("1.26")
def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args
else:
yield "--enable-shared=no"
yield "--enable-static=yes"
yield "--enable-libgdbm-compat"
yield "--with-pic=yes"
yield "--disable-nls"
yield "--disable-dependency-tracking"
yield "--disable-rpath"
yield "--disable-silent-rules"
yield "--without-libiconv-prefix"
yield "--without-libintl-prefix"
yield "--without-readline"
def _do_linux_compile(self):
self.run_configure("./configure", self.c_configure_args())
self.run_make()
self.run_make("install")
runez.move(self.deps / "include/ndbm.h", self.deps / "include/gdbm-ndbm.h")
class LibFFI(ModuleBuilder):
"""
Known issues:
- linux: needs libffi-dev installed (even for a static build)
- macos-arch64: fails to build statically, symbol not found: _ffi_closure_trampoline_table_page
"""
m_debian = "!libffi-dev"
m_telltale: ClassVar[list] = ["{include}/ffi.h", "{include}/ffi/ffi.h"]
xenv_CFLAGS = "-fPIC"
@property
def url(self):
return (
self.cfg_url(self.version) or f"https://github.com/libffi/libffi/releases/download/v{self.version}/libffi-{self.version}.tar.gz"
)
@property
def version(self):
# Check https://github.com/libffi/libffi/releases
return self.cfg_version("3.5.2")
def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args
else:
yield "--enable-shared=no"
yield "--enable-static=yes"
yield "--with-pic=yes"
yield PPG.target.is_macos and "--disable-multi-os-directory"
yield "--disable-docs"
def _do_linux_compile(self):
self.run_configure("./configure", self.c_configure_args())
self.run_make()
self.run_make("install")
class Openssl(ModuleBuilder):
"""
See https://wiki.openssl.org/index.php/Compilation_and_Installation
"""
m_include = "openssl"
m_telltale = "{include}/openssl/ssl.h"
def auto_select_reason(self):
if PPG.target.is_macos:
return "Required on macos"
@property
def url(self):
if self.version and self.version.startswith("1.1.1"):
# Not sure why URL suddenly changed for this on github...
vfolder = self.version.replace(".", "_")
return (
self.cfg_url(self.version)
or f"https://github.com/openssl/openssl/releases/download/OpenSSL_{vfolder}/openssl-{self.version}.tar.gz"
)
return f"https://github.com/openssl/openssl/releases/download/openssl-{self.version}/openssl-{self.version}.tar.gz"
@property
def version(self):
# 3.5 is LTS, supported until Apr 2030 (3.0 EOL Sept 2026)
# Check https://github.com/openssl/openssl/releases and https://endoflife.date/openssl
return self.cfg_version("3.5.6")
def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args
else:
yield "-v"
yield "--openssldir=/etc/ssl"
yield "no-shared", "no-idea", "no-tests"
def _do_linux_compile(self):
self.run_configure("./config", self.c_configure_args())
self.run_make("depend")
self.run_make()
self.run_make("install_sw") # See https://github.com/openssl/openssl/issues/8170
class Ncurses(ModuleBuilder):
m_include = "ncursesw"
xenv_CFLAGS = "-fPIC"
@property
def url(self):
return self.cfg_url(self.version) or f"https://ftpmirror.gnu.org/gnu/ncurses/ncurses-{self.version}.tar.gz"
@property
def version(self):
# Check https://invisible-island.net/ncurses/announce.html
return self.cfg_version("6.6")
def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args
else:
yield "--disable-shared"
yield "--enable-static"
yield "--without-ada"
yield "--disable-db-install"
yield "--without-manpages"
yield "--without-progs"
yield "--without-tests"
yield f"--with-pkg-config-libdir={self.deps_lib_dir}/pkgconfig"
yield "--enable-pc-files"
yield "--with-debug=no"
yield "--with-gpm=no"
yield "--enable-widec"
yield "--enable-symlinks"
yield "--enable-sigwinch"
yield "--without-develop"
if PPG.target.is_linux:
yield "--with-terminfo-dirs=/etc/terminfo:/lib/terminfo:/usr/share/terminfo"
if PPG.target.is_macos:
yield "--with-terminfo-dirs=/usr/share/terminfo"
def _do_linux_compile(self):
self.run_configure("./configure", self.c_configure_args())
self.run_make()
self.run_make("install")
class Readline(ModuleBuilder):
"""
See https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/readline.rb
Known issues:
- linux: libreadline-dev must NOT be installed in order for static build to succeed
"""
m_debian = "-libreadline-dev"
m_include = "readline"
m_telltale = "{include}/readline/readline.h"
xenv_CFLAGS = "-fPIC"
@classmethod
def candidate_modules(cls):
return [Ncurses]
@property
def url(self):
return self.cfg_url(self.version) or f"http://ftpmirror.gnu.org/gnu/readline/readline-{self.version}.tar.gz"
@property
def version(self):
# Patched tarballs (e.g. "8.2.13") are available on the GNU FTP when patches accumulate
# Check https://ftpmirror.gnu.org/gnu/readline/ for available tarballs
return self.cfg_version("8.3")
def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args
else:
yield "--enable-shared=no"
yield "--enable-static=yes"
yield "--with-curses"
yield "--enable-multibyte"
yield "--disable-install-examples"
yield "--disable-docs"
yield "--enable-portable-binary"
def _do_linux_compile(self):
self.run_configure("./configure", self.c_configure_args())
self.run_make()
self.run_make("install")
class Sqlite(ModuleBuilder):
"""
Known issues:
- linux: libsqlite3-dev must be installed in order for static build to succeed
"""
m_debian = "+libsqlite3-dev"
m_telltale: ClassVar[list] = ["{include}/sqlite3.h"]
xenv_CFLAGS = "-fPIC"
def linker_outcome(self, is_selected):
if is_selected and not runez.which("tclsh"):
return LinkerOutcome.failed, "%s (apt install tcl)" % runez.red("needs tclsh")
return super().linker_outcome(is_selected)
@property
def url(self):
return self.cfg_url(self.version) or f"https://github.com/sqlite/sqlite/archive/refs/tags/version-{self.version}.tar.gz"
@property
def version(self):
# Check https://sqlite.org/changes.html (avoid withdrawn releases like 3.52.0)
return self.cfg_version("3.51.3")
def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args
else:
yield "--disable-shared"
yield "--disable-tcl"
yield "--disable-readline"
def _do_linux_compile(self):
self.run_configure("./configure", self.c_configure_args())
self.run_make()
self.run_make("install")
class Uuid(ModuleBuilder):
"""
Known issues:
- linux: uuid-dev must be installed in order for static build to succeed
"""
m_debian = "+uuid-dev"
m_include = "uuid"
m_telltale: ClassVar[list] = ["{include}/uuid/uuid.h"]
xenv_CFLAGS = "-fPIC"
@property
def url(self):
return self.cfg_url(self.version) or f"https://sourceforge.net/projects/libuuid/files/libuuid-{self.version}.tar.gz"
@property
def version(self):
# Standalone libuuid (not util-linux), project is mostly dormant
# Check https://sourceforge.net/projects/libuuid/files/
return self.cfg_version("1.0.3")
def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args
else:
yield "--enable-shared=no"
yield "--enable-static=yes"
yield "--with-pic=yes"
def _do_linux_compile(self):
self.run_configure("./configure", self.c_configure_args())
self.run_make()
self.run_make("install")
class Xz(ModuleBuilder):
m_telltale = "{include}/lzma.h"
def auto_select_reason(self):
if not self.resolved_telltale:
return "Required when lzma.h is not available"
@property
def url(self):
return self.cfg_url(self.version) or f"https://downloads.sourceforge.net/project/lzmautils/xz-{self.version}.tar.gz"
@property
def version(self):
# Check https://github.com/tukaani-project/xz/releases
return self.cfg_version("5.8.3")
def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args
else:
yield "--enable-shared=no"
yield "--enable-static=yes"
yield "--with-pic=yes"
yield "--disable-rpath"
yield "--disable-dependency-tracking"
yield "--disable-doc"
yield "--disable-nls"
yield "--without-libintl-prefix"
def _do_linux_compile(self):
self.run_configure("./configure", self.c_configure_args())
self.run_make()
self.run_make("install")
class Zlib(ModuleBuilder):
"""
Known issues:
- linux: needs zlib1g-dev installed (even for a static build)
"""
m_debian = "!zlib1g-dev"
m_telltale = "{include}/zlib.h"
xenv_CFLAGS = "-fPIC"
def auto_select_reason(self):
if PPG.target.is_macos and self.setup.python_spec.version < "3.8":
return "Required for versions prior to 3.8"
@property
def url(self):
return self.cfg_url(self.version) or f"https://zlib.net/fossils/zlib-{self.version}.tar.gz"
@property
def version(self):
# Check https://zlib.net/ and https://github.com/madler/zlib/releases
return self.cfg_version("1.3.2")
def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args
else:
yield "--static"
def _do_linux_compile(self):
self.run_configure("./configure", self.c_configure_args())
self.run_make()
self.run_make("install")
class Zstd(ModuleBuilder):
"""
Newer compression format present in most 3.14+ builds
"""
m_debian = "!libzstd-dev"
m_telltale = "{include}/zstd.h"
xenv_CFLAGS = "-fPIC"
def auto_select_reason(self):
if self.setup.python_spec.version >= "3.14":
if PPG.target.is_macos:
return "Required for 3.14 and up" # Well, "expected" anyway
if not self.resolved_telltale:
return "Required for 3.14 and up"
@property
def url(self):
return (
self.cfg_url(self.version) or f"https://github.com/facebook/zstd/releases/download/v{self.version}/zstd-{self.version}.tar.gz"
)
@property
def version(self):
# Check https://github.com/facebook/zstd/releases
return self.cfg_version("1.5.7")
def _do_linux_compile(self):
# Notably, this does not build when given a relative path.
self.run_make(f"prefix={os.path.abspath(self.deps)}")
# the libdir on the resulting .dylib on Mac is wrong, but as long as we
# staticly compile this doesn't need a fixup. I got as far as:
# "libdir=\\$(executable_path)/../lib")
self.run_make("install", f"prefix={os.path.abspath(self.deps)}")
class Mpdec(ModuleBuilder):
"""
Prevent falling back to bundled libmpdec (deprecated and scheduled for removal in Python 3.16)
"""
m_debian = "!libmpdec-dev"
m_telltale = "{include}/mpdecimal.h"
xenv_CFLAGS = "-fPIC"
def auto_select_reason(self):
if self.setup.python_spec.version >= "3.16":
if PPG.target.is_macos:
return "Required for 3.16 and up"
if not self.resolved_telltale:
return "Required for 3.16 and up"
@property
def url(self):
return self.cfg_url(self.version) or f"https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-{self.version}.tar.gz"
@property
def version(self):
# Check https://www.bytereef.org/mpdecimal/download.html
return self.cfg_version("4.0.1")
def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args
else:
pass # yield "--static"
yield "--disable-cxx"
def _do_linux_compile(self):
self.run_configure("./configure", self.c_configure_args())
self.run_make()
self.run_make("install")