Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3, python2: clean up templates and dead alternatives, combine python2 and python2-tkinter #54161

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions srcpkgs/python3-tkinter/template
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ _desc="Python programming language"

pkgname=python3-tkinter
version=3.13.1
revision=1
revision=2
build_style="gnu-configure"
configure_args="--enable-shared --enable-ipv6
--enable-loadable-sqlite-extensions --with-computed-gotos
--with-dbmliborder=gdbm:ndbm --with-system-expat --with-system-ffi
--without-ensurepip"
pycompile_dirs="
usr/lib/python${version%.*}/tkinter
usr/lib/python${version%.*}/turtledemo
usr/lib/python${version%.*}/turtle.py"
pycompile_dirs="${py3_lib}/tkinter ${py3_lib}/turtledemo ${py3_lib}/turtle.py"
hostmakedepends="pkg-config"
makedepends="libffi-devel readline-devel gdbm-devel openssl-devel
expat-devel sqlite-devel bzip2-devel zlib-devel liblzma-devel tk-devel"
Expand Down Expand Up @@ -63,6 +60,7 @@ do_check() {
}

do_install() {

mkdir -p ${wrksrc}/tmp-destdir/usr/lib
ln -s lib ${wrksrc}/tmp-destdir/usr/lib${XBPS_TARGET_WORDSIZE}

Expand All @@ -71,25 +69,31 @@ do_install() {

# We only care for the idle and tkinter modules.
vmkdir usr/bin
vmkdir usr/lib/python${version%.*}/lib-dynload
mv ${wrksrc}/tmp-destdir/usr/bin/idle${version%.*} \
${DESTDIR}/usr/bin/idle${version%.*}
vmkdir "${py3_lib}/lib-dynload"

local _idle="idle${version%.*}"
local _src_py_lib="${wrksrc}/tmp-destdir/${py3_lib}"
local _dst_py_lib="${DESTDIR}/${py3_lib}"

mv "${wrksrc}/tmp-destdir/usr/bin/${_idle}" "${DESTDIR}/usr/bin"
mv "${_src_py_lib}/lib-dynload"/_tkinter.*.so "${_dst_py_lib}/lib-dynload"

for lib in idlelib tkinter turtledemo turtle.py; do
mv ${wrksrc}/tmp-destdir/usr/lib/python${version%.*}/${lib} \
${DESTDIR}/usr/lib/python${version%.*}/
mv "${_src_py_lib}/${lib}" "${DESTDIR}/${py3_lib}"
done
mv ${wrksrc}/tmp-destdir/usr/lib/python${version%.*}/lib-dynload/_tkinter.cpython-*.so \
${DESTDIR}/usr/lib/python${version%.*}/lib-dynload/
ln -sf idle${version%.*} ${DESTDIR}/usr/bin/idle3

ln -sf "${_idle}" ${DESTDIR}/usr/bin/idle3
ln -sf "${_idle}" ${DESTDIR}/usr/bin/idle
}

idle-python3_package() {
short_desc="${_desc} - IDE for Python3 using Tkinter"
pycompile_dirs="usr/lib/python${version%.*}/idlelib"
pycompile_dirs="${py3_lib}/idlelib"
depends="${sourcepkg}-${version}_${revision}"
conflicts="python<3.0.0_1 python2<=2.7.18.11_1 python3<=3.13.1_1"
Copy link
Member

@sgn sgn Feb 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put: depends="python>=3.0.0_1 python3>=${version}_${revision}"
conflicts resolution works before version resolution, install them first them is nearly impossible, afaik.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A dependency on python is not appropriate, because the these packages should function properly without installing or ignoring the convenience metapackage. The conflict is only to handle cases where people try to update python3-tkinter while locking python at 2.7, before it was a metapackage, in which case this update will overwrite the alternative symlink I'm now removing.

pkg_install() {
vmove usr/bin/idle3*
vmove usr/lib/python${version%.*}/idlelib
vmove usr/bin/idle*
vmove "${py3_lib}/idlelib"
vinstall ${FILESDIR}/idle3.xpm 644 usr/share/pixmaps
vinstall ${FILESDIR}/idle3.desktop 644 usr/share/applications
}
Expand Down
54 changes: 29 additions & 25 deletions srcpkgs/python3/template
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
#
pkgname=python3
version=3.13.1
revision=1
revision=2
build_style="gnu-configure"
configure_args="--enable-shared --enable-ipv6
--enable-loadable-sqlite-extensions --with-computed-gotos
--with-dbmliborder=gdbm:ndbm --with-system-expat
--without-ensurepip ac_cv_working_tzset=yes"
pycompile_dirs="usr/lib/python${version%.*}"
pycompile_dirs="${py3_lib}"
hostmakedepends="pkgconf autoconf-archive automake"
makedepends="libffi-devel readline-devel gdbm-devel openssl-devel
expat-devel sqlite-devel bzip2-devel zlib-devel liblzma-devel"
Expand All @@ -32,8 +32,6 @@ checksum="9cf9427bee9e2242e3877dd0f6b641c1853ca461f39d6503ce260a59c80bf0d9
skip_extraction="${_bluez}.tar.xz"

alternatives="
python:idle:/usr/bin/idle${version%.*}
python:2to3:/usr/bin/2to3-${version%.*}
python:pydoc:/usr/bin/pydoc${version%.*}
python:python:/usr/bin/python${version%.*}
python:python.1:/usr/share/man/man1/python${version%.*}.1"
Expand Down Expand Up @@ -126,36 +124,43 @@ do_install() {
rm ${DESTDIR}/${py3_lib}/LICENSE.txt

rm -f ${DESTDIR}/usr/bin/2to3

local _dst_py3_lib="${DESTDIR}/${py3_lib}"

# Remove files that belong to python3-tkinter and idle-python3
rm -f ${DESTDIR}/usr/bin/idle3*
rm -rf ${DESTDIR}/usr/lib/python${version%.*}/idlelib
rm -rf ${DESTDIR}/usr/lib/python${version%.*}/tkinter
rm -rf ${DESTDIR}/usr/lib/python${version%.*}/turtledemo
rm -f ${DESTDIR}/usr/lib/python${version%.*}/turtle.py
rm ${DESTDIR}/usr/bin/idle3*
rm ${_dst_py3_lib}/turtle.py
rm -r ${_dst_py3_lib}/idlelib
rm -r ${_dst_py3_lib}/tkinter
rm -r ${_dst_py3_lib}/turtledemo

# Remove test module and tests that fail to be byte-compiled.
rm -rf ${DESTDIR}/usr/lib/python${version%.*}/test
rm -rf ${DESTDIR}/usr/lib/python${version%.*}/lib2to3/tests
rm -rf ${_dst_py3_lib}/test
rm -rf ${_dst_py3_lib}/lib2to3/tests

# Remove references to the install(1) wrapper.
sed -e "s,${XBPS_WRAPPERDIR},/usr/bin,g" -i \
${DESTDIR}/usr/lib/python${version%.*}/_sysconfigdata_*_*.py \
${DESTDIR}/usr/lib/python${version%.*}/config-${version%.*}*/Makefile
${_dst_py3_lib}/_sysconfigdata_*_*.py \
${_dst_py3_lib}/config-${version%.*}*/Makefile

if [ "$CROSS_BUILD" ]; then
# Remove references to cross toolchain.
sed -i "s/$XBPS_CROSS_TRIPLET-//g" \
${DESTDIR}/usr/lib/python${version%.*}/_sysconfigdata_*_*.py \
${DESTDIR}/usr/lib/python${version%.*}/config-${version%.*}*/Makefile
${_dst_py3_lib}/_sysconfigdata_*_*.py \
${_dst_py3_lib}/config-${version%.*}*/Makefile
sed -i -e "s,$XBPS_CROSS_BASE,,g" \
${DESTDIR}/usr/bin/python${version%.*}-config
fi
sed -i -e "s,-fdebug-prefix-map=[^[:space:]]*=[.],," \

sed -i -e "s,-I./External,," \
-e "s,-ffile-prefix-map=[^[:space:]]*=[.],," \
-e "s,-I./External,," \
-e "s,-fdebug-prefix-map=[^[:space:]]*=[.],," \
${DESTDIR}/usr/bin/python${version%.*}-config \
${DESTDIR}/usr/lib/python${version%.*}/_sysconfigdata_*_*.py \
${DESTDIR}/usr/lib/python${version%.*}/config-${version%.*}*/Makefile
${_dst_py3_lib}/_sysconfigdata_*_*.py \
${_dst_py3_lib}/config-${version%.*}*/Makefile

# https://peps.python.org/pep-0668/
vinstall ${FILESDIR}/EXTERNALLY-MANAGED 644 usr/lib/python${version%.*}
vinstall ${FILESDIR}/EXTERNALLY-MANAGED 644 "${py3_lib}"
}

python3-devel_package() {
Expand All @@ -165,10 +170,9 @@ python3-devel_package() {
vmove usr/bin/python*-config
vmove usr/lib/pkgconfig
vmove usr/include
mv ${DESTDIR}/usr/lib/python${version%.*}/config-${version%.*}*/libpython${version%.*}*.a \
${PKGDESTDIR}/usr/lib
mkdir -p ${DESTDIR}/usr/include/python${version%.*}
mv ${PKGDESTDIR}/usr/include/python${version%.*}/pyconfig.h \
${DESTDIR}/usr/include/python${version%.*}
mv "${DESTDIR}/${py3_lib}"/config-*/libpython*.a "${PKGDESTDIR}/usr/lib"

mkdir -p "${DESTDIR}/${py3_inc}"
mv "${PKGDESTDIR}/${py3_inc}/pyconfig.h" "${DESTDIR}/${py3_inc}"
}
}