Skip to content

Commit

Permalink
Find python path correctly (#2647)
Browse files Browse the repository at this point in the history
Fixed the failed CI of building udf applications on Mac.

The root cause is that the CMake find the path of python3.11, but python
3.11 droped the header `longintrepr.h`.
  • Loading branch information
siyuan0322 committed Apr 24, 2023
1 parent ac7d634 commit 2657bec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 4 additions & 4 deletions coordinator/gscoordinator/template/CMakeLists.template
Expand Up @@ -160,8 +160,8 @@ find_package(Threads REQUIRED)

# find Python-------------------------------------------------------------------
if (${CYTHON_PREGEL_APP} OR ${CYTHON_PIE_APP})
find_package (Python COMPONENTS Interpreter Development REQUIRED)
include_directories(SYSTEM ${Python_INCLUDE_DIRS})
find_package (Python3 COMPONENTS Interpreter Development REQUIRED)
include_directories(SYSTEM ${Python3_INCLUDE_DIRS})
endif ()

# find MPI----------------------------------------------------------------------
Expand Down Expand Up @@ -301,7 +301,7 @@ if (CYTHON_PREGEL_APP)
_GRAPH_TYPE=${GRAPH_TYPE}
_GRAPH_HEADER=$_graph_header
_APP_HEADER=$_app_header)
target_link_libraries(${FRAME_NAME} ${Python_LIBRARIES})
target_link_libraries(${FRAME_NAME} ${Python3_LIBRARIES})
set_target_properties(${FRAME_NAME} PROPERTIES COMPILE_FLAGS "-fPIC")
elseif (CYTHON_PIE_APP)
file(GLOB_RECURSE FILES_NEED_COMPILE "*.cc")
Expand All @@ -314,7 +314,7 @@ elseif (CYTHON_PIE_APP)
_GRAPH_TYPE=${GRAPH_TYPE}
_GRAPH_HEADER=$_graph_header
_APP_HEADER=$_app_header)
target_link_libraries(${FRAME_NAME} ${Python_LIBRARIES})
target_link_libraries(${FRAME_NAME} ${Python3_LIBRARIES})
set_target_properties(${FRAME_NAME} PROPERTIES COMPILE_FLAGS "-fPIC")
elseif (JAVA_PIE_APP)
if (ENABLE_JAVA_SDK)
Expand Down
10 changes: 9 additions & 1 deletion coordinator/gscoordinator/utils.py
Expand Up @@ -452,6 +452,7 @@ def compile_app(
f"-DNETWORKX={engine_config['networkx']}",
f"-DCMAKE_PREFIX_PATH='{GRAPHSCOPE_HOME};{OPAL_PREFIX}'",
]

if types_pb2.CMAKE_EXTRA_OPTIONS in attr:
extra_options = (
attr[types_pb2.CMAKE_EXTRA_OPTIONS]
Expand Down Expand Up @@ -502,7 +503,7 @@ def compile_app(
)
elif app_type == "cpp_flash":
cmake_commands += ["-DFLASH_APP=ON"]
elif app_type not in ("cpp_pie", "cpp_pregel"):
elif app_type not in ("cpp_pie", "cpp_pregel"): # Cython
if app_type == "cython_pregel":
pxd_name = "pregel"
cmake_commands += ["-DCYTHON_PREGEL_APP=ON"]
Expand All @@ -511,6 +512,13 @@ def compile_app(
else:
pxd_name = "pie"
cmake_commands += ["-DCYTHON_PIE_APP=ON"]
if "Python_ROOT_DIR" in os.environ:
python3_path = os.path.join(os.environ["Python_ROOT_DIR"], "bin", "python3")
elif "CONDA_PREFIX" in os.environ:
python3_path = os.path.join(os.environ["CONDA_PREFIX"], "bin", "python3")
else:
python3_path = shutil.which("python3")
cmake_commands.append(f"-DPython3_EXECUTABLE={python3_path}")

# Copy pxd file and generate cc file from pyx
shutil.copyfile(
Expand Down

0 comments on commit 2657bec

Please sign in to comment.