The Autotools build system looks for the C header Python.h to determine the
include path for the local Python installation. However, on Ubuntu 18.04 it was
not finding it. The reason is that the libpython3-dev package on Ubuntu 18.04
installs Python 3.6 under a “python3.6m” prefix that it does not add to C/C++
include paths. This seems to be a deliberate choice in the structure of this
package for Ubuntu 18.04, to avoid conflicts with default Python 2.
A reasonable question to ask is then why Python 3 detection succeeds on the CI
Ubuntu 18.04 jobs. The answer is that libpython2-dev is installed. That is, the
Python 3 detection finds the Python.h from the libpython2-dev installation and
incorrectly assumes it has found the Python 3 header. This confusion may play a
role in #227 and #1042.
This coincidental alignment of headers is exposed when libpython2-dev is removed
and Python 3 detection starts failing. This commit pre-empts this failure in
upcoming changes that remove Python 2 support by explicitly making the Python 3
Python.h findable. Related to #1992.
tags:
- linux
image: "$CI_REGISTRY_IMAGE/ubuntu-18.04:$CI_COMMIT_SHA"
+ before_script:
+ # Make Python.h findable
+ - export C_INCLUDE_PATH="/usr/include/python3.6m"
+ - export CPLUS_INCLUDE_PATH="/usr/include/python3.6m"
script:
- ./autogen.sh
- ./configure --enable-man-pdfs
artifacts: false
- job: portable-source
artifacts: true
+ before_script:
+ # Make Python.h findable
+ - export C_INCLUDE_PATH="/usr/include/python3.6m"
+ - export CPLUS_INCLUDE_PATH="/usr/include/python3.6m"
tags:
- linux
variables: