Files
haikuports/dev-lang/python/python3.11-3.11.5.recipe

290 lines
9.8 KiB
Bash

SUMMARY="An interpreted, interactive, object-oriented programming language"
DESCRIPTION="Python is a programming language that lets you work more quickly \
and integrate your systems more effectively. You can learn to use Python and \
see almost immediate gains in productivity and lower maintenance costs.
Python runs on Windows, Linux/Unix, Mac OS X, and has been ported to the Java \
and .NET virtual machines.
Python is free to use, even for commercial products, because of its \
OSI-approved open source license."
HOMEPAGE="https://www.python.org"
LICENSE="Python"
COPYRIGHT="1990-2023 Python Software Foundation"
REVISION="1"
SOURCE_URI="https://www.python.org/ftp/python/$portVersion/Python-$portVersion.tar.xz"
CHECKSUM_SHA256="85cd12e9cf1d6d5a45f17f7afe1cebe7ee628d3282281c492e86adf636defa3f"
SOURCE_DIR="Python-$portVersion"
pyShortVer="${portVersion%.*}"
pyVersionCompat="$portVersion compat >= $pyShortVer"
PATCHES="python$pyShortVer-$portVersion.patchset"
if [ "$secondaryArchSuffix" = _x86 ] ; then
PATCHES+="
python${pyShortVer}_x86-$portVersion.patchset
"
fi
ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"
# On x86_gcc2 we don't want to install the commands in bin/<arch>/, but in bin/.
commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
commandSuffix=
commandBinDir=$prefix/bin
fi
GLOBAL_WRITABLE_FILES="
non-packaged/lib/python$pyShortVer/site-packages directory keep-old
"
PROVIDES="
python$pyShortVer$secondaryArchSuffix = $pyVersionCompat
cmd:2to3_$pyShortVer = $pyVersionCompat
cmd:idle$pyShortVer = $pyVersionCompat
cmd:pydoc$pyShortVer = $pyVersionCompat
cmd:python$pyShortVer = $pyVersionCompat
cmd:python${pyShortVer}_config = $pyVersionCompat
cmd:pyvenv_$pyShortVer = $pyVersionCompat
devel:libpython$pyShortVer$secondaryArchSuffix = 1.0
lib:libpython$pyShortVer$secondaryArchSuffix = 1.0
"
REQUIRES="
haiku$secondaryArchSuffix
cmd:file
lib:libbz2$secondaryArchSuffix
lib:libedit$secondaryArchSuffix
lib:libexpat$secondaryArchSuffix
lib:libffi$secondaryArchSuffix
lib:libintl$secondaryArchSuffix
lib:liblzma$secondaryArchSuffix
lib:libncurses$secondaryArchSuffix
lib:libsqlite3$secondaryArchSuffix
lib:libssl$secondaryArchSuffix
lib:libz$secondaryArchSuffix
"
BUILD_REQUIRES="
haiku${secondaryArchSuffix}_devel
devel:libbz2$secondaryArchSuffix
devel:libedit$secondaryArchSuffix
devel:libexpat$secondaryArchSuffix
devel:libffi$secondaryArchSuffix
devel:liblzma$secondaryArchSuffix
devel:libncurses$secondaryArchSuffix
devel:libsqlite3$secondaryArchSuffix
devel:libssl$secondaryArchSuffix
devel:libtclstub8.6$secondaryArchSuffix
devel:libtk8.6$secondaryArchSuffix
devel:libz$secondaryArchSuffix
"
BUILD_PREREQUIRES="
autoconf_archive
cmd:aclocal
cmd:autoconf
cmd:find
cmd:gcc$secondaryArchSuffix
cmd:ld$secondaryArchSuffix
cmd:libtoolize$secondaryArchSuffix
cmd:make
cmd:pkg_config$secondaryArchSuffix
"
BUILD()
{
autoreconf -fi
# From ./configure:
# "compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
# for debug/optimization stuff. BASECFLAGS is for flags that are required
# just to get things to compile and link."
export BASECFLAGS="-D_BSD_SOURCE"
# Not exporting OPT ends up with "-g -fwrapv -O3 -Wall" being used,
# and using OPT="" means the build ends up being "-O0".
export OPT="-fwrapv -O3 -Wall"
runConfigure --omit-dirs binDir,includeDir ./configure \
--bindir=$commandBinDir \
--includedir=$developDir/headers \
--enable-optimizations \
--enable-shared \
--with-ensurepip=no \
--with-readline=editline \
--with-system-expat \
--with-system-ffi \
--without-static-libpython
# configure: WARNING: --with(out)-system-ffi is ignored on this platform
# --with-lto # this one is too CPU/RAM intensive.
# ToDo: See if something like this helps with tz related tests or not.
# --with-tzpath=$libDir/tcl8.6/tzdata
# prevent make from rebuilding stuff that requires python
touch Parser/asdl* Python/Python-ast.c Include/Python-ast.h
rm -f python
# Uncomment when doing repeated builds (for testing different flags/options).
# make clean
# NOTE: When using "--enable-optimizations" above, using "make $jobArgs" might be unreliable.
# Can see several instances of, for example:
#
# libgcov profiling error:/sources/Python-3.11.4/Objects/object.gcda:Merge mismatch for function 51
# libgcov profiling error:/sources/Python-3.11.4/Parser/parser.gcda:Merge mismatch for function 83
#
# Build might end OK (with only some "missing profile" warnings later on), or it can fail
# with something like:
#
# "Parser/parser.c:38718:1: error: corrupted profile info: invalid time profile"
#
# Not using multiple jobs for make solves both the warnings and the possible error.
# make $jobArgs
make -j 1
}
INSTALL()
{
# altinstall avoids clobbering $prefix/bin/{2to3,idle3,pydoc3,python3,python3-config}
make altinstall
rm $libDir/libpython3.so
# ToDo: use this instead?
# mv $libDir/libpython3.so $libDir/libpython$pyShortVer.so
if [ "$targetArchitecture" = x86_gcc2 ]; then
# On x86_gcc2, move lib-dynload to lib/python3.x/
mv $libDir/python$pyShortVer/lib-dynload $prefix/lib/python$pyShortVer/
fi
prepareInstalledDevelLibs libpython$pyShortVer
fixPkgconfig
if [ "$targetArchitecture" = x86_gcc2 ]; then
# fix pkgconfig to match configure flags
sed -i -e 's,headers/x86,headers,' $developLibDir/pkgconfig/python*.pc
fi
mkdir -p $prefix/lib/python$pyShortVer/vendor-packages
echo 'This directory contains packaged python modules.' \
>$prefix/lib/python$pyShortVer/vendor-packages/README
mkdir -p $prefix/non-packaged/lib/python$pyShortVer
mv $prefix/lib/python$pyShortVer/site-packages $prefix/non-packaged/lib/python$pyShortVer/
# drop testsuite altogether; move to a separate package if needed
cd $prefix/lib/python$pyShortVer
rm -rf ctypes/test distutils/tests idlelib/idle_test lib2to3/tests \
sqlite3/test test tkinter/test unittest/test
}
# Some of the test will crash, invoking the crash dialog, and will hang waiting for
# user's interaction. To avoid that, make sure to configure your system by adding
# the following lines in the file "~/config/settings/system/debug_server/settings":
##---
# executable_actions {
# /sources/Python-$portVersion/python kill
# }
##---
# Replace $portVersion as necessary.
# For some tests that purposefully crash, it would make sense to add support for
# crash-report suppression (as done for other platforms) on "tests/support/__init__,py"'s
# SuppressCrashReport class.
# But that needs support from Haiku's debug_server, as we can't change settings from
# the recipe's building environment at the moment (https://dev.haiku-os.org/ticket/10301)
# To see the available test-runs options:
# > hp -E python3.11
# > LIBRARY_PATH=/sources/Python-3.11.4:%A/lib:/boot/home/config/non-packaged/lib:/boot/home/config/lib:/boot/system/non-packaged/lib:/boot/system/lib python -m test --help
#
# To only execute a particular test:
# > cd Lib/test
# > PYTHONPATH="../":$PYTHONPATH python -m test test_xxx
TEST()
{
# Remove tests data left-overs, if any:
rm -f -r /boot/system/cache/tmp/
rm -f -d -r build/test_python*
local test_options=(
# Use this to get same test order on different runs (actual value not important).
# --randseed 0
# Possibly useful?
# --tempdir=/another_drive/tmp
# Enable/disable certain tests by "resource" type:
# -uall,-audio,-cpu,-curses,-decimal,-gui,-largefile,-network,-subprocess,-tzdata,-urlfetch
# distutils is deprecated, and will be removed on 3.12.
-x test_distutils
# The following tests invoke the crash dialog, and unless your configure
# debug_server default action to "kill" or "report", they will hang waiting for
# user input. See comment above TEST().
-x test_faulthandler
-x test_futures # from test_asyncio. Crashes: Exception (Segment violation)
-x test_subprocess # tends to hang.
-x test_threading # tends to hang.
# Many of the tests hang/stall. We have two options:
#
# 1- Manually remove the problematic test-cases.
# 2- Set a TIMEOUT.
#
# Option 1: Works, but requires manual identification/mainteinance.
#
# Option 2: Doesn't requires maintaining a list of stalling tests, but:
# - Causes errors at the end of the run:
# "unmounting failed: Device/File/Resource Busy"
# - Leaves dangling threads running when the tests timeout:
# "Warning -- threading_cleanup() failed to cleanup 0 threads (count: 0, dangling: 2)"
# (or otherwise leaves the system in a weird state).
# - The time it takes to run the full suite largely increases,
#
# For Option 2, use: "--timeout=300"
#
# Let's use Option 1, for now at least:
# These hang reliably.
-x test__xxsubinterpreters
-x test_asynchat
-x test_concurrent_futures
-x test_interpreters
-x test_multiprocessing_fork
-x test_multiprocessing_forkserver
-x test_multiprocessing_main_handling
-x test_multiprocessing_spawn
-x test_multiprocessing
-x test_threaded_import # test_importlib/test_threaded_import
-x test_socketserver
# "test_asyncio" doesn't seems to runs reliably, even after individually skipping
# all the problematic test-cases that could be identify by running them one by one.
-x test_asyncio
# -x test_asyncio/test_base_events
# -x test_asyncio/test_buffered_proto.py # Exception on Exception handler.
# -x test_asyncio/test_events
# -x test_asyncio/test_sendfile
# -x test_asyncio/test_server # Exception on Exception handler.
# -x test_asyncio/test_sslproto # Exception on Exception handler.
# -x test_asyncio/test_streams
# These not always hang/stall, but they do it enough to warrant skipping for now.
-x test_imaplib
-x test_signal
-x test_socket
-x test_ssl
-x test_urllib2_localnet
# 3.11
-x test_urllib2net
-x test_venv
)
local -x LOGNAME=buildbot # this skips tests_tools/test_freeze, copied from Gentoo's ebuild
make $jobArgs test EXTRATESTOPTS="${test_options[*]}"
}