← Back to team overview

kicad-developers team mailing list archive

Re: CMake doesn't find the right PythonLibs on recent Ubuntus, workaround included

 

On 4/12/2013 8:28 AM, Adam Wolf wrote:
As part of setting up the build server, I've been taking a harder look
at the Ubuntu packages.

CMake isn't detecting the right Python libs on some systems, including
Ubuntu 12.10.  I'm not sure if the issue is in CMake, or Ubuntu, or
Python, or whatever else, but there's a simple enough workaround...

If you get something like this when you cmake for kicad:

-- Found PythonInterp: /usr/bin/python (found version "2.7.3")
-- Check for installed Python Interpreter -- found
-- Python module install path: /usr/lib/python2.7/dist-packages
-- Found PythonLibs: /usr/lib/python3.2/config/libpython3.2.so (found
version "2.7.3")

Your build will probably die when it reaches anything SWIGgy, due to
CMake detecting /usr/lib/python3.2/config/libpython3.2.so as matching
the version of your interpreter, which is 2.7.3.  You can point cmake
to the appropriate PythonLibs, like the following:

cmake ../ -DKICAD_TESTING_VERSION=ON -DKICAD_SCRIPTING=ON
-DKICAD_SCRIPTING_MODULES=ON -DKICAD_SCRIPTING_WXPYTHON=ON
-DCMAKE_BUILD_TYPE=DEBUG
-DPYTHON_LIBRARY=/usr/lib/python2.7/config/libpython2.7.so

This appears to fix it.  I can make builds and use the Python library.

This has been documented by some other folks, with a different
workaround as well.  If you add a minimum version number requirement,
like find_package(PythonLibs 2.6) it seems to work on Ubuntu as well.
With all the cmake balls we're juggling, it's probably safest to just
override it on the command line until it gets fixed upstream.

References:
http://public.kitware.com/Bug/view.php?id=13794
http://www.ruby-forum.com/topic/4151421

Adam Wolf
Wayne and Layne, LLC


Adam,

The CMake FindPythonInter used to do the correct thing. It looked for the default version of Python by first looking at the PYTHON_PATH environment variable then for /usr/bin/python which typically is just a sym-link to find the default version of Python. If either of these is pointing to python 3 on you build system then that is what the Python scripting will be built against unless you specify the python interpreter at build time. If you override this by specifying it on the command like you've shown above, then the KiCad python scripting will not be recognized in your system's default python version because it's being build against and installed in python 2.7 not python 3. I guess from our standpoint since wxWidgets does not build against python 3 so we need to set the python version to < 3 until wxWidgets can be built against Python 3. I'm not sure if FindPythonInterp is sophisticated enough to do this.

Wayne



Follow ups

References