pypy / pypy

PyPy is a very fast and compliant implementation of the Python language.
https://pypy.org
Other
1.1k stars 60 forks source link

Tkinter on MacOS: yet more files need to be bundled. #5096

Open brenthuisman opened 2 weeks ago

brenthuisman commented 2 weeks ago

Recently bundling of tk was improved: https://github.com/pypy/pypy/commit/99cdfd711d2d7b3cc962874872644384c1551136

I can see libtk8.6.dylib now, but at least one more file seems to be needed:

Traceback (most recent call last):
  File "/Users/brent/Downloads/tt.py", line 3, in <module>
    root = tk.Tk()
           ^^^^^^^
  File "/Users/brent/Downloads/pypy-c-jit-185689-a624ac9d22a2-macos_x86_64/lib/pypy3.10/tkinter/__init__.py", line 2304, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brent/Downloads/pypy-c-jit-185689-a624ac9d22a2-macos_x86_64/lib/pypy3.10/_tkinter/__init__.py", line 30, in create
    return TkApp(screenName, className,
  File "/Users/brent/Downloads/pypy-c-jit-185689-a624ac9d22a2-macos_x86_64/lib/pypy3.10/_tkinter/app.py", line 164, in __new__
    Tcl_AppInit(self)
  File "/Users/brent/Downloads/pypy-c-jit-185689-a624ac9d22a2-macos_x86_64/lib/pypy3.10/_tkinter/app.py", line 56, in Tcl_AppInit
    app.raiseTclError()
  File "/Users/brent/Downloads/pypy-c-jit-185689-a624ac9d22a2-macos_x86_64/lib/pypy3.10/_tkinter/app.py", line 177, in raiseTclError
    raise TclError(tkffi.string(
_tkinter.TclError: Can't find a usable init.tcl in the following directories: 
    /opt/homebrew_x86_64/Cellar/tcl-tk/8.6.14/lib/tcl8.6 /Users/brent/Downloads/pypy-c-jit-185689-a624ac9d22a2-macos_x86_64/lib/tcl8.6 /Users/brent/Downloads/lib/tcl8.6 /Users/brent/Downloads/pypy-c-jit-185689-a624ac9d22a2-macos_x86_64/library /Users/brent/Downloads/library /Users/brent/Downloads/tcl8.6.14/library /Users/brent/tcl8.6.14/library

This probably means that Tcl wasn't installed properly.

Not sure if that's the only one.

mattip commented 1 week ago

Reformatting the search path:

/opt/homebrew_x86_64/Cellar/tcl-tk/8.6.14/lib/tcl8.6 \
/Users/brent/Downloads/pypy-c-jit-185689-a624ac9d22a2-macos_x86_64/lib/tcl8.6 \
/Users/brent/Downloads/lib/tcl8.6 \
/Users/brent/Downloads/pypy-c-jit-185689-a624ac9d22a2-macos_x86_64/library \
/Users/brent/Downloads/library \
/Users/brent/Downloads/tcl8.6.14/library \
/Users/brent/tcl8.6.14/library

On the linux builds, init.tcl is under the top-level lib/tcl8.?, that directory and its contents is not being shipped. I will look into this further.

mattip commented 1 week ago

Ahh. This is wrong for macOS, the tcl libraries on the buildbot are not in '/usr' https://github.com/pypy/pypy/blob/7e1daef72877773fa4fc25115f5d8199ef274284/pypy/tool/release/make_portable.py#L137-L140

mattip commented 1 week ago

Done in 696ddf3

brenthuisman commented 1 week ago

Nearly there:

Traceback (most recent call last):
  File "/Users/brent/Downloads/tktest.py", line 6, in <module>
    root = tk.Tk()
           ^^^^^^^
  File "/Users/brent/Downloads/pypy-c-jit-185700-f6179b5ae4d3-macos_x86_64/lib/pypy3.10/tkinter/__init__.py", line 2306, in __init__
    self._loadtk()
  File "/Users/brent/Downloads/pypy-c-jit-185700-f6179b5ae4d3-macos_x86_64/lib/pypy3.10/tkinter/__init__.py", line 2322, in _loadtk
    raise RuntimeError("tk.h version (%s) doesn't match libtk.a version (%s)"
RuntimeError: tk.h version (8.5) doesn't match libtk.a version (8.6)

8.5(.9) is what MacOS 14 ships with, so it looks like it might be first in path or somesuch.

mattip commented 1 week ago

Do you have some environment variable like TK_LIBRARY, TKPATH, TCL_LIBRARY or so set?

brenthuisman commented 1 week ago

Nope, those are all unset.