Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pyarrow linking process #132

Merged
merged 4 commits into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()

Expand Down
13 changes: 0 additions & 13 deletions ci-utils/find_pyarrow.py

This file was deleted.

22 changes: 15 additions & 7 deletions src/nyx/python/nyxus/nyxus.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down