summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2013-04-07 17:02:52 +0000
committerMichał Górny <mgorny@gentoo.org>2013-04-07 17:02:52 +0000
commit37341bff446f8754b125cb0a8dd640d660aed4a8 (patch)
tree5dbccae4832627d6da3fcebaec6bd70e2b9cce81 /eclass
parentMove header wrapping to multilib-build. Use the new code in autotools-multili... (diff)
downloadgentoo-2-37341bff446f8754b125cb0a8dd640d660aed4a8.tar.gz
gentoo-2-37341bff446f8754b125cb0a8dd640d660aed4a8.tar.bz2
gentoo-2-37341bff446f8754b125cb0a8dd640d660aed4a8.zip
Create temporary symlinks for executables and pkg-config files, and add them to $PATH and $PKG_CONFIG_PATH respectively. This makes it easier for broken build systems to find Python, and gives us the possibility of dropping python-wrapper.
Diffstat (limited to 'eclass')
-rw-r--r--eclass/ChangeLog9
-rw-r--r--eclass/python-any-r1.eclass7
-rw-r--r--eclass/python-r1.eclass5
-rw-r--r--eclass/python-single-r1.eclass3
-rw-r--r--eclass/python-utils-r1.eclass96
5 files changed, 114 insertions, 6 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog
index f63e1f75e08e..97f16113211d 100644
--- a/eclass/ChangeLog
+++ b/eclass/ChangeLog
@@ -1,6 +1,13 @@
# ChangeLog for eclass directory
# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.769 2013/04/07 16:56:14 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.770 2013/04/07 17:02:52 mgorny Exp $
+
+ 07 Apr 2013; Michał Górny <mgorny@gentoo.org> python-any-r1.eclass,
+ python-r1.eclass, python-single-r1.eclass, python-utils-r1.eclass:
+ Create temporary symlinks for executables and pkg-config files, and add them
+ to $PATH and $PKG_CONFIG_PATH respectively. This makes it easier for broken
+ build systems to find Python, and gives us the possibility of dropping
+ python-wrapper.
07 Apr 2013; Michał Górny <mgorny@gentoo.org> autotools-multilib.eclass,
multilib-build.eclass, multilib-minimal.eclass:
diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass
index 5d9a3d1e5955..dc3443b75f00 100644
--- a/eclass/python-any-r1.eclass
+++ b/eclass/python-any-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python-any-r1.eclass,v 1.6 2013/01/21 19:28:16 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-any-r1.eclass,v 1.7 2013/04/07 17:02:52 mgorny Exp $
# @ECLASS: python-any-r1
# @MAINTAINER:
@@ -205,7 +205,10 @@ python-any-r1_pkg_setup() {
local PYTHON_PKG_DEP
for i in "${rev_impls[@]}"; do
python_export "${i}" PYTHON_PKG_DEP EPYTHON PYTHON
- ROOT=/ has_version "${PYTHON_PKG_DEP}" && return
+ if ROOT=/ has_version "${PYTHON_PKG_DEP}"; then
+ python_wrapper_setup "${T}"
+ return
+ fi
done
}
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 0b96775373fb..d1cc4206d6af 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.52 2013/03/30 12:56:24 floppym Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.53 2013/04/07 17:02:52 mgorny Exp $
# @ECLASS: python-r1
# @MAINTAINER:
@@ -637,7 +637,9 @@ _python_multibuild_wrapper() {
debug-print-function ${FUNCNAME} "${@}"
local -x EPYTHON PYTHON
+ local -x PATH=${PATH} PKG_CONFIG_PATH=${PKG_CONFIG_PATH}
python_export "${MULTIBUILD_VARIANT}" EPYTHON PYTHON
+ python_wrapper_setup "${T}/${EPYTHON}"
"${@}"
}
@@ -710,6 +712,7 @@ python_export_best() {
debug-print "${FUNCNAME}: Best implementation is: ${best}"
python_export "${best}" "${@}"
+ python_wrapper_setup "${T}"
}
# @FUNCTION: python_replicate_script
diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass
index 6235b66e2cff..97d4a2102651 100644
--- a/eclass/python-single-r1.eclass
+++ b/eclass/python-single-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python-single-r1.eclass,v 1.15 2013/01/30 10:42:25 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-single-r1.eclass,v 1.16 2013/04/07 17:02:52 mgorny Exp $
# @ECLASS: python-single-r1
# @MAINTAINER:
@@ -207,6 +207,7 @@ python-single-r1_pkg_setup() {
fi
python_export "${impl}" EPYTHON PYTHON
+ python_wrapper_setup "${T}"
fi
done
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index a3755461625b..d9db4cf97126 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v 1.20 2013/03/28 12:21:46 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v 1.21 2013/04/07 17:02:52 mgorny Exp $
# @ECLASS: python-utils-r1
# @MAINTAINER:
@@ -818,5 +818,99 @@ python_doheader() {
doins -r "${@}" || die
}
+# @FUNCTION: python_wrapper_setup
+# @USAGE: <path> [<impl>]
+# @DESCRIPTION:
+# Create proper 'python' executable and pkg-config wrappers
+# (if available) in the directory named by <path>. Set up PATH
+# and PKG_CONFIG_PATH appropriately.
+#
+# The wrappers will be created for implementation named by <impl>,
+# or for one named by ${EPYTHON} if no <impl> passed.
+#
+# If the named directory contains a python symlink already, it will
+# be assumed to contain proper wrappers already and only environment
+# setup will be done. If wrapper update is requested, the directory
+# shall be removed first.
+python_wrapper_setup() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local workdir=${1}
+ local impl=${2:-${EPYTHON}}
+
+ [[ ${workdir} ]] || die "${FUNCNAME}: no workdir specified."
+ [[ ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON specified."
+
+ if [[ ! -x ${workdir}/bin/python ]]; then
+ mkdir -p "${workdir}"/{bin,pkgconfig} || die
+
+ # Clean up, in case we were supposed to do a cheap update.
+ rm -f "${workdir}"/bin/python{,2,3,-config}
+ rm -f "${workdir}"/bin/2to3
+ rm -f "${workdir}"/pkgconfig/python{,2,3}.pc
+
+ local EPYTHON PYTHON
+ python_export "${impl}" EPYTHON PYTHON
+
+ local pyver
+ if [[ ${EPYTHON} == python3* ]]; then
+ pyver=3
+ else # includes pypy & jython
+ pyver=2
+ fi
+
+ # Python interpreter
+ ln -s "${PYTHON}" "${workdir}"/bin/python || die
+ ln -s python "${workdir}"/bin/python${pyver} || die
+
+ local nonsupp=()
+
+ # CPython-specific
+ if [[ ${EPYTHON} == python* ]]; then
+ ln -s "${PYTHON}-config" "${workdir}"/bin/python-config || die
+
+ # Python 2.6+.
+ if [[ ${EPYTHON} != python2.5 ]]; then
+ ln -s "${PYTHON/python/2to3-}" "${workdir}"/bin/2to3 || die
+ else
+ nonsupp+=( 2to3 )
+ fi
+
+ # Python 2.7+.
+ if [[ ${EPYTHON} != python2.[56] ]]; then
+ ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${EPYTHON/n/n-}.pc \
+ "${workdir}"/pkgconfig/python.pc || die
+ else
+ # XXX?
+ ln -s /dev/null "${workdir}"/pkgconfig/python.pc || die
+ fi
+ ln -s python.pc "${workdir}"/pkgconfig/python${pyver}.pc || die
+ else
+ nonsupp+=( 2to3 python-config )
+ fi
+
+ local x
+ for x in "${nonsupp[@]}"; do
+ echo >"${workdir}"/bin/${x} <<__EOF__ || die
+#!/bin/sh
+echo "${x} is not supported by ${EPYTHON}" >&2
+exit 1
+__EOF__
+ chmod +x "${workdir}"/bin/${x} || die
+ done
+
+ # Now, set the environment.
+ # But note that ${workdir} may be shared with something else,
+ # and thus already on top of PATH.
+ if [[ ${PATH##:*} != ${workdir}/bin ]]; then
+ PATH=${workdir}/bin${PATH:+:${PATH}}
+ fi
+ if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then
+ PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}
+ fi
+ export PATH PKG_CONFIG_PATH
+ fi
+}
+
_PYTHON_UTILS_R1=1
fi