Skip to content

bpo-45847: Port _tkinter to PY_STDLIB_MOD - #31698

Merged
miss-islington merged 20 commits into
python:mainfrom
erlend-aasland:ac-tkinter
Mar 31, 2022
Merged

bpo-45847: Port _tkinter to PY_STDLIB_MOD#31698
miss-islington merged 20 commits into
python:mainfrom
erlend-aasland:ac-tkinter

Conversation

@erlend-aasland

@erlend-aaslanderlend-aasland commented Mar 5, 2022

Copy link
Copy Markdown
Contributor
  • Remove --with-tclk-* options from configure
  • Use pkg-config to detect _tkinter dependencies (Tcl/Tk, X11)
  • Manual override via environment variables TCLTK_CFLAGS and TCLTK_LIBS

https://bugs.python.org/issue45847

Automerge-Triggered-By: GH:tiran

@erlend-aasland

erlend-aasland commented Mar 6, 2022

Copy link
Copy Markdown
ContributorAuthor

Looks like the Ubuntu pkg-config files for Tcl/Tk are buggy; they don't provide the correct --libs flags (-L is wrong).

Resolved in commit a8313a1

Now we've got problems on FreeBSD (14.0): X11/Xlib.h is included by tk.h, X11 include path is not passed toCFLAGS:

$ grep -A5 "cc.*tcl" config.logconfigure:12411: cc -o conftest -I/usr/local/include/tcl8.6 -I/usr/local/include/tk8.6 conftest.c -L/usr/local/lib -ltk86 -ltkstub86 -ltcl86 -ltclstub86 >&5In file included from conftest.c:111:/usr/local/include/tk8.6/tk.h:99:13: fatal error: 'X11/Xlib.h' file not found
# include <X11/Xlib.h> ^~~~~~~~~~~~1 error generated.
$ pkg-config --libs --cflags tcl86 tk86-I/usr/local/include/tcl8.6 -I/usr/local/include/tk8.6 -L/usr/local/lib -ltk86 -ltkstub86 -ltcl86 -ltclstub86

Proposed solution: add special case for FreeBSD in 72cf592

@erlend-aasland

Copy link
Copy Markdown
ContributorAuthor

(I squeezed 46e43dcaa599d3fe906cdb3ebd591151af856372, 5156b5764a368578e5eb55da471b74e80e5aa479, and 8af1b258d04b042038e0cc0e5fccfd35aad659af into 72cf592)

@erlend-aaslanderlend-aasland changed the title [WIP] bpo-45847: Port _tkinter to PY_STDLIB_MODbpo-45847: Port _tkinter to PY_STDLIB_MODMar 7, 2022
Comment threadconfigure.ac
Comment on lines +3540 to +3544
#if defined(TK_HEX_VERSION)
# if TK_HEX_VERSION < 0x08040200
# error "Tk older than 8.4.2 not supported"
# endif
#endif

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Drop this and keep the ones below?

@erlend-aaslanderlend-aasland added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 7, 2022
@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @erlend-aasland for commit ea426ef 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 7, 2022
@erlend-aasland

erlend-aasland commented Mar 7, 2022

Copy link
Copy Markdown
ContributorAuthor

Non-Windows buildbot status embedded below (updating this post at irregular intervals)

TL;DR: macOS and RHEL7 buildbots did no longer build _tkinter (change in behaviour).

There were some other issues which have been addressed:

  • A FreeBSD bot failed because the X11 check lacked a guard. Addressed in 5816799
Buildbot status
BuildbotPost PRPre PRStatus
AMD64 FreeBSD Shared PRerrormissing🔴
AMD64 Arch Linux Asan Debug PRyesyes🟢
AMD64 Arch Linux Asan PRyesyes🟢
AMD64 Arch Linux TraceRefs PRyes yes🟢
AMD64 Arch Linux Usan PRyes yes🟢
AMD64 Debian PGO PRyesyes🟢
AMD64 Debian root PRmissingmissing🟢
AMD64 Fedora Stable Clang Installed PRyes yes🟢
AMD64 Fedora Stable Clang PRyesyes🟢
AMD64 Fedora Stable LTO + PGO PRyesyes🟢
AMD64 Fedora Stable LTO PRyesyes🟢
AMD64 Fedora Stable PRyesyes🟢
AMD64 Fedora Stable Refleaks PRyes yes🟢
AMD64 RHEL7 LTO + PGO PRmissingyes🔴
AMD64 RHEL7 LTO PRmissingyes🔴
AMD64 RHEL7 PRmissingyes🔴
AMD64 RHEL7 Refleaks PRmissingyes🔴
AMD64 RHEL8 FIPS Only Blake2 Builtin Hash PRyesyes🟢
AMD64 RHEL8 LTO + PGO PRyesyes🟢
AMD64 RHEL8 LTO PRyesyes🟢
AMD64 RHEL8 PRyesyes🟢
AMD64 RHEL8 Refleaks PRyes yes🟢
AMD64 Ubuntu Shared PRmissingmissing🟢
ARM64 macOS PRmissing (deliberate)yes🟢
PPC64 Fedora PRmissingyes🔴
PPC64LE Fedora Stable Clang Installed PRyesyes🟢
PPC64LE Fedora Stable Clang PRyesyes🟢
PPC64LE Fedora Stable LTO + PGO PRyesyes🟢
PPC64LE Fedora Stable LTO PRyesyes🟢
PPC64LE Fedora Stable PRyesyes🟢
PPC64LE Fedora Stable Refleaks PRyesyes🟢
PPC64LE RHEL7 LTO + PGO PRmissingyes🔴
PPC64LE RHEL7 LTO PRmissingyes🔴
PPC64LE RHEL7 PRmissing yes🔴
PPC64LE RHEL7 Refleaks PRmissingyes🔴
PPC64LE RHEL8 LTO + PGO PRyesyes🟢
PPC64LE RHEL8 LTO PRyes yes🟢
PPC64LE RHEL8 PRyesyes🟢
PPC64LE RHEL8 Refleaks PRyesyes🟢
aarch64 Fedora Stable Clang Installed PRyesyes🟢
aarch64 Fedora Stable Clang PRyesyes🟢
aarch64 Fedora Stable LTO + PGO PR yesyes🟢
aarch64 Fedora Stable LTO PRyesyes🟢
aarch64 Fedora Stable PRyesyes🟢
aarch64 Fedora Stable Refleaks PRyesyes🟢
aarch64 RHEL8 LTO + PGO PRyesyes🟢
aarch64 RHEL8 LTO PRyesyes🟢
aarch64 RHEL8 PRyesyes🟢
aarch64 RHEL8 Refleaks PRyesyes🟢
s390x Debian PRyesyes🟢
s390x Fedora Clang Installed PRyes yes🟢
s390x Fedora Clang PRyesyes🟢
s390x Fedora LTO + PGO PRyesyes🟢
s390x Fedora LTO PRyesyes🟢
s390x Fedora PRyes yes🟢
s390x Fedora Refleaks PRyesyes🟢
s390x RHEL7 LTO + PGO PRmissingyes🔴
s390x RHEL7 LTO PRmissingyes🔴
s390x RHEL7 PRmissingyes🔴
s390x RHEL7 Refleaks PRmissing yes🔴
s390x RHEL8 LTO + PGO PRyes yes🟢
s390x RHEL8 LTO PRyesyes🟢
s390x RHEL8 PRyes yes🟢
s390x RHEL8 Refleaks PRyesyes🟢
s390x SLES PR yes yes🟢
x86 Gentoo Installed with X PRyes yes🟢
x86 Gentoo Non-Debug with X PRyes yes🟢
x86-64 macOS PRmissing (deliberate) yes🟢

@erlend-aasland

Copy link
Copy Markdown
ContributorAuthor

Sparked by Ronald's comment on Discourse:

We could add a hack for macOS... I added this on my macOS 12 install, and it works for me. Not sure how it would fare on older installs, though.

--- a/configure.ac+++ b/configure.ac@@ -3515,8 +3515,21 @@ for _QUERY in \
done
AS_VAR_IF([found_tcltk], [no], [
- TCLTK_CFLAGS=${TCLTK_CFLAGS-""}- TCLTK_LIBS=${TCLTK_LIBS-""}+ AS_CASE([$ac_sys_system],+ [Darwin*], [+ TCLTK_CFLAGS=${TCLTK_CFLAGS-"\+ -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Tcl.framework/Headers \+ -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Tk.framework/Headers \+ -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks \+ "}+ TCLTK_LIBS=${TCLTK_LIBS-"\+ -Wl,-F,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks,-framework,Tcl,-framework,Tk+ "}+ ], [+ TCLTK_CFLAGS=${TCLTK_CFLAGS-""}+ TCLTK_LIBS=${TCLTK_LIBS-""}+ ]+ )
])
dnl FreeBSD has an X11 dependency which is not implicitly resolved.

I'm not sure if it's worth it adding a more complex hack, or if it's worth it adding this hack in the first place.

cc. @tiran@ronaldoussoren@ned-deily

@erlend-aasland

Copy link
Copy Markdown
ContributorAuthor

We could add a hack for macOS... I added this on my macOS 12 install, and it works for me. Not sure how it would fare on older installs, though.

Based on comments from Ned and Ronald, I'm dropping adding any hack for macOS; those building on macOS will have to install MacPorts or Homebrew, and explicitly or implicitly pass this information to configure, for example through PKG_CONFIG_PATH.

@tirantiran added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 13, 2022
@erlend-aasland

Copy link
Copy Markdown
ContributorAuthor

Synced with main to get Serhiy's commits (GH-31839, GH-31938)

@erlend-aasland

Copy link
Copy Markdown
ContributorAuthor

@tiran, do you want another round through the buildbots after I pulled Serhiy's changes? Apart from that, are you fine with this PR as it stands?

@ned-deily

ned-deily commented Mar 17, 2022

Copy link
Copy Markdown
Member

Thanks for the PR! I'd like to review and play with it a bit but I likely won't be able to do so before Monday. If you don't hear anything by then, go ahead.

@erlend-aasland

Copy link
Copy Markdown
ContributorAuthor

@ned-deily would you still like to review this?

@ned-deilyned-deily left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks for doing this. Considering the history and complexity, I'm sure some problems will pop up that, at a minimum, will require more documentation, including the devguide with regard to installing dependencies. I did leave a comment about explicitly documenting the removal of the previous configure options. Also FTR, the macOS installer build script at the moment still depends on those current configure options; I will rework that area prior to the next 3.11 alpha.

Comment threadDoc/whatsnew/3.11.rst
@ned-deily

Copy link
Copy Markdown
Member

Ready to go

@erlend-aasland

Copy link
Copy Markdown
ContributorAuthor

Ready to go

Great, thank you for reviewing! @tiran, can you land this? :)

@tiran

Copy link
Copy Markdown
Member

Love it! Your PR removes a lot of complicated code from setup.py.

@miss-islington
miss-islington merged commit b36d222 into python:mainMar 31, 2022
@erlend-aasland
erlend-aasland deleted the ac-tkinter branch March 31, 2022 10:35
erlend-aasland pushed a commit to erlend-aasland/cpython that referenced this pull request Apr 17, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 9, 2022
(cherry picked from commit 269e726)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
erlend-aasland added a commit that referenced this pull request May 9, 2022
miss-islington added a commit that referenced this pull request May 9, 2022
(cherry picked from commit 269e726)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
@sharewax

Copy link
Copy Markdown

files from centos7 (tk-devel-8.5.13-6.el7.x86_64 and tcl-devel-8.5.13-8.el7.x86_64) doesn't contain files for pkg-config, so tcl for debug version of python you get

Wl,--enable-new-dtags -g -L/usr/lib64/openssl11 -L/opt/wargaming/wargaming-python311/root/usr/lib64-Wl,-z,relro -Wl,-rpath,/opt/wargaming/wargaming
-python311/root/usr/lib64 -Wl,--enable-new-dtags -g -L/usr/lib64/openssl11 -L/opt/wargaming/wargaming-python311/root/usr/lib64-Wl,-z,relro -Wl,-rpa
th,/opt/wargaming/wargaming-python311/root/usr/lib64 -Wl,--enable-new-dtags -fno-semantic-interposition -g -L/usr/lib64/openssl11 -flto -fuse-linke
r-plugin -ffat-lto-objects -flto-partition=none -g -L/opt/wargaming/wargaming-python311/root/usr/lib64-Wl,-z,relro -Wl,-rpath,/opt/wargaming/wargam
ing-python311/root/usr/lib64 -Wl,--enable-new-dtags -fno-semantic-interposition -g -L/usr/lib64/openssl11 -L/opt/wargaming/wargaming-python311/root
/usr/lib64-Wl,-z,relro -Wl,-rpath,/opt/wargaming/wargaming-python311/root/usr/lib64 -Wl,--enable-new-dtags -g -L/usr/lib64/openssl11 -I/opt/wargami
ng/wargaming-python311/root/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4
-grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/include/openssl11 build/temp.linux-x86_64-3.11-pydebug/builddir/build/
BUILD/Python-3.11.0rc1/Modules/_ctypes/_ctypes.o build/temp.linux-x86_64-3.11-pydebug/builddir/build/BUILD/Python-3.11.0rc1/Modules/_ctypes/callbac
ks.o build/temp.linux-x86_64-3.11-pydebug/builddir/build/BUILD/Python-3.11.0rc1/Modules/_ctypes/callproc.o build/temp.linux-x86_64-3.11-pydebug/bui
lddir/build/BUILD/Python-3.11.0rc1/Modules/_ctypes/cfield.o build/temp.linux-x86_64-3.11-pydebug/builddir/build/BUILD/Python-3.11.0rc1/Modules/_cty
pes/stgdict.o -L. -L/opt/wargaming/wargaming-python311/root/usr/lib64 -L/usr/lib64/openssl11 -L/usr/local/lib -lffi -ldl -o build/lib.linux-x86_64-
3.11-pydebug/_ctypes.cpython-311d-x86_64-linux-gnu.so
*** WARNING: renaming "_tkinter" since importing it failed: /builddir/build/BUILD/Python-3.11.0rc1/build/debug/build/lib.linux-x86_64-3.11-pydebug/_tkinter.cpython-311d-x86_64-linux-gnu.so: undefined symbol: Tcl_AddErrorInfo
Following modules built successfully but were removed because they could not be imported:
_tkinter

I'll try to set manually flags TCLTK_CFLAGS and TCLTK_LIBS, but it seems strage. on python3.10 all works well without additional things.

@tiran

Copy link
Copy Markdown
Member

@sharewax Python 3.11 requires pkg-config to detect and configure tkinter. The CentOS 7 packages do not provide a .pc file for TCL and TK. _tkinter compiles for me with correct TCLTK_LIBS. We should document the correct flags for CentOS7 users. Could you please open a new ticket?

@sharewax

sharewax commented Aug 13, 2022

Copy link
Copy Markdown

@tiran Sure. Can you provide correct TCLTK_LIBS for centos7? I would like to finish my installation correctly :)
added:
export TCLTK_LIBS="-ltk8.5 -ltcl8.5"
solves the issue if add in into spec file near other export variables.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@erlend-aasland@bedevere-bot@ned-deily@tiran@sharewax@the-knights-who-say-ni@miss-islington