Skip to content

Commit

Permalink
adopt work-around from pinocchio for finding numpy in x-compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed Aug 7, 2024
1 parent 5854eb1 commit 7923a66
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions recipe/build-pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,27 @@ if [[ "${target_platform}" == linux-* ]]; then
export CXXFLAGS="$CXXFLAGS -DSWIGWORDSIZE64"
fi

PYTHON_LIB="${PREFIX}/lib/libpython${PY_VER}${SHLIB_EXT}"
PYTHON_INC="$PREFIX/include/python${PY_VER}"
NUMPY_INC=$(python -c 'import numpy;print(numpy.get_include())')
export BUILD_NUMPY_INCLUDE_DIRS=$( $PYTHON -c "import numpy; print (numpy.get_include())")
export TARGET_NUMPY_INCLUDE_DIRS=$SP_DIR/numpy/core/include

echo $BUILD_NUMPY_INCLUDE_DIRS
echo $TARGET_NUMPY_INCLUDE_DIRS

export GENERATE_PYTHON_STUBS=1
if [[ $CONDA_BUILD_CROSS_COMPILATION == 1 ]]; then
echo "Copying files from $BUILD_NUMPY_INCLUDE_DIRS to $TARGET_NUMPY_INCLUDE_DIRS"
mkdir -p $TARGET_NUMPY_INCLUDE_DIRS
cp -r $BUILD_NUMPY_INCLUDE_DIRS/numpy $TARGET_NUMPY_INCLUDE_DIRS
fi

# Build vanilla version (no avx2), see build-lib.sh
cmake -G Ninja \
${CMAKE_ARGS} \
-Dfaiss_ROOT=_libfaiss_stage/ \
-DCMAKE_BUILD_TYPE=Release \
-DPython_INCLUDE_DIRS="${PYTHON_INC}" \
-DPython_LIBRARIES="${PYTHON_LIB}" \
-DPython_NumPy_INCLUDE_DIRS=${NUMPY_INC} \
-DPython_INCLUDE_DIRS="$PREFIX/include/python${PY_VER}" \
-DPython_LIBRARIES="${PREFIX}/lib/libpython${PY_VER}${SHLIB_EXT}" \
-DPython_NumPy_INCLUDE_DIRS=$TARGET_NUMPY_INCLUDE_DIR \
-B _build_python \
faiss/python
cmake --build _build_python --target swigfaiss -j $CPU_COUNT
Expand Down

0 comments on commit 7923a66

Please sign in to comment.