Skip to content

Commit 710c07d

Browse files
authored
fix(wheel): ship the fvtk.qt subpackage so pyvistaqt imports (#142) (#145)
1 parent 3873313 commit 710c07d

4 files changed

Lines changed: 37 additions & 16 deletions

File tree

build-fvtk.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,17 @@ if [ "${FVTK_STRIP:-0}" = "1" ]; then
153153
echo "WARN: no strip binary found; wheel ships unstripped" >&2
154154
fi
155155
fi
156-
# Drop the GTK/Qt/Tk/wx UI-interactor helper packages — pyvista never imports
157-
# them (its Qt path is the separate pyvistaqt package). They're pure-Python so
158-
# they cost nothing to build, but they're junk for a pyvista wheel. The
159-
# generated setup.py hardcodes them in packages=[...]; remove both the dirs and
160-
# the setup.py references so bdist_wheel doesn't fail on the missing dirs.
161-
for sub in gtk qt test tk wx; do
156+
# Drop the GTK/Tk/wx/test UI-interactor helper packages — pyvista never imports
157+
# them. They're pure-Python so they cost nothing to build, but they're junk for a
158+
# pyvista wheel. The generated setup.py hardcodes them in packages=[...]; remove
159+
# both the dirs and the setup.py references so bdist_wheel doesn't fail on the
160+
# missing dirs. KEEP qt: pyvistaqt imports vtkmodules.qt (-> fvtk.qt) at import
161+
# time, so dropping it breaks pyvistaqt (gh-142).
162+
for sub in gtk test tk wx; do
162163
rm -rf "$BUILD/fvtk/$sub" "$BUILD"/build/lib.*/fvtk/$sub 2>/dev/null || true
163164
done
164165
if [ -f "$BUILD/setup.py" ]; then
165-
sed -i -E "/'fvtk\.(gtk|qt|tk|wx|test)',?/d" "$BUILD/setup.py"
166+
sed -i -E "/'fvtk\.(gtk|tk|wx|test)',?/d" "$BUILD/setup.py"
166167
fi
167168

168169
echo "=== wheel ==="

ci/prune_setup_py.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
#!/usr/bin/env python3
2-
"""Prune UI-interactor subpackages from the generated wheel build tree.
2+
"""Prune dead UI-interactor subpackages from the generated wheel build tree.
33
4-
PyVista never imports the gtk/qt/tk/wx/test helper subpackages (its Qt path is
5-
the separate pyvistaqt package), but VTK's generated setup.py hardcodes them in
6-
``packages=[...]``. Remove both the directories and the setup.py references so
7-
``setup.py bdist_wheel`` doesn't fail on missing dirs. Mirrors the same step in
8-
build-fvtk.sh.
4+
PyVista never imports the gtk/tk/wx/test helper subpackages, but VTK's generated
5+
setup.py hardcodes them in ``packages=[...]``. Remove both the directories and the
6+
setup.py references so ``setup.py bdist_wheel`` doesn't fail on missing dirs.
7+
Mirrors the same step in build-fvtk.sh.
8+
9+
The ``qt`` subpackage is deliberately KEPT: pyvistaqt imports ``vtkmodules.qt``
10+
(redirected to ``fvtk.qt``) for ``PyQtImpl`` / ``QVTKRenderWindowInteractor``, and
11+
dropping it breaks pyvistaqt at import time (gh-142). It is pure Python and pulls
12+
in no Qt binding unless one is already imported, so shipping it is free.
913
1014
Usage: python ci/prune_setup_py.py <build_dir>
1115
"""
@@ -16,7 +20,7 @@
1620
import shutil
1721
import sys
1822

19-
SUBPACKAGES = ("gtk", "qt", "tk", "wx", "test")
23+
SUBPACKAGES = ("gtk", "tk", "wx", "test")
2024

2125

2226
def main(build_dir: str) -> int:
@@ -38,7 +42,7 @@ def main(build_dir: str) -> int:
3842
with open(setup_py, "r", encoding="utf-8") as fh:
3943
text = fh.read()
4044
pat = re.compile(
41-
r"^.*'(?:vtkmodules|fvtk)\.(?:gtk|qt|tk|wx|test)',?.*$\n?",
45+
r"^.*'(?:vtkmodules|fvtk)\.(?:gtk|tk|wx|test)',?.*$\n?",
4246
re.MULTILINE,
4347
)
4448
new_text, n = pat.subn("", text)

ci/smoke_min.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ def main() -> int:
3232
cc = import_module(f"{IMPORT_NAME}.vtkCommonCore")
3333
print(f"smoke_min: VTK_VERSION = {cc.vtkVersion.GetVTKVersion()}")
3434

35+
# The qt helper subpackage must ship so pyvistaqt (imports vtkmodules.qt ->
36+
# fvtk.qt) keeps working (gh-142). Pure Python; binds no Qt unless one is
37+
# already imported.
38+
qt = import_module(f"{IMPORT_NAME}.qt")
39+
assert hasattr(qt, "PyQtImpl"), f"{IMPORT_NAME}.qt missing PyQtImpl"
40+
print(f"smoke_min: {IMPORT_NAME}.qt present")
41+
3542
# Non-rendering filter pipeline: sphere -> triangulate. Exercises the
3643
# Filters/Sources + Filters/Core kits and the Python wrapper bridge without
3744
# touching OpenGL.

ci/smoke_test.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,18 @@ def main() -> int:
3333
except Exception as exc: # noqa: BLE001
3434
print(f"smoke: WARNING could not read VTK version: {exc}")
3535

36+
from importlib import import_module
37+
38+
# The qt helper subpackage must ship: pyvistaqt imports vtkmodules.qt
39+
# (redirected to fvtk.qt) at import time, so a wheel that drops it breaks
40+
# pyvistaqt (gh-142). It is pure Python and binds no Qt unless one is already
41+
# imported, so this import is safe with no Qt installed.
42+
qt = import_module(f"{IMPORT_NAME}.qt")
43+
assert hasattr(qt, "PyQtImpl"), f"{IMPORT_NAME}.qt missing PyQtImpl"
44+
print(f"smoke: {IMPORT_NAME}.qt present (PyQtImpl={qt.PyQtImpl})")
45+
3646
# Offscreen render: prove the OpenGL/render-window stack is importable and
3747
# can produce a frame headlessly.
38-
from importlib import import_module
3948

4049
# autoinit wires the rendering factory overrides.
4150
import_module(f"{IMPORT_NAME}.vtkRenderingOpenGL2")

0 commit comments

Comments
 (0)