From aa4eb8cafd8fe9821cb831900cb80c6b44c6a3f3 Mon Sep 17 00:00:00 2001 From: Marcelo Duarte Date: Wed, 2 Oct 2024 03:59:34 -0300 Subject: [PATCH] hooks: add VTK (vtkmodules) (#2595) --- cx_Freeze/hooks/vtkmodules.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 cx_Freeze/hooks/vtkmodules.py diff --git a/cx_Freeze/hooks/vtkmodules.py b/cx_Freeze/hooks/vtkmodules.py new file mode 100644 index 000000000..671e3ae84 --- /dev/null +++ b/cx_Freeze/hooks/vtkmodules.py @@ -0,0 +1,32 @@ +"""A collection of functions which are triggered automatically by finder when +VTK package is included. +""" + +from __future__ import annotations + +from typing import TYPE_CHECKING + +from cx_Freeze._compat import IS_WINDOWS +from cx_Freeze.hooks._libs import replace_delvewheel_patch + +if TYPE_CHECKING: + from cx_Freeze.finder import ModuleFinder + from cx_Freeze.module import Module + + +def load_vtkmodules(finder: ModuleFinder, module: Module) -> None: + """The VTK (vtkmodules) package. + + Supported pypi versions (tested from 9.2.6 to 9.3.1). + """ + source_dir = module.file.parent.parent / "vtk.libs" + if source_dir.exists(): # vtk >= 9.3.0 + target_dir = f"lib/{source_dir.name}" + if IS_WINDOWS: + finder.include_files(source_dir, target_dir) + replace_delvewheel_patch(module, source_dir.name) + else: + for source in source_dir.iterdir(): + finder.lib_files[source] = f"{target_dir}/{source.name}" + module.ignore_names.add("_vtkmodules_static") + module.ignore_names.add("vtkmodules._build_paths")