Conversation
On Windows in a virtual environment, Tk found no Tcl scripts: the example pointed TCL_LIBRARY to sys.prefix, the virtual environment, instead of the Python installation, and Tcl looks next to the executable, the simulator. tcl_library.py now finds the scripts under sys.base_prefix, for any Tcl version and layout, and sets nothing for a Tcl 9 that carries them in its library. The revert of the variables was a no-op and is gone. Test simple plot waited for its window to be closed, which hangs whenever Tk works; it now closes the window after 5 s like Test advanced plot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It is how the test shows the plot; the timer changed that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
There is still a problem on my side: |
|
Thanks! I think this is a different problem from the one this PR fixes, and not in the bridge: a clash between two Tcl versions in the same process, which Pillow (used by matplotlib's Tk backend) doesn't handle. On Windows, Pillow finds the Tcl/Tk functions by walking all DLLs loaded in the process and taking the first one that exports I reproduced it on Windows CI with NVC 1.22.1, which ships Tcl 9, and Python 3.10 with Tcl 8.6: an access violation, with the Python stack ending in Could you try these?
If this is confirmed, the proper fix belongs in Pillow: on Windows it should use the Tcl/Tk DLLs that |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Standalone Python builds (python-build-standalone) keep Tcl/Tk next to
libpython on Linux. Only the python executable finds them, through its
RPATH, so tkinter failed to load in any simulator embedding the
interpreter:
ImportError: libtcl9tk9.0.so: cannot open shared object file
The libraries have no SONAME, so loading them from Python first does
not help. The package setup now adds that directory to LD_LIBRARY_PATH
of the VUnit process, like add_python_dll_to_path does for PATH on
Windows, and every simulator process inherits it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Added: the Tcl/Tk libraries of the Python installation in every simulator (e343720)
Why. These builds keep the Tcl/Tk shared libraries next to libpython, and only the Why in the bridge, and why Why both changes are needed. With only the library path, the old Tested on Linux with NVC 1.23-devel and GHDL 7.0.0-dev (mcode) and a python-build-standalone CPython 3.14, with no
Not tested: Questa/ModelSim, Riviera-PRO, Active-HDL, macOS and Windows. |
How to run the tests that need no extra Python packages and no user input, and that the PySimpleGUI tests wait for answers to their dialogs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The GitHub release of a version now says what release_notes/<version>.md says when there is one, before the tag message and the generated notes. The notes of 0.1.0 list the known Tcl/Tk issues: standalone Python builds on Linux, fixed by #3, and the Tcl version clash on Windows, #5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lars reported that the matplotlib tests of the example fail with some simulators. A temporary CI job running them on Windows (Python 3.10 and 3.14, NVC and GHDL, prebuilt DLLs) reproduced it with Python 3.10:
Tcl looks for its scripts next to the executable, which inside a simulation is the simulator. The example points
TCL_LIBRARY/TK_LIBRARYto the Python installation, but usedsys.prefix, which in a virtual environment is the environment and has no Tcl. The newtcl_library.pydoes the same withsys.base_prefix, and finds the scripts for any Tcl version and layout (tcl/on Windows,lib/elsewhere) instead of assuming 8.6. It sets nothing for a Tcl 9 that carries its scripts in its library. The testbench loads it withimport_module_from_file, which works on every simulator (exec_fileis not available on Riviera-PRO/Active-HDL).unset_tcl_installationis removed:environ = old_environonly rebinds a name, so it never restored anything.A comment above the plot tests notes a second, separate problem on Windows: a simulator with a Tcl of its own (NVC, Questa) can crash when matplotlib opens a Tk window and Python has another Tcl version, because Pillow and matplotlib use the first Tcl they find in the process. The comment gives the workarounds: a Python with the simulator's Tcl version, or another backend such as
MPLBACKEND=QtAgg. The proper fix belongs in Pillow and matplotlib.The tests behave as before otherwise; Test simple plot still waits for its window to be closed. On Linux the tests passed before when the Python had no Tk, because matplotlib then falls back to the non-interactive Agg backend.
Tested:
TclError.Refs #5: fixes its Linux part. The Windows Tcl version clash of the plot tests stays open there.
🤖 Generated with Claude Code