This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: won't match correct version of tcl/tk
Type: behavior Stage: resolved
Components: Build Versions: Python 3.11
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: jett8998, ned.deily
Priority: normal Keywords:

Created on 2021-08-25 14:35 by jett8998, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (5)
msg400272 - (view) Author: 郑之为 (jett8998) Date: 2021-08-25 14:35
I used the following config:
./configure --prefix=/Users/jett/python311 --enable-optimizations --enable-ipv6 --enable-big-digits=30 --with-lto=full --with-experimental-isolated-subinterpreters --with-static-libpython --enable-universalsdk --with-universal-archs=universal2 --with-openssl=/opt/homebrew/opt/openssl@1.1

export CFLAGS="-I/opt/homebrew/opt/xz/include -I/opt/homebrew/opt/tcl-tk/include"
export CPPFLAGS="-I/opt/homebrew/opt/xz/include -I/opt/homebrew/opt/tcl-tk/include"
export LDFLAGS="-L/opt/homebrew/opt/tcl-tk/lib"

and got a version mismatch error: the executable is 8.6 and the library is 8.5
msg400275 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2021-08-25 16:58
Can you be more specific about what you mean by "executable" and "library"?

In particular, please show the results of, where /path/to/python is replaced by the path to the python you have built or installed:

otool -L $(/path/to/python -c 'import _tkinter;print(_tkinter.__file__)')

Most likely the issue is that you need to use additional ./configure arguments rather than trying to modify CFLAGS et al:

  --with-tcltk-includes='-I...'
                          override search for Tcl and Tk include files
  --with-tcltk-libs='-L...'
                          override search for Tcl and Tk libs

or set up the path to pkg-config info for Homebrew's Tcl and Tk packages.  See the comments in setup.py for more info:

https://github.com/python/cpython/blob/main/setup.py#L1898
msg400304 - (view) Author: 郑之为 (jett8998) Date: 2021-08-26 01:49
now it's more like:
*** WARNING: renaming "_tkinter" since importing it failed: dlopen(/Users/jett/cpython/build/lib.macosx-11.5-universal2-3.11/_tkinter.cpython-311-darwin.so, 2): Symbol not found: _TclBN_mp_clear
  Referenced from: /Users/jett/cpython/build/lib.macosx-11.5-universal2-3.11/_tkinter.cpython-311-darwin.so
  Expected in: flat namespace
 in /Users/jett/cpython/build/lib.macosx-11.5-universal2-3.11/_tkinter.cpython-311-darwin.so

Python build finished successfully!
The necessary bits to build these optional modules were not found:
_gdbm                 ossaudiodev           spwd               
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  pwd                   time               


Following modules built successfully but were removed because they could not be imported:
_tkinter                                              


and this:
jett@zhengzhweidembp iucn % /Users/jett/python311/bin/python3.11 guimain.py              Traceback (most recent call last):  File "/Users/jett/Desktop/GitHub/Repos/iucn/guimain.py", line 1, in <module>
    from tkinter import *
    ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jett/python311/lib/python3.11/tkinter/__init__.py", line 37, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
    ^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named '_tkinter'

ans this.
msg400305 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2021-08-26 02:26
It is difficult to offer suggestions based on minimal information. You may be running into an arch mismatch: since you are requesting a universal2 build (x86_64 and arm64), all the third-party libraries your build links with must also be built with both architectures. Or it still could be a mismatched path problem. You can use the otool -L command I suggested before on the renamed _tkinter.so file left in your build/lib.macosx-11.5-universal2-3.11 directory to determine what path to the Tcl and Tk libraries it is using; it should be an absolute path to the Homebrew libraries.  You can also use the "file" command on the _tkinter file and on the Tcl and Tk library files to determine which archs are present in each. If this is your first attempt at building Python on macOS, I suggest you start with a simpler ./configure command and then consider adding other options after you have that working. To start with you should only need something like:

./configure --prefix=... --with-openssl=... --with-tcltk-includes=... --with-tcltk-libs=...
msg402125 - (view) Author: 郑之为 (jett8998) Date: 2021-09-18 09:20
OK... It's fine now, tests are still failing
History
Date User Action Args
2022-04-11 14:59:49adminsetgithub: 89165
2021-09-18 09:20:01jett8998setstatus: open -> closed
resolution: not a bug
messages: + msg402125

stage: resolved
2021-08-26 02:26:18ned.deilysetmessages: + msg400305
2021-08-26 01:49:26jett8998setmessages: + msg400304
2021-08-25 16:58:10ned.deilysetnosy: + ned.deily
messages: + msg400275
2021-08-25 14:35:52jett8998create