public inbox for gentoo-python@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-python] [PATCHES] Initial python-utils-r1 changes for PyPy 2.1
@ 2013-08-21 19:53 Michał Górny
  2013-08-21 19:54 ` [gentoo-python] [PATCH python-utils-r1 1/4] Add python_is_python3() Michał Górny
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Michał Górny @ 2013-08-21 19:53 UTC (permalink / raw
  To: gentoo-python; +Cc: python

[-- Attachment #1: Type: text/plain, Size: 602 bytes --]

Hello,

I haven't got much time, so they were only quick and the checks were
dirty, so they can be buggy and need much more testing. I only adjusted
the code, didn't add PyPy to supported impls.

The patches:

- add python_is_python3() helper and use it throughout the code,

- add pypy-X_Y and pypy3-X_Y impl support that maps to pypy-X.Y
  and pypy3-X.Y executables and directories.

The code has a few more branches that I could. I specifically made sure
to keep the pre-2.1 pypy support separated for easy removal
in the future. Please review.

-- 
Best regards,
Michał Górny

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 966 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [gentoo-python] [PATCH python-utils-r1 1/4] Add python_is_python3().
  2013-08-21 19:53 [gentoo-python] [PATCHES] Initial python-utils-r1 changes for PyPy 2.1 Michał Górny
@ 2013-08-21 19:54 ` Michał Górny
  2013-08-21 19:54 ` [gentoo-python] [PATCH python-utils-r1 2/4] Use python_is_python3 in the eclass Michał Górny
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Michał Górny @ 2013-08-21 19:54 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

To replace the checks with ones suitable for PyPy3.
---
 gx86/eclass/python-utils-r1.eclass | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass
index 5814a13..00399d2 100644
--- a/gx86/eclass/python-utils-r1.eclass
+++ b/gx86/eclass/python-utils-r1.eclass
@@ -942,5 +942,19 @@ __EOF__
 	fi
 }
 
+# @FUNCTION: python_is_python3
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Check whether <impl> (or ${EPYTHON}) is a Python3k variant
+# (i.e. uses syntax and stdlib of Python 3.*).
+#
+# Returns 0 (true) if it is, 1 (false) otherwise.
+python_is_python3() {
+	local impl=${1:-${EPYTHON}}
+	[[ ${impl} ]] || die "python_is_python3: no impl nor EPYTHON"
+
+	[[ ${impl} == python3* ]]
+}
+
 _PYTHON_UTILS_R1=1
 fi
-- 
1.8.3.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-python] [PATCH python-utils-r1 2/4] Use python_is_python3 in the eclass.
  2013-08-21 19:53 [gentoo-python] [PATCHES] Initial python-utils-r1 changes for PyPy 2.1 Michał Górny
  2013-08-21 19:54 ` [gentoo-python] [PATCH python-utils-r1 1/4] Add python_is_python3() Michał Górny
@ 2013-08-21 19:54 ` Michał Górny
  2013-08-21 19:54 ` [gentoo-python] [PATCH python-utils-r1 3/4] Add support for PyPy 2.1 paths Michał Górny
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Michał Górny @ 2013-08-21 19:54 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

---
 gx86/eclass/python-utils-r1.eclass | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass
index 00399d2..e798c8d 100644
--- a/gx86/eclass/python-utils-r1.eclass
+++ b/gx86/eclass/python-utils-r1.eclass
@@ -532,8 +532,8 @@ _python_rewrite_shebang() {
 			die "${FUNCNAME}: ${f} does not seem to have a valid shebang"
 		fi
 
-		if [[ ${from} == python2 && ${impl} == python3*
-				|| ${from} == python3 && ${impl} != python3* ]]; then
+		if [[ ${from} == python2 ]] && python_is_python3 "${impl}" \
+				|| [[ ${from} == python3 ]] && ! python_is_python3 "${impl}"; then
 			eerror "A file does have shebang not supporting requested impl:"
 			eerror "  file: ${f}"
 			eerror "  shebang: ${shebang}"
@@ -883,9 +883,9 @@ python_wrapper_setup() {
 		python_export "${impl}" EPYTHON PYTHON
 
 		local pyver
-		if [[ ${EPYTHON} == python3* ]]; then
+		if python_is_python3; then
 			pyver=3
-		else # includes pypy & jython
+		else
 			pyver=2
 		fi
 
-- 
1.8.3.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-python] [PATCH python-utils-r1 3/4] Add support for PyPy 2.1 paths.
  2013-08-21 19:53 [gentoo-python] [PATCHES] Initial python-utils-r1 changes for PyPy 2.1 Michał Górny
  2013-08-21 19:54 ` [gentoo-python] [PATCH python-utils-r1 1/4] Add python_is_python3() Michał Górny
  2013-08-21 19:54 ` [gentoo-python] [PATCH python-utils-r1 2/4] Use python_is_python3 in the eclass Michał Górny
@ 2013-08-21 19:54 ` Michał Górny
  2013-08-21 19:54 ` [gentoo-python] [PATCH python-utils-r1 4/4] Support PyPy3 as Py3k provider Michał Górny
  2013-08-22  7:46 ` [gentoo-python] [PATCH python-utils-r1] Add some tests for query functions Michał Górny
  4 siblings, 0 replies; 6+ messages in thread
From: Michał Górny @ 2013-08-21 19:54 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

---
 gx86/eclass/python-utils-r1.eclass | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass
index e798c8d..c34bcbd 100644
--- a/gx86/eclass/python-utils-r1.eclass
+++ b/gx86/eclass/python-utils-r1.eclass
@@ -215,19 +215,19 @@ python_export() {
 	local impl var
 
 	case "${1}" in
-		python*|jython*)
-			impl=${1/_/.}
-			shift
-			;;
 		pypy-c*)
 			impl=${1}
 			shift
 			;;
-		pypy*)
+		pypy1*|pypy2_0)
 			local v=${1#pypy}
 			impl=pypy-c${v/_/.}
 			shift
 			;;
+		python*|jython*|pypy-*)
+			impl=${1/_/.}
+			shift
+			;;
 		*)
 			impl=${EPYTHON}
 			[[ ${impl} ]] || die "python_export: no impl nor EPYTHON"
@@ -248,15 +248,15 @@ python_export() {
 			PYTHON_SITEDIR)
 				local dir
 				case "${impl}" in
-					python*)
-						dir=/usr/$(get_libdir)/${impl}
-						;;
 					jython*)
 						dir=/usr/share/${impl}/Lib
 						;;
-					pypy*)
+					pypy-c*)
 						dir=/usr/$(get_libdir)/${impl/-c/}
 						;;
+					python*|pypy*)
+						dir=/usr/$(get_libdir)/${impl}
+						;;
 				esac
 
 				export PYTHON_SITEDIR=${EPREFIX}${dir}/site-packages
@@ -271,9 +271,12 @@ python_export() {
 					jython*)
 						dir=/usr/share/${impl}/Include
 						;;
-					pypy*)
+					pypy-c*)
 						dir=/usr/$(get_libdir)/${impl/-c/}/include
 						;;
+					pypy*)
+						dir=/usr/$(get_libdir)/${impl}/include
+						;;
 				esac
 
 				export PYTHON_INCLUDEDIR=${EPREFIX}${dir}
@@ -500,7 +503,7 @@ _python_rewrite_shebang() {
 
 	local impl
 	case "${1}" in
-		python*|jython*|pypy-c*)
+		python*|jython*|pypy*)
 			impl=${1}
 			shift
 			;;
-- 
1.8.3.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-python] [PATCH python-utils-r1 4/4] Support PyPy3 as Py3k provider.
  2013-08-21 19:53 [gentoo-python] [PATCHES] Initial python-utils-r1 changes for PyPy 2.1 Michał Górny
                   ` (2 preceding siblings ...)
  2013-08-21 19:54 ` [gentoo-python] [PATCH python-utils-r1 3/4] Add support for PyPy 2.1 paths Michał Górny
@ 2013-08-21 19:54 ` Michał Górny
  2013-08-22  7:46 ` [gentoo-python] [PATCH python-utils-r1] Add some tests for query functions Michał Górny
  4 siblings, 0 replies; 6+ messages in thread
From: Michał Górny @ 2013-08-21 19:54 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

---
 gx86/eclass/python-utils-r1.eclass | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass
index c34bcbd..9c9b417 100644
--- a/gx86/eclass/python-utils-r1.eclass
+++ b/gx86/eclass/python-utils-r1.eclass
@@ -339,20 +339,34 @@ python_export() {
 				debug-print "${FUNCNAME}: PYTHON_LIBS = ${PYTHON_LIBS}"
 				;;
 			PYTHON_PKG_DEP)
-				local d
+				local d slot
 				case ${impl} in
 					python*)
-						PYTHON_PKG_DEP='dev-lang/python';;
+						PYTHON_PKG_DEP='dev-lang/python'
+						slot=${impl#python}
+						;;
 					jython*)
-						PYTHON_PKG_DEP='dev-java/jython';;
-					pypy*)
-						PYTHON_PKG_DEP='virtual/pypy';;
+						PYTHON_PKG_DEP='dev-java/jython'
+						slot=${impl#jython}
+						;;
+					pypy-c*)
+						PYTHON_PKG_DEP='virtual/pypy'
+						slot=${impl#pypy-c}
+						;;
+					pypy-*)
+						PYTHON_PKG_DEP='virtual/pypy'
+						slot=${impl#pypy-}
+						;;
+					pypy3-*)
+						PYTHON_PKG_DEP='virtual/pypy3'
+						slot=${impl#pypy3-}
+						;;
 					*)
 						die "Invalid implementation: ${impl}"
 				esac
 
 				# slot
-				PYTHON_PKG_DEP+=:${impl##*[a-z-]}
+				PYTHON_PKG_DEP+=:${slot}
 
 				# use-dep
 				if [[ ${PYTHON_REQ_USE} ]]; then
@@ -956,7 +970,7 @@ python_is_python3() {
 	local impl=${1:-${EPYTHON}}
 	[[ ${impl} ]] || die "python_is_python3: no impl nor EPYTHON"
 
-	[[ ${impl} == python3* ]]
+	[[ ${impl} == python3* || ${impl} == pypy3* ]]
 }
 
 _PYTHON_UTILS_R1=1
-- 
1.8.3.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-python] [PATCH python-utils-r1] Add some tests for query functions.
  2013-08-21 19:53 [gentoo-python] [PATCHES] Initial python-utils-r1 changes for PyPy 2.1 Michał Górny
                   ` (3 preceding siblings ...)
  2013-08-21 19:54 ` [gentoo-python] [PATCH python-utils-r1 4/4] Support PyPy3 as Py3k provider Michał Górny
@ 2013-08-22  7:46 ` Michał Górny
  4 siblings, 0 replies; 6+ messages in thread
From: Michał Górny @ 2013-08-22  7:46 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

---
 gx86/eclass/tests/python-utils-r1.sh | 80 ++++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)
 create mode 100755 gx86/eclass/tests/python-utils-r1.sh

diff --git a/gx86/eclass/tests/python-utils-r1.sh b/gx86/eclass/tests/python-utils-r1.sh
new file mode 100755
index 0000000..e0378da
--- /dev/null
+++ b/gx86/eclass/tests/python-utils-r1.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+EAPI=5
+source tests-common.sh
+
+test_var() {
+	local var=${1}
+	local impl=${2}
+	local expect=${3}
+
+	tbegin "${var} for ${impl}"
+
+	local ${var}
+	python_export ${impl} ${var}
+	[[ ${!var} == ${expect} ]] || eerror "(${impl}: ${var}: ${!var} != ${expect}"
+
+	tend ${?}
+}
+
+test_is() {
+	local func=${1}
+	local EPYTHON=${2}
+	local expect=${3}
+
+	tbegin "${func} for ${EPYTHON} (expecting: ${3})"
+
+	${func}
+	[[ ${?} == ${expect} ]]
+
+	tend ${?}
+}
+
+inherit python-utils-r1
+
+test_var EPYTHON python2_7 python2.7
+test_var PYTHON python2_7 /usr/bin/python2.7
+test_var PYTHON_SITEDIR python2_7 /usr/lib/python2.7/site-packages
+test_var PYTHON_INCLUDEDIR python2_7 /usr/include/python2.7
+test_var PYTHON_LIBPATH python2_7 /usr/lib/libpython2.7$(get_libname)
+test_var PYTHON_PKG_DEP python2_7 dev-lang/python:2.7
+
+test_var EPYTHON python3_3 python3.3
+test_var PYTHON python3_3 /usr/bin/python3.3
+test_var PYTHON_SITEDIR python3_3 /usr/lib/python3.3/site-packages
+test_var PYTHON_INCLUDEDIR python3_3 /usr/include/python3.3
+test_var PYTHON_LIBPATH python3_3 /usr/lib/libpython3.3$(get_libname)
+test_var PYTHON_PKG_DEP python3_3 dev-lang/python:3.3
+
+test_var EPYTHON jython2_7 jython2.7
+test_var PYTHON jython2_7 /usr/bin/jython2.7
+test_var PYTHON_SITEDIR jython2_7 /usr/share/jython2.7/Lib/site-packages
+test_var PYTHON_INCLUDEDIR jython2_7 /usr/share/jython2.7/Include
+test_var PYTHON_PKG_DEP jython2_7 dev-java/jython:2.7
+
+test_var EPYTHON pypy2_0 pypy-c2.0
+test_var PYTHON pypy2_0 /usr/bin/pypy-c2.0
+test_var PYTHON_SITEDIR pypy2_0 /usr/lib/pypy2.0/site-packages
+test_var PYTHON_INCLUDEDIR pypy2_0 /usr/lib/pypy2.0/include
+test_var PYTHON_PKG_DEP pypy2_0 virtual/pypy:2.0
+
+test_var EPYTHON pypy-2_1 pypy-2.1
+test_var PYTHON pypy-2_1 /usr/bin/pypy-2.1
+test_var PYTHON_SITEDIR pypy-2_1 /usr/lib/pypy-2.1/site-packages
+test_var PYTHON_INCLUDEDIR pypy-2_1 /usr/lib/pypy-2.1/include
+test_var PYTHON_PKG_DEP pypy-2_1 virtual/pypy:2.1
+
+test_var EPYTHON pypy3-2_1 pypy3-2.1
+test_var PYTHON pypy3-2_1 /usr/bin/pypy3-2.1
+test_var PYTHON_SITEDIR pypy3-2_1 /usr/lib/pypy3-2.1/site-packages
+test_var PYTHON_INCLUDEDIR pypy3-2_1 /usr/lib/pypy3-2.1/include
+test_var PYTHON_PKG_DEP pypy3-2_1 virtual/pypy3:2.1
+
+test_is python_is_python3 python2.7 1
+test_is python_is_python3 python3.2 0
+test_is python_is_python3 jython2.7 1
+test_is python_is_python3 pypy2.0 1
+test_is python_is_python3 pypy-2.1 1
+test_is python_is_python3 pypy3-2.1 0
+
+texit
-- 
1.8.3.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-08-22  7:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-21 19:53 [gentoo-python] [PATCHES] Initial python-utils-r1 changes for PyPy 2.1 Michał Górny
2013-08-21 19:54 ` [gentoo-python] [PATCH python-utils-r1 1/4] Add python_is_python3() Michał Górny
2013-08-21 19:54 ` [gentoo-python] [PATCH python-utils-r1 2/4] Use python_is_python3 in the eclass Michał Górny
2013-08-21 19:54 ` [gentoo-python] [PATCH python-utils-r1 3/4] Add support for PyPy 2.1 paths Michał Górny
2013-08-21 19:54 ` [gentoo-python] [PATCH python-utils-r1 4/4] Support PyPy3 as Py3k provider Michał Górny
2013-08-22  7:46 ` [gentoo-python] [PATCH python-utils-r1] Add some tests for query functions Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox