|
| 1 | +#!/usr/bin/bash |
| 2 | +# |
| 3 | +# {{{ CDDL HEADER |
| 4 | +# |
| 5 | +# This file and its contents are supplied under the terms of the |
| 6 | +# Common Development and Distribution License ("CDDL"), version 1.0. |
| 7 | +# You may only use this file in accordance with the terms of version |
| 8 | +# 1.0 of the CDDL. |
| 9 | +# |
| 10 | +# A full copy of the text of the CDDL should have accompanied this |
| 11 | +# source. A copy of the CDDL is also available via the Internet at |
| 12 | +# http://www.illumos.org/license/CDDL. |
| 13 | +# }}} |
| 14 | +# |
| 15 | +# Copyright 2024 OmniOS Community Edition (OmniOSce) Association. |
| 16 | +# |
| 17 | +. ../../lib/build.sh |
| 18 | + |
| 19 | +PROG=Python |
| 20 | +VER=3.13.1 |
| 21 | +PKG=runtime/python-313 |
| 22 | +MVER=${VER%.*} |
| 23 | +SUMMARY="$PROG $MVER" |
| 24 | +DESC="$SUMMARY" |
| 25 | + |
| 26 | +BUILD_DEPENDS_IPS=" |
| 27 | + developer/build/autoconf |
| 28 | + developer/pkg-config |
| 29 | + ooce/developer/autoconf-archive |
| 30 | +" |
| 31 | +RUN_DEPENDS_IPS=" |
| 32 | + compress/bzip2 |
| 33 | + database/sqlite-3 |
| 34 | + library/expat |
| 35 | + library/libffi |
| 36 | + library/libxml2 |
| 37 | + library/ncurses |
| 38 | + library/readline |
| 39 | + library/security/openssl-3 |
| 40 | + library/zlib |
| 41 | + system/library/gcc-runtime |
| 42 | + developer/object-file |
| 43 | +" |
| 44 | +XFORM_ARGS="-D PYTHONVER=$MVER" |
| 45 | + |
| 46 | +HARDLINK_TARGETS=" |
| 47 | + usr/bin/python$MVER |
| 48 | +" |
| 49 | +SKIP_RTIME_CHECK=1 |
| 50 | +NO_SONAME_EXPECTED=1 |
| 51 | + |
| 52 | +set_python_version $MVER |
| 53 | +set_arch 64 |
| 54 | + |
| 55 | +# To expose the CMSG_ macros and new recvmsg() semantics for the socket module |
| 56 | +set_standard XPG6 |
| 57 | + |
| 58 | +# Save arguments to the stack so that the mdb/pstack plugin can find them. |
| 59 | +CFLAGS[amd64]+=" -msave-args" |
| 60 | +CFLAGS[aarch64]+=" -mtls-dialect=trad" |
| 61 | + |
| 62 | +export CCSHARED="-fPIC" |
| 63 | +CPPFLAGS+=" -I/usr/include/ncurses" |
| 64 | +export DFLAGS=-64 |
| 65 | +MAKE_ARGS=" |
| 66 | + DFLAGS=-64 |
| 67 | + DESTSHARED=/usr/lib/python$MVER/lib-dynload |
| 68 | +" |
| 69 | +MAKE_INSTALL_ARGS=DESTSHARED=/usr/lib/python$MVER/lib-dynload |
| 70 | + |
| 71 | +CONFIGURE_OPTS=" |
| 72 | + --enable-shared |
| 73 | + --with-system-expat |
| 74 | + --enable-ipv6 |
| 75 | + --without-ensurepip |
| 76 | +" |
| 77 | + |
| 78 | +CONFIGURE_OPTS[amd64]+=" |
| 79 | + --enable-optimizations |
| 80 | + --with-dtrace |
| 81 | +" |
| 82 | + |
| 83 | +CONFIGURE_OPTS[aarch64]+=" |
| 84 | + --build=${TRIPLETS[amd64]%.*} |
| 85 | + --with-build-python=$PYTHON |
| 86 | + ac_cv_file__dev_ptmx=yes |
| 87 | + ac_cv_file__dev_ptc=no |
| 88 | +" |
| 89 | + |
| 90 | +# See https://bugs.python.org/issue25003 |
| 91 | +# There is (was?) a bug in Python which massively slowed down os.urandom() |
| 92 | +# due to the introduction of a call to getentropy() which blocks until there |
| 93 | +# is sufficient entropy, and this affected pkg(7) significantly. |
| 94 | +# We tell Python that we don't have getentropy(); Solaris does the same. |
| 95 | +CONFIGURE_OPTS+=" ac_cv_func_getentropy=no " |
| 96 | + |
| 97 | +# hstrerror() is present in -lresolv, but if configure decides it's available |
| 98 | +# then it uses it in a number of modules, which then don't link. |
| 99 | +# Versions of Python < 3.11 did not detect this function but the new checks |
| 100 | +# in 3.11 are less robust and think it's there even when it isn't. |
| 101 | +# https://github.com/python/cpython/issues/89886#issuecomment-1106100113 |
| 102 | +CONFIGURE_OPTS+=" ac_cv_func_hstrerror=no" |
| 103 | + |
| 104 | +# XXX |
| 105 | +CONFIGURE_OPTS+=" ac_cv_readline_rl_startup_hook_takes_args=no" |
| 106 | + |
| 107 | +export DTRACE_CPP=$GCCPATH/bin/cpp |
| 108 | + |
| 109 | +CURSES_CFLAGS="-DHAVE_NCURSESW -D_XOPEN_SOURCE_EXTENDED" |
| 110 | +LIBREADLINE_LIBS="-zrecord -lreadline -lncurses" |
| 111 | +export CURSES_CFLAGS LIBREADLINE_LIBS |
| 112 | + |
| 113 | +build_init() { |
| 114 | + typeset s=${SYSROOT[aarch64]} |
| 115 | + |
| 116 | + addpath PKG_CONFIG_PATH[aarch64] $s/usr/lib/pkgconfig |
| 117 | + CONFIGURE_OPTS[aarch64]+=" --with-openssl=$s/usr" |
| 118 | +} |
| 119 | + |
| 120 | +pre_configure() { |
| 121 | + typeset arch="$1" |
| 122 | + |
| 123 | + save_variable CC |
| 124 | + |
| 125 | + PKG_CONFIG_PATH="${PKG_CONFIG_PATH[$arch]}" \ |
| 126 | + PANEL_LIBS=`pkg-config --libs panel` |
| 127 | + export PANEL_LIBS |
| 128 | + |
| 129 | + ! cross_arch $arch && return |
| 130 | + |
| 131 | + CC+=" --sysroot=${SYSROOT[$arch]}" |
| 132 | +} |
| 133 | + |
| 134 | +post_configure() { |
| 135 | + restore_variable CC |
| 136 | +} |
| 137 | + |
| 138 | +post_install() { |
| 139 | + python_compile \ |
| 140 | + -o0 -o1 -o2 \ |
| 141 | + -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' |
| 142 | +} |
| 143 | + |
| 144 | +TESTSUITE_SED=" |
| 145 | + 1,/Tests result:/ { |
| 146 | + /Tests result:/p |
| 147 | + d |
| 148 | + } |
| 149 | + / slowest tests:/,/^$/d |
| 150 | + /Total duration/d |
| 151 | + /^make:/d |
| 152 | +" |
| 153 | + |
| 154 | +launch_testsuite() { |
| 155 | + # Test selection |
| 156 | + EXTRATESTOPTS="-uall,-audio,-gui,-largefile,-network -w" |
| 157 | + EXTRATESTOPTS+=" --ignorefile $SRCDIR/files/test.exclude" |
| 158 | + export EXTRATESTOPTS |
| 159 | + if [ -z "$SKIP_TESTSUITE" ] && ( [ -n "$BATCH" ] || ask_to_testsuite ); then |
| 160 | + # The compilall test (rightly) gets upset if we force timestamps |
| 161 | + save_variable FORCE_PYC_TIMESTAMP |
| 162 | + unset FORCE_PYC_TIMESTAMP |
| 163 | + BATCH=1 run_testsuite "$@" </dev/null |
| 164 | + restore_variable FORCE_PYC_TIMESTAMP |
| 165 | + else |
| 166 | + SKIP_TESTSUITE=1 # skip the dtrace tests too |
| 167 | + fi |
| 168 | +} |
| 169 | + |
| 170 | +test_dtrace() { |
| 171 | + # Dtrace tests require elevated privileges. They will have been skipped |
| 172 | + # as part of the full testsuite run. |
| 173 | + |
| 174 | + [ -n "$SKIP_TESTSUITE" ] && return |
| 175 | + |
| 176 | + typeset logf=$TMPDIR/testsuite-d.log |
| 177 | + :> $logf |
| 178 | + for dir in $TMPDIR/$BUILDDIR; do |
| 179 | + pushd $dir >/dev/null || logerr "chdir $dir" |
| 180 | + $PFEXEC $MAKE test TESTOPTS=test_dtrace | tee -a $logf |
| 181 | + # Reset ownership on the python cache directories/files which will |
| 182 | + # have been created with root ownership. |
| 183 | + $PFEXEC chown -R "`stat -c %U $SRCDIR`" . |
| 184 | + popd >/dev/null |
| 185 | + done |
| 186 | + sed "$TESTSUITE_SED" < $logf > $SRCDIR/testsuite-d.log |
| 187 | + [ -s $SRCDIR/testsuite-d.log ] \ |
| 188 | + || echo "dtrace tests have failed" >> $SRCDIR/testsuite-d.log |
| 189 | +} |
| 190 | + |
| 191 | +init |
| 192 | +download_source $PROG $PROG $VER |
| 193 | +patch_source |
| 194 | +prep_build autoconf -autoreconf |
| 195 | +build |
| 196 | +launch_testsuite |
| 197 | +test_dtrace |
| 198 | +make_package |
| 199 | +clean_up |
| 200 | + |
| 201 | +# Vim hints |
| 202 | +# vim:ts=4:sw=4:et:fdm=marker |
0 commit comments