* [gentoo-python] python-any-r1: bunch of bugfixes/improvements and dep-checking function
@ 2013-04-22 10:51 Michał Górny
2013-04-22 10:52 ` [gentoo-python] [PATCH 1/4] Make Python checks consistent Michał Górny
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Michał Górny @ 2013-04-22 10:51 UTC (permalink / raw
To: gentoo-python; +Cc: python
[-- Attachment #1: Type: text/plain, Size: 1668 bytes --]
Hi,
I'm submitting a batch of patches for python-any-r1. The patches:
1. improve consistency between Python impl checking code. All branches
start to check whether Python interpreter is installed.
2. improve consistency in wrapper setup. All branches now set up
wrappers.
3. error out if no Python impl matches. This will become important with
the new dep-check function.
4. add support for defining python_check_deps() function in ebuilds.
The function can be used to verify whether Python impl chosen by eclass
supports all the deps needed for the package.
For example, if a package runs a script needing dev-python/foo
and dev-python/bar, the function would look like:
python_check_deps() {
if ! has_version "dev-python/foo[${PYTHON_USEDEP}]"; then
einfo "${EPYTHON}: dev-python/foo does not support the impl"
return 1
elif ! has_version "dev-python/bar[${PYTHON_USEDEP}]"; then
einfo "${EPYTHON}: dev-python/bar does not support the impl"
return 1
else
return 0
fi
}
Note that the package will need a proper dep as well:
DEPEND="
${PYTHON_DEPS}
python_targets_python2_7? (
dev-python/foo[python_targets_python2_7]
dev-python/bar[python_targets_python2_7]
)
"
Note to self: think how to improve the deps.
Please note that the new syntax will be necessary only with more
complex cases. Simpler things like package just calling 'pyfoo' script
will be handled by simple:
DEPEND="dev-python/pyfoo"
which will enforce at least one impl for pyfoo, and pyfoo wrapper will
handle the rest.
--
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 1/4] Make Python checks consistent.
2013-04-22 10:51 [gentoo-python] python-any-r1: bunch of bugfixes/improvements and dep-checking function Michał Górny
@ 2013-04-22 10:52 ` Michał Górny
2013-04-22 10:52 ` [gentoo-python] [PATCH 2/4] Perform wrapper setup in all codepaths Michał Górny
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Michał Górny @ 2013-04-22 10:52 UTC (permalink / raw
To: gentoo-python; +Cc: python, Michał Górny
Always use _python_EPYTHON_supported(), and always check for the package
being installed.
---
gx86/eclass/python-any-r1.eclass | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/gx86/eclass/python-any-r1.eclass b/gx86/eclass/python-any-r1.eclass
index dc3443b..3799491 100644
--- a/gx86/eclass/python-any-r1.eclass
+++ b/gx86/eclass/python-any-r1.eclass
@@ -158,7 +158,11 @@ _python_EPYTHON_supported() {
esac
if has "${i}" "${PYTHON_COMPAT[@]}"; then
- return 0
+ local PYTHON_PKG_DEP
+ python_export "${i}" PYTHON_PKG_DEP
+ if ROOT=/ has_version "${PYTHON_PKG_DEP}"; then
+ return 0
+ fi
elif ! has "${i}" "${_PYTHON_ALL_IMPLS[@]}"; then
ewarn "Invalid EPYTHON: ${EPYTHON}"
fi
@@ -202,10 +206,9 @@ python-any-r1_pkg_setup() {
fi
done
- local PYTHON_PKG_DEP
for i in "${rev_impls[@]}"; do
- python_export "${i}" PYTHON_PKG_DEP EPYTHON PYTHON
- if ROOT=/ has_version "${PYTHON_PKG_DEP}"; then
+ python_export "${i}" EPYTHON PYTHON
+ if _python_EPYTHON_supported "${EPYTHON}"; then
python_wrapper_setup "${T}"
return
fi
--
1.8.1.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-python] [PATCH 2/4] Perform wrapper setup in all codepaths.
2013-04-22 10:51 [gentoo-python] python-any-r1: bunch of bugfixes/improvements and dep-checking function Michał Górny
2013-04-22 10:52 ` [gentoo-python] [PATCH 1/4] Make Python checks consistent Michał Górny
@ 2013-04-22 10:52 ` Michał Górny
2013-04-22 10:52 ` [gentoo-python] [PATCH 3/4] Report no matching Python impl properly Michał Górny
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Michał Górny @ 2013-04-22 10:52 UTC (permalink / raw
To: gentoo-python; +Cc: python, Michał Górny
Currently, the wrapper was set up only in the fallback line. Instead,
set it up consistently in all cases.
---
gx86/eclass/python-any-r1.eclass | 2 ++
1 file changed, 2 insertions(+)
diff --git a/gx86/eclass/python-any-r1.eclass b/gx86/eclass/python-any-r1.eclass
index 3799491..2ecbfbd 100644
--- a/gx86/eclass/python-any-r1.eclass
+++ b/gx86/eclass/python-any-r1.eclass
@@ -180,6 +180,7 @@ python-any-r1_pkg_setup() {
if [[ ${EPYTHON} ]]; then
if _python_EPYTHON_supported "${EPYTHON}"; then
python_export EPYTHON PYTHON
+ python_wrapper_setup "${T}"
return
fi
fi
@@ -194,6 +195,7 @@ python-any-r1_pkg_setup() {
break
elif _python_EPYTHON_supported "${i}"; then
python_export "${i}" EPYTHON PYTHON
+ python_wrapper_setup "${T}"
return
fi
done
--
1.8.1.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-python] [PATCH 3/4] Report no matching Python impl properly.
2013-04-22 10:51 [gentoo-python] python-any-r1: bunch of bugfixes/improvements and dep-checking function Michał Górny
2013-04-22 10:52 ` [gentoo-python] [PATCH 1/4] Make Python checks consistent Michał Górny
2013-04-22 10:52 ` [gentoo-python] [PATCH 2/4] Perform wrapper setup in all codepaths Michał Górny
@ 2013-04-22 10:52 ` Michał Górny
2013-04-22 10:52 ` [gentoo-python] [PATCH 4/4] Add python_check_deps() to support testing supported impls Michał Górny
2013-04-30 5:36 ` [gentoo-python] python-any-r1: bunch of bugfixes/improvements and dep-checking function Michał Górny
4 siblings, 0 replies; 6+ messages in thread
From: Michał Górny @ 2013-04-22 10:52 UTC (permalink / raw
To: gentoo-python; +Cc: python, Michał Górny
---
gx86/eclass/python-any-r1.eclass | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/gx86/eclass/python-any-r1.eclass b/gx86/eclass/python-any-r1.eclass
index 2ecbfbd..d222155 100644
--- a/gx86/eclass/python-any-r1.eclass
+++ b/gx86/eclass/python-any-r1.eclass
@@ -215,6 +215,12 @@ python-any-r1_pkg_setup() {
return
fi
done
+
+ eerror "No Python implementation found for the build. This is usually"
+ eerror "a bug in the ebuild. Please report it to bugs.gentoo.org"
+ eerror "along with the build log."
+ echo
+ die "No supported Python implementation installed."
}
_PYTHON_ANY_R1=1
--
1.8.1.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-python] [PATCH 4/4] Add python_check_deps() to support testing supported impls.
2013-04-22 10:51 [gentoo-python] python-any-r1: bunch of bugfixes/improvements and dep-checking function Michał Górny
` (2 preceding siblings ...)
2013-04-22 10:52 ` [gentoo-python] [PATCH 3/4] Report no matching Python impl properly Michał Górny
@ 2013-04-22 10:52 ` Michał Górny
2013-04-30 5:36 ` [gentoo-python] python-any-r1: bunch of bugfixes/improvements and dep-checking function Michał Górny
4 siblings, 0 replies; 6+ messages in thread
From: Michał Górny @ 2013-04-22 10:52 UTC (permalink / raw
To: gentoo-python; +Cc: python, Michał Górny
Now ebuilds can declare python_check_deps() function. It will be called
with EPYTHON and PYTHON_USEDEP set for the impl, and it can do whatever
to check whether the impl in question is fine with them, then return
an appropriate boolean status.
---
gx86/eclass/python-any-r1.eclass | 40 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/gx86/eclass/python-any-r1.eclass b/gx86/eclass/python-any-r1.eclass
index d222155..88b5752 100644
--- a/gx86/eclass/python-any-r1.eclass
+++ b/gx86/eclass/python-any-r1.eclass
@@ -20,6 +20,14 @@
# pkg_setup() which finds the best supported implementation and sets it
# as the active one.
#
+# Optionally, you can define a python_check_deps() function. It will
+# be called by the eclass with EPYTHON set to each matching Python
+# implementation and it is expected to check whether the implementation
+# fulfills the package requirements. You can use the locally exported
+# PYTHON_USEDEP to check USE-dependencies of relevant packages. It
+# should return a true value (0) if the Python implementation fulfills
+# the requirements, a false value (non-zero) otherwise.
+#
# Please note that python-any-r1 will always inherit python-utils-r1
# as well. Thus, all the functions defined there can be used in the
# packages using python-any-r1, and there is no need ever to inherit
@@ -134,16 +142,38 @@ _python_build_set_globals() {
}
_python_build_set_globals
+# @ECLASS-VARIABLE: PYTHON_USEDEP
+# @DESCRIPTION:
+# An eclass-generated USE-dependency string for the currently tested
+# implementation. It is set locally for python_check_deps() call.
+#
+# The generate USE-flag list is compatible with packages using python-r1,
+# python-single-r1 and python-distutils-ng eclasses. It must not be used
+# on packages using python.eclass.
+#
+# Example use:
+# @CODE
+# python_check_deps() {
+# has_version "dev-python/foo[${PYTHON_USEDEP}]"
+# }
+# @CODE
+#
+# Example value:
+# @CODE
+# python_targets_python2_7(-)?,python_single_target_python2_7(+)?
+# @CODE
+
# @FUNCTION: _python_EPYTHON_supported
# @USAGE: <epython>
# @INTERNAL
# @DESCRIPTION:
# Check whether the specified implementation is supported by package
-# (specified in PYTHON_COMPAT).
+# (specified in PYTHON_COMPAT). Calls python_check_deps() if declared.
_python_EPYTHON_supported() {
debug-print-function ${FUNCNAME} "${@}"
- local i=${1/./_}
+ local EPYTHON=${1}
+ local i=${EPYTHON/./_}
case "${i}" in
python*|jython*)
@@ -161,6 +191,12 @@ _python_EPYTHON_supported() {
local PYTHON_PKG_DEP
python_export "${i}" PYTHON_PKG_DEP
if ROOT=/ has_version "${PYTHON_PKG_DEP}"; then
+ if declare -f python_check_deps >/dev/null; then
+ local PYTHON_USEDEP="python_targets_${i}(-),python_single_target_${i}(+)"
+ python_check_deps
+ return ${?}
+ fi
+
return 0
fi
elif ! has "${i}" "${_PYTHON_ALL_IMPLS[@]}"; then
--
1.8.1.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [gentoo-python] python-any-r1: bunch of bugfixes/improvements and dep-checking function
2013-04-22 10:51 [gentoo-python] python-any-r1: bunch of bugfixes/improvements and dep-checking function Michał Górny
` (3 preceding siblings ...)
2013-04-22 10:52 ` [gentoo-python] [PATCH 4/4] Add python_check_deps() to support testing supported impls Michał Górny
@ 2013-04-30 5:36 ` Michał Górny
4 siblings, 0 replies; 6+ messages in thread
From: Michał Górny @ 2013-04-30 5:36 UTC (permalink / raw
To: Michał Górny; +Cc: gentoo-python, python
[-- Attachment #1: Type: text/plain, Size: 48 bytes --]
Committed.
--
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
end of thread, other threads:[~2013-04-30 5:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-22 10:51 [gentoo-python] python-any-r1: bunch of bugfixes/improvements and dep-checking function Michał Górny
2013-04-22 10:52 ` [gentoo-python] [PATCH 1/4] Make Python checks consistent Michał Górny
2013-04-22 10:52 ` [gentoo-python] [PATCH 2/4] Perform wrapper setup in all codepaths Michał Górny
2013-04-22 10:52 ` [gentoo-python] [PATCH 3/4] Report no matching Python impl properly Michał Górny
2013-04-22 10:52 ` [gentoo-python] [PATCH 4/4] Add python_check_deps() to support testing supported impls Michał Górny
2013-04-30 5:36 ` [gentoo-python] python-any-r1: bunch of bugfixes/improvements and dep-checking function 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