* [gentoo-dev] New feature for python eclass for review
@ 2009-05-25 20:49 Petteri Räty
2009-05-27 22:49 ` Petteri Räty
0 siblings, 1 reply; 2+ messages in thread
From: Petteri Räty @ 2009-05-25 20:49 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1.1: Type: text/plain, Size: 249 bytes --]
I wrote support to the python eclass to make sure python version used to
install has support for needed use flags. With current EAPIs I can't
think of a way to do this without a pkg_setup check but feel free to
surprise me.
Regards,
Petteri
[-- Attachment #1.2: python-use-with.patch --]
[-- Type: text/plain, Size: 2812 bytes --]
Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.54
diff -u -r1.54 python.eclass
--- python.eclass 30 Oct 2008 05:21:46 -0000 1.54
+++ python.eclass 25 May 2009 20:47:37 -0000
@@ -14,8 +14,11 @@
if [[ -n "${NEED_PYTHON}" ]] ; then
- DEPEND=">=dev-lang/python-${NEED_PYTHON}"
+ PYTHON_ATOM=">=dev-lang/python-${NEED_PYTHON}"
+ DEPEND="${PYTHON_ATOM}"
RDEPEND="${DEPEND}"
+else
+ PYTHON_ATOM="dev-lang/python"
fi
__python_eclass_test() {
@@ -59,6 +62,78 @@
__python_version_extract $PYVER_ALL
}
+# @ECLASS-VARIABLE: PYTHON_USE_WITH
+# @DESCRIPTION:
+# Set this to a space separated list of use flags
+# the python slot in use must be built with.
+
+# @ECLASS-VARIABLE: PYTHON_USE_WITH_OR
+# @DESCRIPTION:
+# Set this to a space separated list of use flags
+# of which one must be turned on for the slot of
+# in use.
+
+# @ECLASS-VARIABLE: PYTHON_USE_WITH_OPT
+# @DESCRIPTION:
+# Set this if you need to make either PYTHON_USE_WITH or
+# PYTHON_USE_WITH_OR atoms conditional under a use flag.
+
+# @FUNCTION: python_pkg_setup
+# @DESCRIPTION:
+# Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags
+# are respected. Only exported if one of those variables is set.
+if ! has ${EAPI} 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
+ python_pkg_setup_fail() {
+ eerror "${1}"
+ die "${1}"
+ }
+
+ python_pkg_setup() {
+ [[ ${PYTHON_USE_WITH_OPT} ]] && use !${PYTHON_USE_WITH_OPT} && return
+
+ python_version
+ local failed
+ local pyatom="dev-lang/python:${PYVER}"
+
+ for use in ${PYTHON_USE_WITH}; do
+ if ! has_version "${pyatom}[${use}]"; then
+ python_pkg_setup_fail \
+ "Please rebuild ${pyatom} with use flags: ${PYTHON_USE_WITH}"
+ fi
+ done
+
+ for use in ${PYTHON_USE_WITH_OR}; do
+ if has_version "${pyatom}[${use}]"; then
+ return
+ fi
+ done
+
+ if [[ ${PYTHON_USE_WITH_OR} ]]; then
+ python_pkg_setup_fail \
+ "Please rebuild ${pyatom} with one of: ${PYTHON_USE_WITH_OR}"
+ fi
+ }
+
+ EXPORT_FUNCTIONS pkg_setup
+
+ if [[ ${PYTHON_USE_WITH} ]]; then
+ PYTHON_USE_WITH_ATOM="${PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]"
+ elif [[ ${PYTHON_USE_WITH_OR} ]]; then
+ PYTHON_USE_WITH_ATOM="|| ( "
+ for use in ${PYTHON_USE_WITH_OR}; do
+ PYTHON_USE_WITH_ATOM="
+ ${PYTHON_USE_WITH_ATOM}
+ ${PYTHON_ATOM}[${use}]"
+ done
+ PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_ATOM} )"
+ fi
+ if [[ ${PYTHON_USE_WITH_OPT} ]]; then
+ PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${PYTHON_USE_WITH_ATOM} )"
+ fi
+ DEPEND="${PYTHON_USE_WITH_ATOM}"
+ RDEPEND="${PYTHON_USE_WITH_ATOM}"
+fi
+
# @FUNCTION: python_disable_pyc
# @DESCRIPTION:
# Tells python not to automatically recompile modules to .pyc/.pyo
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 261 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [gentoo-dev] New feature for python eclass for review
2009-05-25 20:49 [gentoo-dev] New feature for python eclass for review Petteri Räty
@ 2009-05-27 22:49 ` Petteri Räty
0 siblings, 0 replies; 2+ messages in thread
From: Petteri Räty @ 2009-05-27 22:49 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 341 bytes --]
Petteri Räty wrote:
> I wrote support to the python eclass to make sure python version used to
> install has support for needed use flags. With current EAPIs I can't
> think of a way to do this without a pkg_setup check but feel free to
> surprise me.
>
> Regards,
> Petteri
>
No comments so committed.
Regards,
Petteri
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 261 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-05-27 22:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-25 20:49 [gentoo-dev] New feature for python eclass for review Petteri Räty
2009-05-27 22:49 ` Petteri Räty
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox