From owner-freebsd-python@FreeBSD.ORG  Sun May 20 08:41:39 2012
Return-Path: <owner-freebsd-python@FreeBSD.ORG>
Delivered-To: python@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id A15681065674;
	Sun, 20 May 2012 08:41:39 +0000 (UTC)
	(envelope-from mail@sysfault.org)
Received: from smtprelay04.ispgateway.de (smtprelay04.ispgateway.de
	[80.67.31.38]) by mx1.freebsd.org (Postfix) with ESMTP id 328B78FC0C;
	Sun, 20 May 2012 08:41:39 +0000 (UTC)
Received: from [89.182.42.104] (helo=medusa.sysfault.org)
	by smtprelay04.ispgateway.de with esmtpsa (TLSv1:AES256-SHA:256)
	(Exim 4.68) (envelope-from <mail@sysfault.org>)
	id 1SW1hj-0004hE-RA; Sun, 20 May 2012 10:41:32 +0200
Received: from [127.0.0.1] (helo=medusa.sysfault.org)
	by medusa.sysfault.org with esmtp (Exim 4.77 (FreeBSD))
	(envelope-from <mail@sysfault.org>)
	id 1SW1jJ-0009Uf-VK; Sun, 20 May 2012 10:43:10 +0200
Received: (from marcus@localhost)
	by medusa.sysfault.org (8.14.5/8.14.5/Submit) id q4K8h9Xb036496;
	Sun, 20 May 2012 10:43:09 +0200 (CEST) (envelope-from marcus)
Date: Sun, 20 May 2012 10:43:09 +0200 (CEST)
Message-Id: <201205200843.q4K8h9Xb036496@medusa.sysfault.org>
To: FreeBSD-gnats-submit@freebsd.org
From: Marcus von Appen <mva@freebsd.org>
X-send-pr-version: 3.113
X-GNATS-Notify: 
X-Df-Sender: OTM2OTM0
Cc: kde@freebsd.org, python@freebsd.org
Subject: cmake python detection gets confused if multiple python versions
	are installed
X-BeenThere: freebsd-python@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
Reply-To: Marcus von Appen <mva@freebsd.org>
List-Id: FreeBSD-specific Python issues <freebsd-python.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-python>, 
	<mailto:freebsd-python-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-python>
List-Post: <mailto:freebsd-python@freebsd.org>
List-Help: <mailto:freebsd-python-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-python>,
	<mailto:freebsd-python-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sun, 20 May 2012 08:41:39 -0000


>Submitter-Id:	current-users
>Originator:	Marcus von Appen
>Organization:	
>Confidential:	no 
>Synopsis:	cmake python detection gets confused if multiple python versions are installed
>Severity:	non-critical
>Priority:	medium
>Category:	ports
>Class:		sw-bug
>Release:	FreeBSD 9.0-STABLE amd64
>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)