DIPlib / diplib

Quantitative Image Analysis in C++, MATLAB and Python
https://diplib.org
Apache License 2.0
228 stars 50 forks source link

cmake: PyDIP module not configured #44

Closed clnFind closed 5 years ago

clnFind commented 5 years ago

Component DIPimage / PyDIP / CMake build scripts. installed from sources

Describe the bug

➜  target cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=g++-8 ..

-- The C compiler identification is AppleClang 9.0.0.9000039
-- The CXX compiler identification is GNU 8.1.0
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/local/bin/g++-8
-- Check for working CXX compiler: /usr/local/bin/g++-8 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- PROJECT_VERSION = 3.0.alpha
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND) (found version "4.5")
-- Performing Test HAS_PRETTY_FUNCTION
-- Performing Test HAS_PRETTY_FUNCTION - Success
-- Performing Test HAS_128_INT
-- Performing Test HAS_128_INT - Success
~~~Configuring Zlib~~~
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - failed
-- Looking for fseeko
-- Looking for fseeko - found
-- Looking for unistd.h
-- Looking for unistd.h - found
~~~
~~~Configuring libics~~~
-- Looking for strtok_r
-- Looking for strtok_r - found
~~~Configuring LibTIFF~~~
-- Performing Test C_FLAG_Wall
-- Performing Test C_FLAG_Wall - Success
-- Performing Test C_FLAG_Winline
-- Performing Test C_FLAG_Winline - Success
-- Performing Test C_FLAG_W
-- Performing Test C_FLAG_W - Success
-- Performing Test C_FLAG_Wformat_security
-- Performing Test C_FLAG_Wformat_security - Success
-- Performing Test C_FLAG_Wpointer_arith
-- Performing Test C_FLAG_Wpointer_arith - Success
-- Performing Test C_FLAG_Wdisabled_optimization
-- Performing Test C_FLAG_Wdisabled_optimization - Success
-- Performing Test C_FLAG_Wno_unknown_pragmas
-- Performing Test C_FLAG_Wno_unknown_pragmas - Success
-- Performing Test C_FLAG_Wdeclaration_after_statement
-- Performing Test C_FLAG_Wdeclaration_after_statement - Success
-- Performing Test C_FLAG_Wno_unused_parameter
-- Performing Test C_FLAG_Wno_unused_parameter - Success
-- Performing Test C_FLAG_Wno_unused_but_set_variable
-- Performing Test C_FLAG_Wno_unused_but_set_variable - Failed
-- Performing Test C_FLAG_fstrict_aliasing
-- Performing Test C_FLAG_fstrict_aliasing - Success
-- Looking for assert.h
-- Looking for assert.h - found
-- Looking for dlfcn.h
-- Looking for dlfcn.h - found
-- Looking for fcntl.h
-- Looking for fcntl.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for io.h
-- Looking for io.h - not found
-- Looking for search.h
-- Looking for search.h - found
-- Looking for string.h
-- Looking for string.h - found
-- Looking for strings.h
-- Looking for strings.h - found
-- Looking for sys/time.h
-- Looking for sys/time.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Performing Test C_HAS_inline
-- Performing Test C_HAS_inline - Success
-- Performing Test TIME_WITH_SYS_TIME
-- Performing Test TIME_WITH_SYS_TIME - Success
-- Performing Test TM_IN_SYS_TIME
-- Performing Test TM_IN_SYS_TIME - Success
-- Check size of signed int
-- Check size of signed int - done
-- Check size of unsigned int
-- Check size of unsigned int - done
-- Check size of signed long
-- Check size of signed long - done
-- Check size of unsigned long
-- Check size of unsigned long - done
-- Check size of signed long long
-- Check size of signed long long - done
-- Check size of unsigned long long
-- Check size of unsigned long long - done
-- Check size of unsigned char *
-- Check size of unsigned char * - done
-- Check size of size_t
-- Check size of size_t - done
-- Check size of ptrdiff_t
-- Check size of ptrdiff_t - done
-- Looking for mmap
-- Looking for mmap - found
-- Looking for setmode
-- Looking for setmode - found
-- Looking for snprintf
-- Looking for snprintf - found
-- Looking for strcasecmp
-- Looking for strcasecmp - found
-- Looking for strtol
-- Looking for strtol - found
-- Looking for strtoll
-- Looking for strtoll - found
-- Looking for strtoul
-- Looking for strtoul - found
-- Looking for strtoull
-- Looking for strtoull - found
-- Looking for getopt
-- Looking for getopt - found
-- Looking for lfind
-- Looking for lfind - found
-- Check if the system is big endian
-- Searching 16 bit integer
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
-- LibTIFF uses win32 IO: FALSE
-- LibTIFF has JPEG 8/12 bit dual mode: FALSE
~~~
-- Could NOT find FFTW3 (missing: FFTW3_INCLUDE_DIR FFTW3_LIBRARY_FFTW3F FFTW3_LIBRARY_FFTW3F_THREADS FFTW3_LIBRARY_FFTW3 FFTW3_LIBRARY_FFTW3_THREADS)
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Found OpenGL: /System/Library/Frameworks/OpenGL.framework
-- Found GLFW: /usr/local/lib/libglfw.dylib
-- GLFW found: /usr/local/lib/libglfw.dylib -- /usr/local/include
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Found Java: /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java (found suitable version "1.8.0.131", minimum required is "1.8") found components:  Development
-- Found JNI: /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/libjawt.dylib
-- Found PythonInterp: /Users/cln/.pyenv/shims/python3.7 (found version "1.4")
-- Could NOT find Matlab (missing: Matlab_INCLUDE_DIRS Matlab_MEX_LIBRARY Matlab_MEX_EXTENSION Matlab_ROOT_DIR Matlab_MX_LIBRARY MAIN_PROGRAM) (found version "NOTFOUND")

--------------------------------------
   DIPlib CONFIGURATION REPORT

 * C++ compiler: GNU
 * C++ compiler flags:  -Wall -Wextra -Wconversion -Wsign-conversion -pedantic -Wno-unknown-pragmas -Wno-attributes -g -Og
 * Build type: Debug
 * Building shared library
 * Library installed to: /usr/local/lib
 * Header files installed to: /usr/local/include
 * Doxygen documentation not configured
 * Using OpenMP for multithreading
 * Stack trace recording enabled
 * Asserts disabled
 * Unicode support enabled
 * Using 128-bit PRNG
 * ICS file IO enabled, with zlib
 * TIFF file IO enabled, with zlib, with JPEG
 * JPEG file IO enabled
 * Using built-in FFT
 * Unit test code included
 * DIPviewer module added to 'all' with window managers: GLFW
 * DIPviewer Java bindings not configured
 * DIPjavaio module added to 'all' target with interfaces:
 * PyDIP module not configured
 * DIPimage toolbox not configured

Next, type 'make; make check; make install'

--------------------------------------

-- Configuring done
-- Generating done
-- Build files have been written to: /Users/cln/OCR/src/diplib/target

System information:

crisluengo commented 5 years ago

You have Python 3.7 installed in /Users/cln/.pyenv/shims/python3.7. How did you install it?

In the CMakeLists.txt file in the root of the repository, on line 146, it says

find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION})

Change this line to

find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} REQUIRED)

and run CMake again. You should now get an error message that might indicate what the problem with your Python installation is.

clnFind commented 5 years ago

@crisluengo Yes, I uninstalled Python 3.7, but I got this following error:

CMake Error at dependencies/pybind11/tools/FindPythonLibsNew.cmake:95 (message):
  Python config failure:
  pyenv: python3.6: command not found

  The `python3.6' command exists in these Python versions:
    3.6.0
crisluengo commented 5 years ago

I'm not sure what that error message means. It looks like it identifies Python3.6 as installed, but then cannot run it. I have not had problems in the past using the Python in a virtual environment for building this project.

Why did you uninstall 3.7? Which version of Python do you intend to use? You can add -DPYBIND11_PYTHON_VERSION=3.6 to your CMake command if you want to build explicitly against the 3.6 version of Python, but you need to have that version installed.

Do delete your CMakeCache.txt file if you are going to change the version of Python you build for, just in case CMake gets confused with old values.

clnFind commented 5 years ago

@crisluengo I mainly use Python 3.6, rarely 3.7, following your method, the following errors occurred:

CMake Error at /usr/local/Cellar/cmake/3.11.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find PythonInterp: Found unsuitable version "1.4", but required
  is at least "3.6" (found /Users/cln/.pyenv/shims/python3.6)
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.11.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:376 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/Cellar/cmake/3.11.1/share/cmake/Modules/FindPythonInterp.cmake:155 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  dependencies/pybind11/tools/FindPythonLibsNew.cmake:60 (find_package)
  CMakeLists.txt:147 (find_package)
-- Configuring incomplete, errors occurred!
crisluengo commented 5 years ago

Strange that it sees the wrong version string there. I do not understand this error. I think pyenv might be confusing the CMake scripts that try to find the Python executable and associated libraries.

One workaround could be to add the following defines to your CMake command:

-DPYTHON_EXECUTABLE=/usr/local/bin/python3.7
-DPYTHON_LIBRARY=/usr/local/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib
-DPYTHON_INCLUDE_DIR=/usr/local/Frameworks/Python.framework/Versions/3.7/include/python3.7m/

(I've put in valid directories for my installation, which I have through Homebrew. You'll have to find the relevant directories on your system.)


If you use an Anaconda installation of Python, this CMake script might help us, but let's see if the above solves it, because it'll be more effort to figure out how to use this other script.

clnFind commented 5 years ago

@crisluengo Thanks very much, it works. I use pyenv-virtualenv, no anaconda. I run the following command:

cmake -DCMAKE_BUILD_TYPE=Debug 
-DPYTHON_EXECUTABLE=/Users/cln/.pyenv/shims/python  
-DPYBIND11_PYTHON_VERSION=3.6 
-DPYTHON_INCLUDE_DIR=/Users/cln/.pyenv/versions/3.6.0/include/python3.6m 
-DPYTHON_LIBRARIES=/Users/cln/.pyenv/versions/3.6.0/lib/libpython3.6m.a  
-DCMAKE_CXX_COMPILER=g++-8 
-DBIOFORMATS_JAR=$HOME/java/bioformats_package.jar 
-DJAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home  ..

DIPlib CONFIGURATION REPORT

Next, type 'make; make check; make install'

crisluengo commented 5 years ago

@clnFind Thanks so much for reporting back!