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 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) 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'
Responsible Changed From-To: freebsd-ports-bugs->freebsd-python That's a Python PR
mva 2012-06-19 17:18:13 UTC FreeBSD ports repository Modified files: Mk bsd.python.mk Log: - Force cmake to use PYTHON_VER as version to detect, so that it uses the same Python version for the interpreter and library linking, if multiple Python versions are installed. PR: ports/168159 On behalf of: python@ Revision Changes Path 1.148 +12 -1 ports/Mk/bsd.python.mk _______________________________________________ cvs-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/cvs-all To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
State Changed From-To: open->closed Committed. Thanks!
Created attachment 157311 [details] Enforce default Python provided by the ports tree While this bug was resolved with the update of CMake to 3.0.1 in r366996, the workaround was still useful: by default CMake picks up the highest available version of Python package, while we want to use the default version provided by the ports framework. The attached patch fixes build issues reported in https://bugs.freebsd.org/199685 and https://bugs.freebsd.org/200518.
Reopen and request maintainer approval.
Take for exp-run
Exp-run results: http://package18.nyi.freebsd.org/build.html?mastername=101amd64-default-D2704PR168169&build=2015-06-01_08h27m15s The 1 new failure is not related to this change, patch approved.
Just a minor change to be done: "Enforce the default version provided by the ports tree." should be "Enforce the version required by the port or the default."
And while here: should not be CMAKE_ARGS+= only be set, if USES contains cmake? Just to keep the set environment clean?
(In reply to Marcus von Appen from comment #9) > And while here: should not be CMAKE_ARGS+= only be set, if USES contains > cmake? Just to keep the set environment clean? Seems like overcomplication for me, besides two lines above the CONFIGURE_ENV is set unconditionally.
(In reply to Marcus von Appen from comment #8) > Just a minor change to be done: > "Enforce the default version provided by the ports tree." > should be > "Enforce the version required by the port or the default." Absolutely. Will you commit the patch or you want me to do it?
(In reply to Max Brazhnikov from comment #11) > (In reply to Marcus von Appen from comment #8) > > Just a minor change to be done: > > "Enforce the default version provided by the ports tree." > > should be > > "Enforce the version required by the port or the default." > > Absolutely. Will you commit the patch or you want me to do it? A change prior to the commit should be sufficient. No need for a separate patch in my opinion.
Created attachment 157371 [details] Enforce the version required by the port or the default
(In reply to Marcus von Appen from comment #12) > (In reply to Max Brazhnikov from comment #11) > > (In reply to Marcus von Appen from comment #8) > > > Just a minor change to be done: > > > "Enforce the default version provided by the ports tree." > > > should be > > > "Enforce the version required by the port or the default." > > > > Absolutely. Will you commit the patch or you want me to do it? > > A change prior to the commit should be sufficient. No need for a separate > patch in my opinion. Sorry for not being clear, I was talking about the final version of the patch.
A commit references this bug: Author: makc Date: Wed Jun 10 09:23:54 UTC 2015 New revision: 389024 URL: https://svnweb.freebsd.org/changeset/ports/389024 Log: Pass the default Python version (or the version required by port) for CMake based ports. By default CMake picks up the highest available version of Python package, therefore ports which use CMake may fail to build or link to different Python library than one could expect (e.g. bugs 199685, 200518). In essence this commit reverts r366996. PR: 168159 Exp-run by: antoine Approved by: mva Changes: head/Mk/Uses/python.mk