hpdbscan icon indicating copy to clipboard operation
hpdbscan copied to clipboard

python integration problem

Open fbenedett opened this issue 10 months ago • 1 comments

Hello,

I am trying to install your code but I encounter the following problem:


mkdir build && cd build && cmake .. && make
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Checking for module 'mpi-c'
--   No package 'mpi-c' found
-- Could NOT find MPI_C (missing: MPI_C_LIB_NAMES MPI_C_HEADER_DIR MPI_C_WORKS) 
-- Checking for module 'mpi-cxx'
--   No package 'mpi-cxx' found
-- Could NOT find MPI_CXX (missing: MPI_CXX_LIB_NAMES MPI_CXX_HEADER_DIR MPI_CXX_WORKS) 
-- Could NOT find MPI (missing: MPI_C_FOUND MPI_CXX_FOUND) 
BUILDING WITHOUT MPI SUPPORT
-- Found OpenMP_C: -fopenmp (found suitable version "4.5", minimum required is "4.0") 
-- Found OpenMP_CXX: -fopenmp (found suitable version "4.5", minimum required is "4.0") 
-- Found OpenMP: TRUE (found suitable version "4.5", minimum required is "4.0")  
-- HDF5 C compiler wrapper is unable to compile a minimal HDF5 program.
-- Found HDF5: /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so (found suitable version "1.10.7", minimum required is "1.8.10")  
-- Found SWIG: /usr/bin/swig4.0 (found version "4.0.2")  
-- Found PythonInterp: /home/fbenedet/my_env/bin/python (found version "3.10.12") 
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.10.so (found version "3.10.12") 
CMake Warning (dev) at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (NUMPY) does
  not match the name of the calling package (NumPy).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/FindNumPy.cmake:28 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:61 (FIND_PACKAGE)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found NUMPY: /home/fbenedet/my_env/lib/python3.10/site-packages/numpy/core/include  
-- Configuring done
-- Generating done
-- Build files have been written to: /media/fbenedet/My Passport/dbscan/hpdbscan-master/build
[ 16%] Building CXX object CMakeFiles/hpdbscan.dir/src/hpdbscan.cpp.o
[ 33%] Linking CXX shared library libhpdbscan.so
[ 33%] Built target hpdbscan
[ 50%] Building CXX object CMakeFiles/hpdbscan-bin.dir/src/cli.cpp.o
[ 66%] Linking CXX executable hpdbscan
[ 66%] Built target hpdbscan-bin
[ 83%] Building CXX object CMakeFiles/hpdbscan-binding.dir/hpdbscan_wrap.cpp.o
/media/fbenedet/My Passport/dbscan/hpdbscan-master/build/hpdbscan_wrap.cpp:3344:10: fatal error: numpy/arrayobject.h: No such file or directory
 3344 | #include <numpy/arrayobject.h>
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/hpdbscan-binding.dir/build.make:76: CMakeFiles/hpdbscan-binding.dir/hpdbscan_wrap.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:139: CMakeFiles/hpdbscan-binding.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

I think it is related to the line 61 of CMakeLists.txt: FIND_PACKAGE(NumPy) I do not understand why it is not working. I have, on my system, numpy in my virtual environment and I do find the arrayobject.h, but the make process cannot find it.

fbenedett avatar Apr 12 '24 12:04 fbenedett

Hi @fbenedett ,

I am having a difficult time reproducing the issue as it seems to work in my setup. However, what you could try is explicitly including the numpy headers. For this try the following:

  1. Open the CMakeLists.txt in the main directory
  2. Add a new line after line 60, i.e. INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
  3. Add INCLUDE_DIRECTORIES(${NUMPY_INCLUDE_DIRS})
  4. Clear the CMake cache and build everything from scratch

Please let me know if this works. If not, do not hesitate to get in touch again

Markus-Goetz avatar Apr 14 '24 11:04 Markus-Goetz

Closing this due to inactivity

Markus-Goetz avatar May 22 '24 20:05 Markus-Goetz