# -*- mode: cmake -*-

if (PYTHON)

  find_package(PythonInterp)
  if (PYTHONINTERP_FOUND)
    # seek the same version of python
    set(PYTHONINTERP_VERSION_STRING ${PYTHON_VERSION_STRING})
    set(Python_ADDITIONAL_VERSIONS ${PYTHONINTERP_VERSION_STRING})
    find_package(PythonLibs)
    
    # if versions of libraries and interpreter match, show can go on
    if (PYTHONLIBS_VERSION_STRING STREQUAL PYTHONINTERP_VERSION_STRING)
    
      set(HAVE_PYTHON TRUE)
      message(STATUS "Found Python:")
      message(STATUS "\tPython interpreter: ${PYTHON_EXECUTABLE} (version ${PYTHON_VERSION_STRING})")
      
      include(find_python_module)
      ####
      find_python_module(numpy REQUIRED)
      if (PY_NUMPY)
        set (HAVE_PYTHON_NUMPY TRUE)
        message(STATUS "\tHave numpy package at ${PY_NUMPY}")
      endif(PY_NUMPY)
      ####
      find_python_module(ase)
      if (PY_ASE)
        message(STATUS "\tHave ase package at ${PY_ASE}")
      else()
        message(STATUS "\tDid not find ase package; download from wiki.fysik.dtu.dk/ase if you want to use pympqc.ase_mpqc")
      endif(PY_ASE)
    else()
      message(WARNING 
        "** Could not find matching PYTHON interpreter and libraries
** Python interpreter version ${PYTHONINTERP_VERSION_STRING} was found, but Python libraries version ${PYTHONLIBS_VERSION_STRING} was found
** Make sure to set CMAKE variable PYTHON_EXECUTABLE to the \"correct\" interpreter
** You may also need to make the \"correct\" PYTHON interpreter appear first in PATH"
      )
      if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
        message(WARNING "** N.B. With MacPorts you may need to \"port select\", e.g.: port select python python27-apple")
      endif()
    endif()
  endif(PYTHONINTERP_FOUND)
  
endif()
