|
root / lang / python / build.sh
build.sh Bash 51 lines 2.2 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
#!/bin/bash
# Build script for CPython 3.13.
#
# Links the OS-provided OpenSSL 3.5 (base, in /usr) — so _ssl/_hashlib build
# stock with no LibreSSL patches, and pip + HTTPS work out of the box. zlib
# and libffi also come from the base system.

set -e
cd "$SRCDIR"

# Hammerhead is illumos with a renamed sysname. CPython's configure derives its
# platform logic (LDSHARED, Py_SUNOS_VERSION, dynamic loading, ...) from
# `uname -s`, which returns "Hammerhead" — so NONE of the SunOS/Solaris branches
# fire. Symptoms: LDSHARED defaults to bare `ld` (extension .so links fail with
# "cannot find entry symbol _start" + undefined Py symbols), and socketmodule.c
# re-declares sethostname() (Py_SUNOS_VERSION undefined, i.e. <= 510), clashing
# with illumos <unistd.h>. Map Hammerhead -> SunOS in configure so the correct
# SunOS/5.x + GCC branches activate: LDSHARED becomes '$(CC) -shared' (GNU-ld
# friendly) and Py_SUNOS_VERSION becomes 511. Same approach as the other ports'
# hammerhead-solaris-compat patches; done as a string-keyed sed so it survives
# Python patch-version bumps.
sed -i 's/ac_sys_system=`uname -s`/&; if test "$ac_sys_system" = Hammerhead; then ac_sys_system=SunOS; fi/' configure

export CFLAGS="${CFLAGS:--O2} -fPIC"
export CPPFLAGS="-I$PREFIX/include"
# rpath: libpython3.13.so + any zport deps live at $PREFIX/lib; the base
# OpenSSL/ffi/z live at /usr/lib. Bake both so nothing needs LD_LIBRARY_PATH.
export LDFLAGS="-L$PREFIX/lib -R$PREFIX/lib -R/usr/lib"
# illumos: the _socket module calls hstrerror(), which lives in libresolv
# (not libc/libnsl as on Linux). Without this _socket fails to import with
# "symbol hstrerror: referenced symbol not found".
export LIBS="-lresolv"

./configure \
    --build=$BUILD_TRIPLE \
    --host=$BUILD_TRIPLE \
    --prefix=$PREFIX \
    --enable-shared \
    --with-system-ffi \
    --with-openssl=/usr \
    --with-ensurepip=install

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"

# convenience symlinks (setup.py install names the binary python3.13)
ln -sf python3.13 "$PKGDIR$PREFIX/bin/python3"
ln -sf python3    "$PKGDIR$PREFIX/bin/python"
ln -sf pip3.13    "$PKGDIR$PREFIX/bin/pip3" 2>/dev/null || true
ln -sf pip3       "$PKGDIR$PREFIX/bin/pip"  2>/dev/null || true