### this file is sourced not run
PKGVER=3.11.4
PKGARCH=i686

PYTHON_VER=${PKGVER%.*}

# source: LFS 11.3 updated to BLFS SVN r890
TARBALL=Python-$PKGVER.tar.xz
MD5SUM=fb7f7eae520285788449d569e45b6718
SRC_URL=https://www.python.org/ftp/python/3.11.4/$TARBALL
#BUNDLE=fatdog-base-11.3.tar
#SRC_URL=http://distro.ibiblio.org/fatdog/source/900/$BUNDLE

SLACKREQ='libreadline'
SLACKDESC="python3_32: python3_32 $PKGVER (Build-system Python)
python3_32: 
python3_32: The Python 3 package contains the Python development environment. It 
python3_32: is useful for object-oriented programming, writing scripts, 
python3_32: prototyping large programs, or developing entire applications.
python3_32:
python3_32: This contains 32-bit python and libraries.
python3_32: 
python3_32: https://www.python.org/
python3_32:
python3_32: 
"

### override download for LFS sources bundle
# $1-src-dir $2-tarball 
#pkg_download() {
#	echo downloading $BUNDLE for $TARBALL
#	wget -P $1 $SRC_URL
#	tar -xf $1/$BUNDLE --strip-components=1 -C $1 
#	rm $1/$BUNDLE
#}

### default pkg_prepare
### default pkg_package

### build
pkg_build() {
	cd /tmp/Python* &&

	# This is a drop-in replacement for python3-base.
	# The recipe is identical to python3-base except:
	# a) we enable optimisation, and
	# b) due to its location, a lot more libs will be built and used.
	CONFFLAGS="$CONFFLAGS   \
		--enable-shared     \
		--disable-test-modules \
		--with-system-expat \
		--with-system-ffi   \
		--with-readline     \
		--with-ensurepip=install  \
		--with-platlibdir=$LIBDIR \
	" &&
	# --enable-optimizations # this takes forever
	# --without-ensurepip    # build without pip3
	pkg_build_autoconf &&

	# LFS 11.3 suppress warning and urge to upgrade pip3
	cat > /etc/pip.conf << EOF &&
[global]
root-user-action = ignore
disable-pip-version-check = true
EOF

	pkg_build_slackdesc &&

	# multilib (CBLFS)
	# headers
	mv -v /usr/include/python${PYTHON_VER}/pyconfig.h /tmp/pyconfig-32.h &&
	rm -rf /usr/include/python${PYTHON_VER} && mkdir -p /usr/include/python${PYTHON_VER} &&
	mv -v /tmp/pyconfig* /usr/include/python${PYTHON_VER} &&

	# symlinks
	rm -f /usr/bin/python3 &&
	mv -v /usr/bin/python${PYTHON_VER}{,-32} &&
	ln -sfv python${PYTHON_VER}-32 /usr/bin/python3-32 &&
	
	# kill duplicate binaries and include
	rm -rv /usr/bin/{2to3*,*config,pydoc3*,idle3*} &&
	rm -r /usr/$LIBDIR/python${PYTHON_VER}/site-packages /usr/share/man &&
	rm -f /etc/pip.conf &&

	true
}
