Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 May 2012 10:43:09 +0200 (CEST)
From:      Marcus von Appen <mva@FreeBSD.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        kde@FreeBSD.org, python@FreeBSD.org
Subject:   ports/168159: cmake python detection gets confused if multiple python versions are installed
Message-ID:  <201205200843.q4K8h9Xb036496@medusa.sysfault.org>
Resent-Message-ID: <201205200850.q4K8o1ad029025@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         168159
>Category:       ports
>Synopsis:       cmake python detection gets confused if multiple python versions are installed
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 20 08:50:01 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Marcus von Appen
>Release:        FreeBSD 9.0-STABLE amd64
>Organization:
>Environment:
System: FreeBSD medusa.sysfault.org 9.0-STABLE FreeBSD 9.0-STABLE #0: Mon May 14 15:08:44 CEST 2012 root@medusa.sysfault.org:/usr/obj/usr/src/sys/MEDUSA amd64


	
>Description:
        If multiple Python versions are installed, cmake's
        find_host_package(PythonInterp) and
        find_host_package(PythonLibs) statements may return different
        Python versions, causing cmake to try to detect and link
        against the wrong Python default version

>How-To-Repeat:

        Install lang/python27, lang/python31, lang/python
        Try to configure and build graphics/py-opencv:

        [...]
root@medusa:/usr/ports/graphics/py-opencv # make configure
===>  License BSD accepted by the user
===>  Extracting for py27-opencv-2.3.1_3
=> SHA256 Checksum OK for OpenCV-2.3.1a.tar.bz2.
===>  Patching for py27-opencv-2.3.1_3
===>  Applying extra patch /usr/ports/graphics/py-opencv/../opencv/files/extra-patch-opencv-python
===>  Applying FreeBSD patches for py27-opencv-2.3.1_3
===>   py27-opencv-2.3.1_3 depends on file: /usr/local/lib/python2.7/site-packages/numpy/core/numeric.py - found
===>   py27-opencv-2.3.1_3 depends on file: /usr/local/bin/python2.7 - found
===>   py27-opencv-2.3.1_3 depends on executable: pkg-config - found
===>   py27-opencv-2.3.1_3 depends on file: /usr/local/bin/cmake - found
===>   py27-opencv-2.3.1_3 depends on shared library: opencv_legacy.2 - found
===>  Configuring for py27-opencv-2.3.1_3
[...]
-- Looking for pthread.h - found
-- Found PythonInterp: /usr/local/bin/python (found version "2.7.3")
-- Found PythonLibs: /usr/local/lib/libpython3.1.so (found version "3.1.5")
--     Use NumPy headers from: /usr/local/lib/python2.7/site-packages/numpy/core/include
--     Found Sphinx 1.1.2: /usr/local/bin/sphinx-build
-- Parsing 'cvconfig.h.cmake'


>Fix:
        I'm not entirely sure, if that should be fixed in the related
        cmake files

        /usr/local/share/cmake/Modules/FindPythonInterp.cmake
        /usr/local/share/cmake/Modules/FindPythonLibs.cmake

        by adjusting the search/find order or go into the relevant Mk
        files. Below is a patch for bsd.python.mk, which explicitly sets
        the Python version to be used in bsd.python.mk, based on the
        detected PYTHON_VER.

Index: Mk/bsd.python.mk
===================================================================
RCS file: /home/pcvs/ports/Mk/bsd.python.mk,v
retrieving revision 1.143
diff -u -r1.143 bsd.python.mk
--- Mk/bsd.python.mk	11 Apr 2012 12:52:16 -0000	1.143
+++ Mk/bsd.python.mk	20 May 2012 08:31:02 -0000
@@ -674,6 +674,11 @@

 .endif # defined(USE_TWISTED)

+.if defined(USE_CMAKE)
+CMAKE_ARGS+=	-DPythonLibs_FIND_VERSION:STRING="${PYTHON_VER}" \
+		-DPythonInterp_FIND_VERSIN:STRING="${PYTHON_VER}"
+.endif
+
 # XXX Hm, should I export some of the variables above to *_ENV?

 .endif		# !defined(_POSTMKINCLUDED) &&
 !defined(Python_Pre_Include)
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201205200843.q4K8h9Xb036496>