From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id ED51A138010 for ; Fri, 29 Mar 2013 22:38:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D97F9E0895; Fri, 29 Mar 2013 22:38:42 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 6286DE0895 for ; Fri, 29 Mar 2013 22:38:42 +0000 (UTC) Received: from pomiocik.lan (77-255-217-157.adsl.inetia.pl [77.255.217.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id 84FEF33DBAB; Fri, 29 Mar 2013 22:38:40 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-python@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-python] [PATCH] Create a temporary links for Python execs and pkg-config. Date: Fri, 29 Mar 2013 23:39:30 +0100 Message-Id: <1364596770-17336-1-git-send-email-mgorny@gentoo.org> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <20130329233803.2ba9f24b@pomiocik.lan> References: <20130329233803.2ba9f24b@pomiocik.lan> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Discussions centering around the Python ecosystem in Gentoo Linux X-BeenThere: gentoo-python@gentoo.org X-BeenThere: gentoo-python@lists.gentoo.org X-Archives-Salt: 176648a2-212c-4638-85b8-5100b6b3e89a X-Archives-Hash: 8a9461bc0c8c87c0cdae66da8cb569c1 With this patch, all apps which call 'python', 'python2', 'python3', '2to3', 'python-config' or 'pkg-config ... python' start to work properly without any kind of wrapper. The wrappers are set up in python_foreach_impl, python_export_best and pkg_setup phases of python-any-r1 and python-single-r1. python_foreach_impl uses ${T}/${EPYTHON} subdirs for the wrappers. The remaining functions set them 'globally' in ${T}. --- gx86/eclass/python-any-r1.eclass | 5 +- gx86/eclass/python-r1.eclass | 3 ++ gx86/eclass/python-single-r1.eclass | 1 + gx86/eclass/python-utils-r1.eclass | 94 +++++++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 1 deletion(-) diff --git a/gx86/eclass/python-any-r1.eclass b/gx86/eclass/python-any-r1.eclass index 5d9a3d1..4761221 100644 --- a/gx86/eclass/python-any-r1.eclass +++ b/gx86/eclass/python-any-r1.eclass @@ -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/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass index 4ba80a9..a3fdd0e 100644 --- a/gx86/eclass/python-r1.eclass +++ b/gx86/eclass/python-r1.eclass @@ -634,7 +634,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}" "${@}" } @@ -707,6 +709,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/gx86/eclass/python-single-r1.eclass b/gx86/eclass/python-single-r1.eclass index 6235b66..950bf52 100644 --- a/gx86/eclass/python-single-r1.eclass +++ b/gx86/eclass/python-single-r1.eclass @@ -207,6 +207,7 @@ python-single-r1_pkg_setup() { fi python_export "${impl}" EPYTHON PYTHON + python_wrapper_setup "${T}" fi done diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass index a375546..6aa4a64 100644 --- a/gx86/eclass/python-utils-r1.eclass +++ b/gx86/eclass/python-utils-r1.eclass @@ -818,5 +818,99 @@ python_doheader() { doins -r "${@}" || die } +# @FUNCTION: python_wrapper_setup +# @USAGE: [] +# @DESCRIPTION: +# Create proper 'python' executable and pkg-config wrappers +# (if available) in the directory named by . Set up PATH +# and PKG_CONFIG_PATH appropriately. +# +# The wrappers will be created for implementation named by , +# or for one named by ${EPYTHON} if no 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 -- 1.8.1.5