File: pyinstaller.rst

package info (click to toggle)
python-pyvista 0.44.1-11
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 159,804 kB
  • sloc: python: 72,164; sh: 118; makefile: 68
file content (33 lines) | stat: -rw-r--r-- 1,208 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
.. _pyinstaller:

Freezing PyVista with PyInstaller
=================================
You can make some fantastic standalone programs with ``pyinstaller``
and ``pyvista``, and you can even make a graphical user interface
incorporating ``PyQt5`` or ``pyside2``.  Depending on your version of
VTK, this requires some extra steps to setup.

When running VTK v9, you need to add several additional
``hiddenimports``.  For clarity and completeness, create a spec file
(we'll name it ``pyvista.spec``) following the directions given at
`Using Spec Files <https://pyinstaller.readthedocs.io/en/stable/spec-files.html>`__.  Modify the ``Analysis`` and add the following hidden imports:

.. code:: python

    main_py = os.path.join(some_path, "main.py")
    a = Analysis(
        [main_py],
        pathex=[],
        binaries=[],
        hiddenimports=[
            "vtkmodules",
            "vtkmodules.all",
            "vtkmodules.qt.QVTKRenderWindowInteractor",
            "vtkmodules.util",
            "vtkmodules.util.numpy_support",
            "vtkmodules.numpy_interface.dataset_adapter",
        ],
    )

From there, you can freeze an application using ``pyvista`` and create
a standalone application.