Gentoo Archives: gentoo-user

From: "Gerrit Kühn" <gerrit.kuehn@×××××××.de>
To: gentoo-user@l.g.o
Subject: [gentoo-user] ebuild with cmake, swig and python
Date: Tue, 03 Sep 2019 06:10:32
Message-Id: 20190903081020.896ba9b09cdebd362f83648c@aei.mpg.de
Hi,

After searching the web without much success, maybe somebody in here can
direct me into the right direction:
I have a software that is providing swig bindings to (among other
languages) python, and I'd like to have an ebuild for that and get
binding for python2 and python3 at the same time. Building the thing works
fine for python2 and python3 on the commandline, but I cannot get my
ebuild to build for both python2 and python3 versions. It will build for
whatever is set as default python interpreter, but will not find the
libraries for the other one.

This is what the ebuild reports (with python3 being default):

-- +++ DEBUG +++ PYTHON_EXECUTABLE: /usr/bin/python
-- Found PythonInterp: /usr/bin/python (found version "3.6.9") 
-- Found PythonLibs: /usr/lib/libpython3.6m.so (found version "3.6.9") 
-- +++ DEBUG +++ PYTHON_EXECUTABLE: /usr/bin/python
-- +++ DEBUG +++ PYTHON_LIBRARIES: /usr/lib/libpython3.6m.so
-- +++ DEBUG +++ PYTHONLIBS_VERSION_STRING: 3.6.9
-- Found SWIG: /usr/bin/swig (found suitable version "3.0.12", minimum
required is "2.0.4") 
-- +++ DEBUG +++ ARG_INTERP: python2
-- +++ DEBUG +++ PYTHON_EXECUTABLE: /usr/bin/python2
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.15",
minimum required is "2") 
-- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES
PYTHON_INCLUDE_DIRS) (Required is at least version "2")
-- +++ DEBUG +++ PYTHON_EXECUTABLE: /usr/bin/python2
-- +++ DEBUG +++ PYTHON_LIBRARIES: PYTHON_LIBRARY-NOTFOUND
-- +++ DEBUG +++ PYTHONLIBS_VERSION_STRING: 
-- Checking for python 2.7.15 module: numpy ... yes
-- +++ DEBUG +++ ARG_PYTHON_EXECUTABLE: /usr/bin/python2


This is what I get on the commandline when building:

-- +++ DEBUG +++ PYTHON_EXECUTABLE: /usr/bin/python
-- Found PythonInterp: /usr/bin/python (found version "3.6.9") 
-- Found PythonLibs: /usr/lib/libpython3.6m.so (found version "3.6.9") 
-- +++ DEBUG +++ PYTHON_EXECUTABLE: /usr/bin/python
-- +++ DEBUG +++ PYTHON_LIBRARIES: /usr/lib/libpython3.6m.so
-- +++ DEBUG +++ PYTHONLIBS_VERSION_STRING: 3.6.9
-- Found SWIG: /usr/bin/swig (found suitable version "3.0.12", minimum
required is "2.0.4") 
-- +++ DEBUG +++ ARG_INTERP: /usr/bin/python2
-- +++ DEBUG +++ PYTHON_EXECUTABLE: /usr/bin/python2
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.15",
minimum required is "2") 
-- Found PythonLibs: /usr/lib/libpython2.7.so (found suitable version
"2.7.15", minimum required is "2") 
-- +++ DEBUG +++ PYTHON_EXECUTABLE: /usr/bin/python2
-- +++ DEBUG +++ PYTHON_LIBRARIES: /usr/lib/libpython2.7.so
-- +++ DEBUG +++ PYTHONLIBS_VERSION_STRING: 2.7.15
-- Checking for python 2.7.15 module: numpy ... yes
-- +++ DEBUG +++ ARG_PYTHON_EXECUTABLE: /usr/bin/python2


The ebuild itself is quite straight-forward (I think), just using
cmake-utils to pass on USE flags to options (ENABLE_SWIG_PYTHON2 and
ENABLE_SWIG_PYTHON3 in this case). This part works as far as I can see. Is
there anything else to consider? Somehow the ebuild environment appears to
be different from what I have on the commandline so that the second python
version isn't properly found.


cu
  Gerrit