Hello All,
I am currently building VTK from source with flag VTK_WHEEL_BUILD
as on to make my own python wheel. However, the python wheel created is not usable. I have to either specify the vtk dll paths in my python program using os.add_dll_directory()
or generate pyi files manually using the generate_pyi.py
file located in the vtkmodules folder to make it work.
I will go through the steps I have followed to make the wheel:
-
Firstly, I set up the necessary flag
VTK_WHEEL_BUILD
as ON in CMAKE GUI and configure and generate my vtk solution file using Visual studio 2022. -
Second, I use the solution file and make the build for my source.
-
This build will create a
setup.py
file in my build directory. -
Then I run the command
python setup.py bdist_wheel
to generate the wheel file which will be created in thebuild\dist
directory. At this point I also have another build inside my build directory where my vtkmodules folder andvtk.py
file reside. -
I then proceed to install the wheel in my venv using
pip install pythonWheel.whl
. -
The installed vtk library is not usable unless I specify the vtk dlls path in my python file using
os.add_dll_directory()
or generate pyi files manually (in the venv).
I tried a couple of trial and error as follows,
- I have also tried to add vtk module dll folder path (which is located in the bin of my vtk build directory) to
VTK_DLL_PATHS
in CMAKE. This did not worked, gave same issue. - I have the set the flag
VTK_BUILD_PYI_FILES
to on in CMAKE and rebuild the solution file. However, this gave the error as “DLL files cannot be opened”.
Please let me know where did I go wrong or have I missed something.
PS: The wheel build is made for VTK 9.3 using python 3.9.13