Skip to content

Commit

Permalink
refactor: sync viennaps changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed Mar 18, 2024
1 parent a5d3a63 commit 34046bf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
18 changes: 16 additions & 2 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ add_custom_target(${PROJECT_NAME} ALL)

set(CMAKE_MACOSX_RPATH ON)

list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN")
list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN/../vtkmodules")
if(NOT APPLE)
list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN")
list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN/../vtkmodules")
list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN/../viennals.libs")
else()
list(APPEND CMAKE_INSTALL_RPATH "@loader_path")
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../vtkmodules")
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../viennals.libs")
endif()

# --------------------------------------------------------------------------------------------------------
# Setup Dependencies
Expand Down Expand Up @@ -64,3 +71,10 @@ endmacro()

setup_binding(viennals2d -DVIENNALS_PYTHON_DIMENSION=2)
setup_binding(viennals3d -DVIENNALS_PYTHON_DIMENSION=3)

set(VIENNALS_LIB_FOLDER "${VIENNALS_LIBRARY_OUTPUT_DIR}/viennals.libs")

if(WIN32 AND NOT VIENNALS_SYSTEM_VTK)
setup_vtk_env(${MODULE_NAME} "${VIENNALS_LIB_FOLDER}")
install(DIRECTORY "${VIENNALS_LIB_FOLDER}" DESTINATION .)
endif()
15 changes: 13 additions & 2 deletions python/__init__.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,25 @@ visualisation applications, although this is not the main design target.
"""

import sys
from .@MODULE_NAME@ import *

def _windows_dll_path():

import os
import vtk

os.add_dll_directory(vtk.__path__)
vtk_path = vtk.__path__[0]

additional_paths = [
vtk_path,
os.path.join(os.path.dirname(vtk_path), 'vtk.libs'),
os.path.join(os.path.dirname(os.path.dirname(__file__)), 'viennals.libs')
]

for path in additional_paths:
os.add_dll_directory(path)
os.environ["PATH"] = path + os.pathsep + os.environ["PATH"]

if sys.platform == "win32":
_windows_dll_path()

from .@MODULE_NAME@ import *

0 comments on commit 34046bf

Please sign in to comment.