How can I specify the location of Python.h during the make?

Asked by Jonathan Harker

I am having trouble making the SWIG component of Dolfin. After running cmake with the following commands:

export PYTHONPATH=/share/apps/lib/python2.6/site-packages/:/share/apps/lib64/python2.6/site-packages/:$PYTHONPATH

cmake -DCMAKE_PREFIX_PATH=/share/apps -DCMAKE_INSTALL_PREFIX=/share/apps -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python26 -DPYTHON_INCLUDE_PATH:PATH='/usr/include/python2.6/:/share/apps/' -DPYTHON_LIBRARY:FILEPATH=/usr/lib64/libpython2.6.so.1.0 -DUFC_DIR=/share/apps/ -DBLAS_LIBRARIES='-L/share/apps/lib -lamd -lcblas -lf77blas -lptcblas -lptf77blas -latlas' -DLAPACK_LIBRARIES='-L /share/apps/lib -llapack' -DARMADILLO_DIR=/share/apps -DUMFPACK_DIR=/share/apps/ -DSWIG_DIR=/share/apps/ -DSWIG_INCLUDE_PATH='/usr/include/python2.6/' .

I get the following configuration:

-- The following optional packages were found:
-- -------------------------------------------
-- (OK) OPENMP
-- (OK) MPI
-- (OK) UMFPACK
-- (OK) ZLIB
-- (OK) PYTHON
--
-- The following optional packages could not be found:
-- ---------------------------------------------------
-- (**) PETSC
-- (**) SLEPC
-- (**) TRILINOS
-- (**) MTL4
-- (**) CHOLMOD
-- (**) SCOTCH
-- (**) PARMETIS
-- (**) CGAL
-- (**) SPHINX

But then `make` fails with the following error:

[100%] Built target dolfin
[100%] Swig source
Scanning dependencies of target _cpp
[100%] Building CXX object dolfin/swig/CMakeFiles/_cpp.dir/dolfinPYTHON_wrap.cxx.o
/home/kjharke/rpmbuild/BUILD/dolfin-1.0.0/dolfin/swig/dolfinPYTHON_wrap.cxx:151:20: error: Python.h: No such file or directory
/home/kjharke/rpmbuild/BUILD/dolfin-1.0.0/dolfin/swig/dolfinPYTHON_wrap.cxx:3832:4: error: #error "This python version requires swig to be run with the '-classic' option"

The errors go on for another 30 lines or so.
Python.h is located at /usr/include/python2.6/Python.h, how do I tell that to make?

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Johannes Ring
Solved:
Last query:
Last reply:
Revision history for this message
Johan Hake (johan-hake) said :
#1

What platform are you using?

It looks like you are miss the Python.h file, which some Linux
distributions ship in a:

   python-dev

package.

Johan

On 03/28/2012 02:55 AM, Jonathan Harker wrote:
> New question #191886 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/191886
>
> I am having trouble making the SWIG component of Dolfin. After running cmake with the following commands:
>
> export PYTHONPATH=/share/apps/lib/python2.6/site-packages/:/share/apps/lib64/python2.6/site-packages/:$PYTHONPATH
>
> cmake -DCMAKE_PREFIX_PATH=/share/apps -DCMAKE_INSTALL_PREFIX=/share/apps -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python26 -DPYTHON_INCLUDE_PATH:PATH='/usr/include/python2.6/:/share/apps/' -DPYTHON_LIBRARY:FILEPATH=/usr/lib64/libpython2.6.so.1.0 -DUFC_DIR=/share/apps/ -DBLAS_LIBRARIES='-L/share/apps/lib -lamd -lcblas -lf77blas -lptcblas -lptf77blas -latlas' -DLAPACK_LIBRARIES='-L /share/apps/lib -llapack' -DARMADILLO_DIR=/share/apps -DUMFPACK_DIR=/share/apps/ -DSWIG_DIR=/share/apps/ -DSWIG_INCLUDE_PATH='/usr/include/python2.6/' .
>
> I get the following configuration:
>
> -- The following optional packages were found:
> -- -------------------------------------------
> -- (OK) OPENMP
> -- (OK) MPI
> -- (OK) UMFPACK
> -- (OK) ZLIB
> -- (OK) PYTHON

Revision history for this message
Johannes Ring (johannr) said :
#2

I see you have Python.h in /usr/include/python2.6/. Could you print out the PYTHON_INCLUDE_DIRS variable by adding the following line after find_package(PythonLibs) in the main CMakeLists.txt file?

  message(STATUS "PYTHON_INCLUDE_DIRS: ${PYTHON_INCLUDE_DIRS}")

Revision history for this message
Jonathan Harker (jesusaurus) said :
#3

-- PYTHON_INCLUDE_DIRS: /usr/include/python2.6/:/share/apps

Just as I have set with the cmake argument -DPYTHON_INCLUDE_PATH:PATH='/usr/include/python2.6/:/share/apps/'

Revision history for this message
Best Johannes Ring (johannr) said :
#4

PYTHON_INCLUDE_DIR (PYTHON_INCLUDE_PATH is deprecated) should point to the directory where Python.h is located. Why do you have ':/share/apps/' there? Try removing that part and only do

  -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python2.6

Revision history for this message
Jonathan Harker (jesusaurus) said :
#5

I thought that PYTHON_INCLUDE_PATH was for more than just finding Python.h, that the directories would be recursively searched for needed python modules. Changing the deprecated PATH to DIR has fixed my problem. Thank you.

Revision history for this message
Jonathan Harker (jesusaurus) said :
#6

Thanks Johannes Ring, that solved my question.