From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-dev] [PATCH] python-r1: introduce PYTHON executable getter.
Date: Mon, 24 Sep 2012 23:11:04 +0200 [thread overview]
Message-ID: <1348521064-31463-1-git-send-email-mgorny@gentoo.org> (raw)
In-Reply-To: <1348048827-1290-1-git-send-email-mgorny@gentoo.org>
A semi-replacement for _python-distutils-ng_very_long_name...
Unlike the forementioned function, it returns just the binary name
and not the complete path. Thus, the executable rewrite in p-d-ng has
been changed to use #!/usr/bin/env.
---
gx86/eclass/python-distutils-ng.eclass | 28 ++++------------------------
gx86/eclass/python-r1.eclass | 20 ++++++++++++++++++++
2 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/gx86/eclass/python-distutils-ng.eclass b/gx86/eclass/python-distutils-ng.eclass
index 34717aa..33d183c 100644
--- a/gx86/eclass/python-distutils-ng.eclass
+++ b/gx86/eclass/python-distutils-ng.eclass
@@ -54,26 +54,6 @@ EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
DEPEND="${DEPEND} !<sys-apps/portage-2.1.10.58"
-# @FUNCTION: _python-distutils-ng_get_binary_for_implementation
-# @USAGE: implementation
-# @RETURN: Full path to Python binary for given implementation.
-# @DESCRIPTION:
-# This function returns full path for Python binary for given implementation.
-#
-# Binary returned by this function should be used instead of simply calling
-# `python'.
-_python-distutils-ng_get_binary_for_implementation() {
- local impl="${1/_/.}"
- case "${impl}" in
- python?.?|jython?.?)
- echo "/usr/bin/${impl}" ;;
- pypy?.?)
- echo "/usr/bin/pypy-c${impl: -3}" ;;
- *)
- die "Unsupported implementation: ${1}" ;;
- esac
-}
-
RDEPEND=${PYTHON_DEPS}
DEPEND=${PYTHON_DEPS}
@@ -90,7 +70,7 @@ _python-distutils-ng_run_for_impl() {
local command="${2}"
local S="${WORKDIR}/impl_${impl}/${_PACKAGE_SPECIFIC_S}"
- PYTHON="$(_python-distutils-ng_get_binary_for_implementation "${impl}")"
+ PYTHON="$(python_get_PYTHON "${impl}")"
EPYTHON="${impl/_/.}"
einfo "Running ${command} in ${S} for ${impl}"
@@ -147,10 +127,10 @@ python-distutils-ng_rewrite_hashbang() {
[[ -n "${1}" ]] || die "Missing file name"
[[ -n "${2}" ]] || die "Missing implementation"
local file_name="${1}"
- local binary="$(_python-distutils-ng_get_binary_for_implementation "${2}")"
+ local binary="$(python_get_PYTHON "${2}")"
[[ $(head -n 1 "${file_name}") == '#!'*(python|jython|pypy-c)* ]] || \
die "Missing or invalid #! line in ${file_name}"
- sed -i -e "1c#!${binary}" "${file_name}" || die
+ sed -i -e "1c#!/usr/bin/env ${binary}" "${file_name}" || die
}
# @FUNCTION: python-distutils-ng_redoscript
@@ -253,7 +233,7 @@ python-distutils-ng_src_prepare() {
# Try to run binary for each implementation:
for impl in ${PYTHON_COMPAT[@]}; do
use "python_targets_${impl}" ${PYTHON_COMPAT[@]} || continue
- $(_python-distutils-ng_get_binary_for_implementation "${impl}") \
+ $(python_get_PYTHON "${impl}") \
-c "import sys" || die
done
diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass
index 68b5c38..4c4d69d 100644
--- a/gx86/eclass/python-r1.eclass
+++ b/gx86/eclass/python-r1.eclass
@@ -118,3 +118,23 @@ _python_set_globals() {
done
}
_python_set_globals
+
+# @FUNCTION: python_get_PYTHON
+# @USAGE: <impl>
+# @DESCRIPTION:
+# Get the Python executable name for the given implementation.
+python_get_PYTHON() {
+ local impl=${1/_/.}
+
+ case "${impl}" in
+ python*|jython*)
+ echo ${impl}
+ ;;
+ pypy*)
+ echo pypy-c${impl#pypy}
+ ;;
+ *)
+ die "Invalid argument to python_get_PYTHON: ${1}"
+ ;;
+ esac
+}
--
1.7.12
prev parent reply other threads:[~2012-09-24 21:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-19 10:00 [gentoo-dev] [PATCH 1/6] Drop pointless default S assignment Michał Górny
2012-09-19 10:00 ` [gentoo-dev] [PATCH 2/6] Move EXPORT_FUNCTIONS after the EAPI switch Michał Górny
2012-09-19 10:00 ` [gentoo-dev] [PATCH 3/6] Temporarily remove PYTHON_OPTIONAL -- it is mis-designed Michał Górny
2012-09-19 10:00 ` [gentoo-dev] [PATCH 4/6] Support PYTHON_COMPAT being an array Michał Górny
2012-09-19 10:00 ` [gentoo-dev] [PATCH 5/6] Move PYTHON_COMPAT, IUSE and REQUIRED_USE to python-r1 Michał Górny
2012-09-19 10:00 ` [gentoo-dev] [PATCH 6/6] Generate python depstrings in python-r1 Michał Górny
2012-09-19 13:00 ` Ian Stakenvicius
2012-09-19 17:37 ` Michał Górny
2012-09-19 17:58 ` Ian Stakenvicius
2012-09-19 18:40 ` Michał Górny
2012-09-19 21:43 ` [gentoo-dev] [PATCH 1/3] Generate python depstrings in python-r1 (updated) Michał Górny
2012-09-19 21:43 ` [gentoo-dev] [PATCH 2/3] Generate PYTHON_USEDEP for use in cross-package deps Michał Górny
2012-09-19 21:43 ` [gentoo-dev] [PATCH 3/3] Support specifying the USE-deps for Python impl Michał Górny
2012-09-22 4:47 ` [gentoo-dev] [PATCH 1/3] Generate python depstrings in python-r1 (updated) Ben de Groot
2012-09-24 21:11 ` Michał Górny [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1348521064-31463-1-git-send-email-mgorny@gentoo.org \
--to=mgorny@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox