Solved How to solve: /include/boost/python/detail/wrap_python.hpp: fatal error: 'pyconfig.h' file not found

Hello,

need some help here, did ton of googling and all the answers are too Linux specific and seems like its not helping on FreeBSD 13.1.

I do a cmake and keep getting the error below to build a project called "Caffe" with OpenCL patch:

Code:
/usr/local/include/boost/python/detail/wrap_python.hpp:57:11: fatal error: 'pyconfig.h' file not found
# include <pyconfig.h>

Here is all the python installed files, I have pyconfig.h installed:

I did softlinks on terminal:
ln -s /usr/local/include/python3.9/pyconfig.h pyconfig.h

I did export:
export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/usr/local/include/python3.9/"

Also explicitly telling cmake to use the python lib and include directory:
cmake \
-D OPENCL_LIBRARIES=/usr/local/lib/libOpenCL.so.1 \
-D CMAKE_BUILD_TYPE=Release \
-D CPU_ONLY=OFF \
-D USE_CUDA=OFF \
-D PYTHON_INCLUDE_DIR="/usr/local/include/python3.9/" \
-D PYTHON_LIBRARY="/usr/local/lib/libpython3.9.so" \
-D BUILD_python=OFF \
-D USE_OPENCL=ON \
-D BLAS=open ..


Here is what python environment shows of it's paths, I first enter line by line to terminal:
python3
from sysconfig import get_paths
from pprint import pprint
info = get_paths()
pprint(info)


Finally, outputs:

Python:
{'data': '/usr/local',
 'include': '/usr/local/include/python3.9',
 'platinclude': '/usr/local/include/python3.9',
 'platlib': '/usr/local/lib/python3.9/site-packages',
 'platstdlib': '/usr/local/lib/python3.9',
 'purelib': '/usr/local/lib/python3.9/site-packages',
 'scripts': '/usr/local/bin',
 'stdlib': '/usr/local/lib/python3.9'}

I have also tried adding some code to the cmakelist.txt file to help cmake find the pyconfig.h file:

C++:
if(UNIX OR APPLE OR USE_ARM_CROSS_COMPILE)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -std=c++11 -DCMAKE_BUILD -I /usr/local/include/ -L /usr/local/lib/")
  find_package(PythonLibs 3 REQUIRED)
  set(PYTHON_MAJOR $ENV{Python_VERSION_MAJOR})
  set(PYTHON_MINOR $ENV{Python_VERSION_MINOR})
  set(PYTHONLIBS_VERSION_STRING ${Python_VERSION})
  set(PYTHON_INCLUDE_DIR ${Python_INCLUDE_DIRS})
  set(PYTHON_LIBRARIES ${Python_LIBRARIES})
  message("Using Python: ${PYTHONLIBS_VERSION_STRING}")
  list(GET VERSION_LIST 0 PYTHON_MAJOR)
  list(GET VERSION_LIST 1 PYTHON_MINOR)
endif()


None of all the attempts above works.

Why is cmake so blind and not able to find the pyconfig.h?

Here is what pkg info python shows:

Code:
python-3.9_3,2

Name           : python
Version        : 3.9_3,2
Installed on   : Sat Sep 10 23:30:10 2022 EDT
Origin         : lang/python
Architecture   : FreeBSD:13:*
Prefix         : /usr/local
Categories     : python lang
Licenses       :
Maintainer     : python@FreeBSD.org
WWW            : https://www.python.org/
Comment        : "meta-port" for the default version of Python interpreter
Annotations    :
        repo_type      : binary
        repository     : FreeBSD
Flat size      : 38.0B


Thanks for any advice.
 
Actually it seems that I need to first clear the build directory and do the export command first then do a cmake:

export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/usr/local/include/python3.9/"

This seems to solve the issue...
 
Back
Top