diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d604b9d..5ab35ee0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ if(CUDA_FOUND AND USEGPU) set(CUDA_ARCH_LIST "35;37;50;72;75;80;86") endif() elseif (CUDA_VERSION_MAJOR STREQUAL "12") - set(CUDA_ARCH_LIST "52;60;72;75;80;86;89;90") + set(CUDA_ARCH_LIST "52;60;75;80;86;89;90") else() # some old CUDA version (<10) set(CUDA_ARCH_LIST "50") endif() @@ -317,49 +317,37 @@ if(USEARROW) if (BUILD_LIB) # Find Python find_package(Python REQUIRED COMPONENTS Interpreter) - # Execute the Python script to find pyarrow include path execute_process( COMMAND ${Python_EXECUTABLE} -c "import pyarrow as pa; print(pa.get_include())" OUTPUT_VARIABLE PATH_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE ) - # Store the path in a CMake variable set(PYARROW_INCLUDE_PATH "${PATH_OUTPUT}" CACHE INTERNAL "Path to pyarrow include directory") - - # Set filename for finding pyarrow - set(python_filename "ci-utils/find_pyarrow.py") - set(python_filepath "${CMAKE_CURRENT_SOURCE_DIR}/${python_filename}") - # Execute the Python script to find pyarrow library path execute_process( - COMMAND ${Python_EXECUTABLE} ${python_filepath} + COMMAND ${Python_EXECUTABLE} -c "import pyarrow as pa; print(pa.get_library_dirs()[0])" OUTPUT_VARIABLE LIB_PATH_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE ) - # Store the path in a CMake variable set(PYARROW_LIB_PATH "${LIB_PATH_OUTPUT}" CACHE INTERNAL "Path to pyarrow library directory") - if (PYARROW_INCLUDE_PATH STREQUAL "") message(FATAL_ERROR "Pyarrow library not found.") endif() - if (PYARROW_LIB_PATH STREQUAL "") message(FATAL_ERROR "Pyarrow library not found.") endif() - # Print the path message(STATUS "PyArrow Include Path: ${PYARROW_INCLUDE_PATH}") - message(STATUS "PyArrow Include Path: ${PYARROW_LIB_PATH}") + message(STATUS "PyArrow Library Path: ${PYARROW_LIB_PATH}") # add pyarrow include path include_directories(${PYARROW_INCLUDE_PATH}) - - target_link_libraries(backend PRIVATE ${PYARROW_LIB_PATH} ) - - target_link_libraries(backend PRIVATE ${Python_INCLUDE_DIRS}) + #add pyarrow library + list(APPEND Nyxus_LIBRARIES arrow_python) + target_link_directories(backend PRIVATE ${PYARROW_LIB_PATH}) endif() diff --git a/ci-utils/find_pyarrow.py b/ci-utils/find_pyarrow.py deleted file mode 100644 index 362e9067..00000000 --- a/ci-utils/find_pyarrow.py +++ /dev/null @@ -1,13 +0,0 @@ -import pyarrow as pa -import platform -path=pa.get_library_dirs()[0] -operating_system = platform.system() - -if operating_system == 'Linux': - path += '/libarrow_python.so' -elif operating_system == 'Darwin': - path += '/libarrow_python.dylib' -elif operating_system == 'Windows': - path += '\\arrow_python.lib' - -print(path) \ No newline at end of file diff --git a/src/nyx/python/nyxus/nyxus.py b/src/nyx/python/nyxus/nyxus.py index ff26e631..99773386 100644 --- a/src/nyx/python/nyxus/nyxus.py +++ b/src/nyx/python/nyxus/nyxus.py @@ -1,3 +1,18 @@ +import os +import sys +import numpy as np +import pandas as pd +from typing import Optional, List + +import pyarrow as pa +if os.sys.platform == "win32": + for lib_dir in pa.get_library_dirs(): + if sys.version_info[0]==3 and sys.version_info[1]>=8: + # since add_dll_dir is added in Python3.8 + os.add_dll_directory(lib_dir) + else: + os.environ['PATH'] = lib_dir + os.pathsep + os.environ['PATH'] + from .backend import ( initialize_environment, featurize_directory_imp, @@ -21,13 +36,6 @@ arrow_is_enabled_imp, ) -import os -import numpy as np -import pandas as pd -import pyarrow as pa -from typing import Optional, List - -#pa.import_pyarrow() class Nyxus: """Nyxus image feature extraction library diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8fa31636..9e2623bf 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -26,7 +26,7 @@ if(CUDA_FOUND AND USEGPU) set(CUDA_ARCH_LIST "35;37;50;72;75;80;86") endif() elseif (CUDA_VERSION_MAJOR STREQUAL "12") - set(CUDA_ARCH_LIST "52;60;72;75;80;86;89;90") + set(CUDA_ARCH_LIST "52;60;75;80;86;89;90") else() # some old CUDA version (<10) set(CUDA_ARCH_LIST "50") endif()