Skip to content

Commit

Permalink
fix(python): dll path
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed Mar 11, 2024
1 parent 5ad1bbd commit 1029c70
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ if(WIN32 AND NOT VIENNALS_SYSTEM_VTK)
setup_vtk_env(${PROJECT_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()

if (NOT VIENNALS_SYSTEM_VTK)
message(STATUS "[ViennaLS] Setting VTK_DIR to previously created environment")
# We set `VTK_DIR` to the previously setup environment to ensure
# that the python script can find the library files
set(VTK_DIR "${PROJECT_BINARY_DIR}/vtk_env")
endif()

# --------------------------------------------------------------------------------------------------------
# Setup 2D-Bindings
# --------------------------------------------------------------------------------------------------------
Expand Down
15 changes: 14 additions & 1 deletion python/__init__.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,24 @@ extra_dll_dir = os.path.dirname(__file__)

if sys.platform == 'win32' and os.path.isdir(extra_dll_dir):
# Add the VTK dll directory
os.add_dll_directory(os.path.join(os.path.abspath("@VTK_DIR@".replace("/lib/cmake/vtk", "")), "bin"))

vtk_path = "@VTK_DIR@".replace("/lib/cmake/vtk", "")

if vtk_path:
os.add_dll_directory(os.path.abspath("@VTK_DIR@"))
else:
os.add_dll_directory(os.path.join(os.path.abspath("@VTK_DIR@".replace("/lib/cmake/vtk", "")), "bin"))

# Add the directory of the python bindings

os.add_dll_directory(extra_dll_dir)

# Remove internal symbols

del vtk_path

from .@MODULE_NAME@ import *

# Remove internal symbols

del extra_dll_dir

0 comments on commit 1029c70

Please sign in to comment.