Skip to content

Commit

Permalink
Add python 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
citrus-it committed Dec 9, 2024
1 parent c4db1c9 commit bd83964
Show file tree
Hide file tree
Showing 47 changed files with 6,204 additions and 3 deletions.
4 changes: 1 addition & 3 deletions build/python312/local.mog
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ license LICENSE license=PSFv2

<transform link mediator=python3 -> set mediator-version $(PYTHONVER)>

# Let the default mediator priority take effect while the highest version is
# the default.
#<transform link mediator=python3 -> set mediator-priority vendor>
<transform link mediator=python3 -> set mediator-priority vendor>

# Add mediated link for /usr/bin/python and python-config
link path=usr/bin/python target=python3
Expand Down
60 changes: 60 additions & 0 deletions build/python313/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

Python module dependencies
--------------------------

setuptools
pip (and pip depends on setuptools! See "Bootstrap" below)

pkg
cryptography
setuptools-rust
semantic-version
typing-extensions
tomli
six
cffi
pycparser
asn1crypto
idna
jsonrpclib
jsonschema
attrs
pyrsistent
js-regex
orjson
pycurl
rapidjson
coverage
pyopenssl
cryptography

bhyve (brand)
pyyaml

glib2
meson
packaging


Bootstrap
---------

To bootstrap modules for a new python version, build 'setuptools' and 'pip'
with the '-f bootstrap' flag, and install these bootstrap packages:

for m in setuptools pip; do
{ cd $m; ./build.sh -f bootstrap -blt; }
done
pfexec pkg install {pip,setuptools}-3XX-bootstrap

then build again, without the bootstrap flag:

for m in setuptools pip; do
{ cd $m; ./build.sh -blt; }
done

and finally switch out the bootstrap packages for the real ones:

pfexec pkg install --reject pip-3XX-bootstrap pip-3XX
pfexec pkg install --reject setuptools-3XX-bootstrap setuptools-3XX

202 changes: 202 additions & 0 deletions build/python313/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
#!/usr/bin/bash
#
# {{{ CDDL HEADER
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
# }}}
#
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
#
. ../../lib/build.sh

PROG=Python
VER=3.13.1
PKG=runtime/python-313
MVER=${VER%.*}
SUMMARY="$PROG $MVER"
DESC="$SUMMARY"

BUILD_DEPENDS_IPS="
developer/build/autoconf
developer/pkg-config
ooce/developer/autoconf-archive
"
RUN_DEPENDS_IPS="
compress/bzip2
database/sqlite-3
library/expat
library/libffi
library/libxml2
library/ncurses
library/readline
library/security/openssl-3
library/zlib
system/library/gcc-runtime
developer/object-file
"
XFORM_ARGS="-D PYTHONVER=$MVER"

HARDLINK_TARGETS="
usr/bin/python$MVER
"
SKIP_RTIME_CHECK=1
NO_SONAME_EXPECTED=1

set_python_version $MVER
set_arch 64

# To expose the CMSG_ macros and new recvmsg() semantics for the socket module
set_standard XPG6

# Save arguments to the stack so that the mdb/pstack plugin can find them.
CFLAGS[amd64]+=" -msave-args"
CFLAGS[aarch64]+=" -mtls-dialect=trad"

export CCSHARED="-fPIC"
CPPFLAGS+=" -I/usr/include/ncurses"
export DFLAGS=-64
MAKE_ARGS="
DFLAGS=-64
DESTSHARED=/usr/lib/python$MVER/lib-dynload
"
MAKE_INSTALL_ARGS=DESTSHARED=/usr/lib/python$MVER/lib-dynload

CONFIGURE_OPTS="
--enable-shared
--with-system-expat
--enable-ipv6
--without-ensurepip
"

CONFIGURE_OPTS[amd64]+="
--enable-optimizations
--with-dtrace
"

CONFIGURE_OPTS[aarch64]+="
--build=${TRIPLETS[amd64]%.*}
--with-build-python=$PYTHON
ac_cv_file__dev_ptmx=yes
ac_cv_file__dev_ptc=no
"

# See https://bugs.python.org/issue25003
# There is (was?) a bug in Python which massively slowed down os.urandom()
# due to the introduction of a call to getentropy() which blocks until there
# is sufficient entropy, and this affected pkg(7) significantly.
# We tell Python that we don't have getentropy(); Solaris does the same.
CONFIGURE_OPTS+=" ac_cv_func_getentropy=no "

# hstrerror() is present in -lresolv, but if configure decides it's available
# then it uses it in a number of modules, which then don't link.
# Versions of Python < 3.11 did not detect this function but the new checks
# in 3.11 are less robust and think it's there even when it isn't.
# https://github.com/python/cpython/issues/89886#issuecomment-1106100113
CONFIGURE_OPTS+=" ac_cv_func_hstrerror=no"

# XXX
CONFIGURE_OPTS+=" ac_cv_readline_rl_startup_hook_takes_args=no"

export DTRACE_CPP=$GCCPATH/bin/cpp

CURSES_CFLAGS="-DHAVE_NCURSESW -D_XOPEN_SOURCE_EXTENDED"
LIBREADLINE_LIBS="-zrecord -lreadline -lncurses"
export CURSES_CFLAGS LIBREADLINE_LIBS

build_init() {
typeset s=${SYSROOT[aarch64]}

addpath PKG_CONFIG_PATH[aarch64] $s/usr/lib/pkgconfig
CONFIGURE_OPTS[aarch64]+=" --with-openssl=$s/usr"
}

pre_configure() {
typeset arch="$1"

save_variable CC

PKG_CONFIG_PATH="${PKG_CONFIG_PATH[$arch]}" \
PANEL_LIBS=`pkg-config --libs panel`
export PANEL_LIBS

! cross_arch $arch && return

CC+=" --sysroot=${SYSROOT[$arch]}"
}

post_configure() {
restore_variable CC
}

post_install() {
python_compile \
-o0 -o1 -o2 \
-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data'
}

TESTSUITE_SED="
1,/Tests result:/ {
/Tests result:/p
d
}
/ slowest tests:/,/^$/d
/Total duration/d
/^make:/d
"

launch_testsuite() {
# Test selection
EXTRATESTOPTS="-uall,-audio,-gui,-largefile,-network -w"
EXTRATESTOPTS+=" --ignorefile $SRCDIR/files/test.exclude"
export EXTRATESTOPTS
if [ -z "$SKIP_TESTSUITE" ] && ( [ -n "$BATCH" ] || ask_to_testsuite ); then
# The compilall test (rightly) gets upset if we force timestamps
save_variable FORCE_PYC_TIMESTAMP
unset FORCE_PYC_TIMESTAMP
BATCH=1 run_testsuite "$@" </dev/null
restore_variable FORCE_PYC_TIMESTAMP
else
SKIP_TESTSUITE=1 # skip the dtrace tests too
fi
}

test_dtrace() {
# Dtrace tests require elevated privileges. They will have been skipped
# as part of the full testsuite run.

[ -n "$SKIP_TESTSUITE" ] && return

typeset logf=$TMPDIR/testsuite-d.log
:> $logf
for dir in $TMPDIR/$BUILDDIR; do
pushd $dir >/dev/null || logerr "chdir $dir"
$PFEXEC $MAKE test TESTOPTS=test_dtrace | tee -a $logf
# Reset ownership on the python cache directories/files which will
# have been created with root ownership.
$PFEXEC chown -R "`stat -c %U $SRCDIR`" .
popd >/dev/null
done
sed "$TESTSUITE_SED" < $logf > $SRCDIR/testsuite-d.log
[ -s $SRCDIR/testsuite-d.log ] \
|| echo "dtrace tests have failed" >> $SRCDIR/testsuite-d.log
}

init
download_source $PROG $PROG $VER
patch_source
prep_build autoconf -autoreconf
build
launch_testsuite
test_dtrace
make_package
clean_up

# Vim hints
# vim:ts=4:sw=4:et:fdm=marker
33 changes: 33 additions & 0 deletions build/python313/common.mog
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.

# Copyright 2021 OmniOS Community Edition (OmniOSce) Association.

# Newer setup tools creates entry point scripts which do things like:
#
# try:
# from importlib import metadata
# except ImportError: # for Python<3.8
# import importlib_metadata as metadata
#
# This causes the IPS dependency resolver to assume that both importlib and
# importlib_metadata should exist, when in fact one is for Python < 3.8 and
# one is for later versions. Depending on the python version, one or the other
# will fail to be found.
#
# Therefore we bypass resolution of these dependencies.

<transform file path=.*/bin/ -> set pkg.depend.bypass-generate .*metadata.* >

# XXX - due to cross compilation in the virtual environment, scripts end up
# with a venv shebang. This needs fixing but for now allow the failed
# dependency.
$(aarch64_ONLY)<transform file path=.*/bin/ \
-> set pkg.depend.bypass-generate python>

55 changes: 55 additions & 0 deletions build/python313/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# {{{ CDDL HEADER
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
# }}}

# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.

set_python_version 3.13

PYVER=$PYTHONVER # 3.13
PYMVER=${PYTHONVER%%.*} # 3
SPYVER=${PYTHONVER//./} # 313

RUN_DEPENDS_IPS="runtime/python-$SPYVER "
XFORM_ARGS="
-D PYTHONVER=$PYVER
-D PYTHONLIB=${PYTHONLIB#/}/python$PYVER
-D PYVER=$PYVER
-D PYMVER=$PYMVER
-D SPYVER=$SPYVER
"

PKGDIFF_HELPER='
s:(vendor-packages/[^-]*)-[0-9.]*:\1-VERSION:g
'

# Python modules ship shared objects with no SONAME
NO_SONAME_EXPECTED=1

# Use an extra directory level for building each module since there can be
# multiple versions of python being built in parallel and if they are built
# in the same directory then they will clobber each other.

# Do this now, before changing the temporary base
init_repos

TMPDIR+="/python$PYVER"
DTMPDIR+="/python$PYVER"
BASE_TMPDIR=$TMPDIR

PEP518OPTS+=" --ignore-installed"

# Use the same python version for dependency resolution
# XXX
#PKGDEPEND="/usr/bin/python$PYTHONVER -Es $PKGDEPEND"

# Vim hints
# vim:ts=4:sw=4:et:fdm=marker
1 change: 1 addition & 0 deletions build/python313/files/ctf.skip
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
amd64/libpython3\.so$
9 changes: 9 additions & 0 deletions build/python313/files/test.exclude
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Elements on the python test suite to skip on OmniOS
#
# illumos does not support multiple SCM_RIGHTS messages in a packet
*FDPassSeparate*
#
# Related to wchar_t differences on illumos
*.test_re.ReTests.test_locale_compiled
*.test_re.ReTests.test_locale_caching
Loading

0 comments on commit bd83964

Please sign in to comment.