public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Arfrever Frehtes Taifersar Arahesis (arfrever)" <arfrever@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] gentoo-x86 commit in eclass: distutils.eclass
Date: Thu, 24 Dec 2009 04:21:39 +0000	[thread overview]
Message-ID: <E1NNfCl-00049V-BT@stork.gentoo.org> (raw)

arfrever    09/12/24 04:21:39

  Modified:             distutils.eclass
  Log:
  Disallow using of ${python}, distutils_python_version() and distutils_python_tkinter() in EAPI >=3. Add renaming of Python scripts containing versioned shebangs and generation of wrapper scripts.

Revision  Changes    Path
1.68                 eclass/distutils.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/distutils.eclass?rev=1.68&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/distutils.eclass?rev=1.68&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/distutils.eclass?r1=1.67&r2=1.68

Index: distutils.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- distutils.eclass	28 Nov 2009 18:39:27 -0000	1.67
+++ distutils.eclass	24 Dec 2009 04:21:39 -0000	1.68
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.67 2009/11/28 18:39:27 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.68 2009/12/24 04:21:39 arfrever Exp $
 
 # @ECLASS: distutils.eclass
 # @MAINTAINER:
@@ -28,7 +28,12 @@
 	DEPEND="virtual/python"
 	RDEPEND="${DEPEND}"
 fi
-python="python"
+
+if has "${EAPI:-0}" 0 1 2; then
+	python="python"
+else
+	python="die"
+fi
 
 # @ECLASS-VARIABLE: DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES
 # @DESCRIPTION:
@@ -38,6 +43,11 @@
 # @DESCRIPTION:
 # Global options passed to setup.py.
 
+# @ECLASS-VARIABLE: DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS
+# @DESCRIPTION:
+# Set this to disable renaming of Python scripts containing versioned shebangs
+# and generation of wrapper scripts.
+
 # @ECLASS-VARIABLE: DOCS
 # @DESCRIPTION:
 # Additional DOCS
@@ -153,6 +163,24 @@
 	python_need_rebuild
 
 	if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+		if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then
+			declare -A wrapper_scripts=()
+
+			rename_scripts_with_versioned_shebangs() {
+				if [[ -d "${D}usr/bin" ]]; then
+					cd "${D}usr/bin"
+
+					local file
+					for file in *; do
+						if [[ -f "${file}" && ! "${file}" =~ [[:digit:]]+\.[[:digit:]]+$ && "$(head -n1 "${file}")" =~ ^'#!'.*python[[:digit:]]+\.[[:digit:]]+ ]]; then
+							mv "${file}" "${file}-${PYTHON_ABI}" || die "Renaming of '${file}' failed"
+							wrapper_scripts+=(["${D}usr/bin/${file}"]=)
+						fi
+					done
+				fi
+			}
+		fi
+
 		if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then
 			installation() {
 				_distutils_hook pre
@@ -167,6 +195,10 @@
 				echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@"
 				"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || return "$?"
 
+				if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then
+					rename_scripts_with_versioned_shebangs
+				fi
+
 				_distutils_hook post
 			}
 			python_execute_function -s installation "$@"
@@ -184,10 +216,19 @@
 				echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@"
 				"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@" || return "$?"
 
+				if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then
+					rename_scripts_with_versioned_shebangs
+				fi
+
 				_distutils_hook post
 			}
 			python_execute_function installation "$@"
 		fi
+
+		if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${#wrapper_scripts[@]}" -ne "0" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then
+			python_generate_wrapper_scripts "${!wrapper_scripts[@]}"
+		fi
+		unset wrapper_scripts
 	else
 		# need this for python-2.5 + setuptools in cases where
 		# a package uses distutils but does not install anything
@@ -283,6 +324,10 @@
 # Calls python_version, so that you can use something like
 # e.g. insinto ${ROOT}/usr/include/python${PYVER}
 distutils_python_version() {
+	if ! has "${EAPI:-0}" 0 1 2; then
+		die "${FUNCNAME}() cannot be used in this EAPI"
+	fi
+
 	python_version
 }
 
@@ -290,5 +335,9 @@
 # @DESCRIPTION:
 # Checks for if tkinter support is compiled into python
 distutils_python_tkinter() {
+	if ! has "${EAPI:-0}" 0 1 2; then
+		die "${FUNCNAME}() cannot be used in this EAPI"
+	fi
+
 	python_tkinter_exists
 }






             reply	other threads:[~2009-12-24  4:21 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-24  4:21 Arfrever Frehtes Taifersar Arahesis (arfrever) [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-04-12 18:49 [gentoo-commits] gentoo-x86 commit in eclass: distutils.eclass Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-12-24 15:05 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-12-13 13:36 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-10-10 19:23 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-07-17 23:03 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-05-25 15:07 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-03-04 17:49 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-02-28 11:52 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-02-08  9:35 Peter Volkov (pva)
2010-02-07 21:17 Peter Volkov (pva)
2010-02-04 18:31 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-01-10 17:24 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-11-28 18:39 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-11-06  0:35 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-10-11 13:38 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-09-11 20:03 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-09-11 12:24 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-09-09 19:26 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-09-07  2:34 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-09-05 16:45 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-08-12  2:24 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-08-05 18:34 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-08-02  0:30 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-02-18 14:43 Peter Volkov (pva)
2008-10-28 21:29 Ali Polatel (hawking)
2008-10-27  0:19 Ali Polatel (hawking)
2008-09-24 16:45 Ali Polatel (hawking)
2008-06-28  0:05 Luca Longinotti (chtekk)
2008-06-24 13:40 Ali Polatel (hawking)
2008-06-20 18:21 Ali Polatel (hawking)
2008-05-30 10:22 Ali Polatel (hawking)
2008-05-29 15:24 Ali Polatel (hawking)
2008-01-23 22:19 Ali Polatel (hawking)
2007-10-25 13:49 Ali Polatel (hawking)

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=E1NNfCl-00049V-BT@stork.gentoo.org \
    --to=arfrever@gentoo.org \
    --cc=gentoo-commits@lists.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