Files
haikuports/dev-lang/python/python3.10-3.10.19.recipe
OscarL beeb3b2b7a python3.10: update to version 3.10.19. (#13054)
Added a note on the description regarding the need to uninstall the .hpkg pip/pip_python310 packages, if the users intend to use "upstream pip" (to avoid possible conflicts).
2025-10-11 20:56:14 -03:00

512 lines
19 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.
Note: to install \"pip\" for this Python version, use the following commands:
> pkgman uninstall pip pip_python310
(only needed if you had the .hpkg packaged version of \"pip\" previously installed)
> python3.10 -m ensurepip --default-pip
> python3.10 -m pip install --upgrade pip
And then you should be able to use \"pip\" or \"pip3\" normally."
HOMEPAGE="https://www.python.org"
LICENSE="Python"
COPYRIGHT="1990-2025 Python Software Foundation"
REVISION="1"
SOURCE_URI="https://www.python.org/ftp/python/$portVersion/Python-$portVersion.tar.xz"
CHECKSUM_SHA256="c8f4a596572201d81dd7df91f70e177e19a70f1d489968b54b5fbbf29a97c076"
SOURCE_DIR="Python-$portVersion"
pyShortVer="${portVersion%.*}"
pyVersionCompat="$portVersion compat >= $pyShortVer"
PATCHES="python$pyShortVer-$portVersion.patchset"
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
"
# [RECIPE OPTIONS]>>>
# If this is not intended to be the "default" Python version, set to "false", so "make altinstall"
# is used, and only version-suffixed commands are used in PROVIDES.
installAsDefaultPython=true
# Set to "true" if we should build the "tkinter" module.
# Disabled for now, as tkinter deadlocks on Haiku. Try again when tk drops undroidwish for xlibe.
enableTkinter=false
# Set to "true" to package all the tests into a separate "_tests" package (around 30 MB in size).
# Tests are discarded if set to "false".
packageTests=false
# Set to "false" for faster local/test builds. Around 4 to 5 times faster that way.
optimizedBuild=true
# Set to true to build with "-g" and create a _debuginfo package.
buildWithDebugInfo=true
# Run all tests by default. Set to "true" to make "hp --test" only run then known failing tests.
runOnlyKnownFailingTests=false
# Run only the tests that are generally excluded. Expect LOTS of hangs/crashes/etc.
runOnlyExcludedTests=false
# <<<[RECIPE OPTIONS]
PROVIDES="
python$pyShortVer$secondaryArchSuffix = $pyVersionCompat
cmd:2to3_$pyShortVer = $pyVersionCompat
cmd:pydoc$pyShortVer = $pyVersionCompat
cmd:python$pyShortVer = $pyVersionCompat
cmd:python${pyShortVer}_config = $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:libncursesw$secondaryArchSuffix
lib:libsqlite3$secondaryArchSuffix
lib:libssl$secondaryArchSuffix
lib:libz$secondaryArchSuffix
"
REPLACES="
python310$secondaryArchSuffix
"
BUILD_REQUIRES="
haiku${secondaryArchSuffix}_devel
devel:libbz2$secondaryArchSuffix
devel:libedit$secondaryArchSuffix
devel:libexpat$secondaryArchSuffix
devel:libffi$secondaryArchSuffix
devel:liblzma$secondaryArchSuffix
devel:libncursesw$secondaryArchSuffix
devel:libsqlite3$secondaryArchSuffix
devel:libssl$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
"
if $installAsDefaultPython; then
PROVIDES+="
cmd:2to3 = $portVersion compat >= $pyShortVer
cmd:python3 = $portVersion compat >= $pyShortVer
cmd:pydoc3 = $portVersion compat >= $pyShortVer
cmd:python3_config = $portVersion compat >= $pyShortVer
"
fi
if $enableTkinter; then
PROVIDES+="
cmd:idle$pyShortVer = $pyVersionCompat
"
if $installAsDefaultPython; then
PROVIDES+="
cmd:idle3 = $portVersion compat >= $pyShortVer
"
fi
BUILD_REQUIRES+="
devel:libtclstub8.6$secondaryArchSuffix
devel:libtk8.6$secondaryArchSuffix
"
fi
if $packageTests; then
PROVIDES_tests="
python$pyShortVer${secondaryArchSuffix}_tests = $portVersion
"
REQUIRES_tests="
python$pyShortVer$secondaryArchSuffix == $portVersion base
"
fi
if $buildWithDebugInfo; then
defineDebugInfoPackage python$pyShortVer$secondaryArchSuffix \
$prefix/bin/python$pyShortVer \
$libDir/libpython$pyShortVer.so.1.0 \
$prefix/lib/python$pyShortVer/lib-dynload/_asyncio.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_bisect.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_blake2.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_bz2.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_codecs_cn.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_codecs_hk.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_codecs_iso2022.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_codecs_jp.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_codecs_kr.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_codecs_tw.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_contextvars.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_crypt.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_csv.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_ctypes_test.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_ctypes.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_curses_panel.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_curses.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_datetime.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_decimal.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_elementtree.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_hashlib.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_heapq.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_json.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_lsprof.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_lzma.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_md5.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_multibytecodec.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_multiprocessing.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_opcode.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_pickle.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_posixshmem.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_posixsubprocess.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_queue.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_random.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_sha1.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_sha256.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_sha3.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_sha512.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_socket.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_sqlite3.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_ssl.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_statistics.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_struct.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_testbuffer.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_testcapi.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_testclinic.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_testimportmultiple.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_testinternalcapi.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_testmultiphase.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_xxsubinterpreters.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_xxtestfuzz.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/_zoneinfo.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/array.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/audioop.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/binascii.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/cmath.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/fcntl.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/grp.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/math.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/mmap.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/pyexpat.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/readline.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/resource.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/select.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/spwd.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/syslog.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/termios.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/unicodedata.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/xxlimited_35.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/xxlimited.cpython-310.so \
$prefix/lib/python$pyShortVer/lib-dynload/zlib.cpython-310.so
fi
BUILD()
{
autoupdate
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."
# If not provided, the Makefile ends up with:
# BASECFLAGS= -Wno-unused-result -Wsign-compare
# OPT= -DNDEBUG -g -fwrapv -O3 -Wall
# -NDEBUG gets added by ./configure unless "--with-assertions" is used.
export BASECFLAGS="-pipe -D_BSD_SOURCE"
if $buildWithDebugInfo; then
export BASECFLAGS="$BASECFLAG -g"
fi
export OPT="-fwrapv -Wall" # remove "-g" until we use "defineDebugInfoPackage".
if $optimizedBuild; then
export OPT+=" -O3"
maybeEnableOptimizations="--enable-optimizations"
else
export OPT+=" -O0"
maybeEnableOptimizations=
fi
runConfigure --omit-dirs binDir,includeDir ./configure \
--bindir=$commandBinDir \
--includedir=$developDir/headers \
$maybeEnableOptimizations \
--enable-shared \
--with-ensurepip=no \
--with-readline=editline \
--with-system-expat \
--with-tzpath=$(findpaths -c : B_FIND_PATH_DATA_DIRECTORY zoneinfo)
# --with-lto # this one is too CPU/RAM intensive.
# Uncomment when doing repeated builds (for testing different flags/options).
# echo "[.recipe] Cleaning before rebuild:" && make clean && rm -f python
# NOTE: When using "--enable-optimizations" above, using "make $jobArgs" might be unreliable.
make $jobArgs
}
INSTALL()
{
if $installAsDefaultPython; then
make install
else
# altinstall avoids clobbering $prefix/bin/{idle3,pydoc3,python3,python3-config}
make altinstall
fi
rm $libDir/libpython3.so
# remove some cruft:
rm $prefix/lib/python$pyShortVer/config-$pyShortVer/libpython$pyShortVer.a
rm $prefix/lib/python$pyShortVer/config-$pyShortVer/python.o
# No point in having this if we don't have a working tkinter.
if ! $enableTkinter; then
rm $prefix/bin/idle$pyShortVer
if $installAsDefaultPython; then
rm -f $prefix/bin/idle3
fi
fi
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
prepareInstalledDevelLib 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/
if $packageTests; then
packageEntries tests \
$prefix/lib/python$pyShortVer/idlelib/idle_test \
$prefix/lib/python$pyShortVer/test
else
# drop testsuite altogether
cd $prefix/lib/python$pyShortVer
rm -rf ctypes/test distutils/tests idlelib/idle_test lib2to3/tests sqlite3/test test \
tkinter/test unittest/test
fi
}
# 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-3.*/python kill
# }
##---
# 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.nn
# > LIBRARY_PATH=%A:/boot/system/lib python -m test --help
# or:
# > LD_PRELOAD=./libpython3.nn.so.1.0 python -m test --help
#
# To only execute a particular test (from the $sourceDir):
#
# > LD_PRELOAD=./libpython3.nn.so.1.0 python -m test test_datetime -W
#
# Beware that running tests that way can cause some tests to fail, while they work fine under
# "hp --test"'s chroot. (test_sysconfig.MakefileTests.test_parse_makefile, for example).
# Problem is "os.getcwd()" will return wrong data, causing some file operations to fail.
# For reference... Tests results on beta4 (x64):
# 345 tests OK. 23 tests failed. 28 tests skipped.
TEST()
{
# Remove tests data left-overs, if any:
# rm -f -r /boot/system/cache/tmp/
# rm -f -d -r build/test_python*
make $jobArgs test EXTRATESTOPTS="--cleanup"
local test_options=(
# Use this to get same test order on different runs (actual value not important).
-r
--randseed 7858065
# Print the names of the 10 slowest tests.
--slowest
# Possibly useful?
# --tempdir=/another_drive/tmp
# Enable/disable certain tests by "resource" type:
# -uall,-audio,-cpu,-curses,-decimal,-gui,-largefile,-network,-subprocess,-urlfetch
# make test --help says that "-unone" is the default, but the build is doing this:
# "resources: all,-audio,-gui,-largefile" instead.
#
# Let's be explicit to avoid surprises:
-unone,curses,tzdata
)
local tests_to_exclude=(
# 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 (eg: --timeout=300).
#
# Option 1: Works, but requires manual identification/mainteinance.
#
# Option 2: Doesn't requires maintaining a list of stalling tests, but:
# at the end of the test run it causes:
# - "unmounting failed: Device/File/Resource Busy" errors, as there are
# dangling threads running when the tests timeout (requiring `killall python`)
# - The time it takes to run the full suite largely increases.
#
# 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
-x test_multiprocessing_fork
-x test_multiprocessing_forkserver
-x test_multiprocessing_main_handling
-x test_multiprocessing_spawn
-x test_socketserver
-x test_threaded_import # test_importlib/test_threaded_import
# "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 # 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
# Hang on nightlies
-x test_httplib
-x test_httpservers
-x test_logging
-x test_xmlrpc
# These hang at least once on beta4.
-x test_docxmlrpc
-x test_wsgiref # low/no CPU usage.
-x test_poplib # mid/high CPU usage.
-x test_ftplib # segfaults sometimes?
-x test_smtplib # timeouts sometimes, others, hangs?
-x test_eintr # sometimes runs, others hangs. Seems related to file locking.
)
local tests_that_fail=(
test_asyncore
test_builtin
test_c_locale_coercion
test_compileall
test_ctypes
test_datetime
test_fcntl
test_genericpath
test_json
test_mailbox
test_os
test_pathlib
test_popen
test_posix
test_pty
test_re
test_readline
test_shutil
test_site
test_tarfile
test_time
test_tools
test_utf8_mode
)
local -x LOGNAME=buildbot # this skips tests_tools/test_freeze, copied from Gentoo's ebuild
if $runOnlyExcludedTests; then
make $jobArgs test EXTRATESTOPTS="${test_options[*]} ${tests_to_exclude[*]}"
elif $runOnlyKnownFailingTests; then
make $jobArgs test EXTRATESTOPTS="${test_options[*]} ${tests_that_fail[*]}"
else
# Runs the full test suite (minus the tests that we explicitly exclude).
make $jobArgs test EXTRATESTOPTS="${test_options[*]} ${tests_to_exclude[*]}"
fi
# Occasionally, some test fails seemingly due to the racy nature of tempfile.mktemp().
# Even the help for that function says to NOT use it, but some tests still do.
#
# If you find some strange "æ" suffix on temp dirnames, ej:
# "cwd: /sources/Python-3.nn.nn/build/test_python_10324æ"
# That's due to usages of os_helper.FS_NONASCII.
}