public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCHES] distutils-r1: support 'edefault' in sub-phase functions
@ 2013-05-01 20:42 Michał Górny
  2013-05-01 20:42 ` [gentoo-dev] [PATCH 1/2] Introduce edefault() as a friendly default sub-phase wrapper Michał Górny
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Michał Górny @ 2013-05-01 20:42 UTC (permalink / raw
  To: gentoo-dev; +Cc: python

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

Hi, everyone.

This one goes to gentoo-dev since it's a potentially wider idea
and I'd like to get other developers opinion on.

As you most likely already know, distutils-r1 allows ebuilds to define
sub-phase functions like:

  python_compile() {
    # commands which will be run for each impl
    do_something_magical
  }

Often, ebuilds do not want to override the sub-phases completely
but instead call the default implementation:

  python_install_all() {
    use doc && local HTML_DOCS=( doc/html/. )
    distutils-r1_python_install_all
  }

So the behavior is quite similar to the regular phase functions.
However, the function names ended up quite verbose.

To make this more friendly, I would likely to locally introduce
'edefault' function in the eclass (name can change). The function would
-- similarly to 'default' in regular phase functions -- call
the default code for the sub-phase.

For example, the above would change to:

  python_install_all() {
    use doc && local HTML_DOCS=( doc/html/. )
    edefault
  }

I will send in reply a patch adding the described magic to the eclass,
and a second one showing how an example ebuild can be changed
(dev-python/setuptools).

What are your thoughts?

-- 
Best regards,
Michał Górny

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

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

* [gentoo-dev] [PATCH 1/2] Introduce edefault() as a friendly default sub-phase wrapper.
  2013-05-01 20:42 [gentoo-dev] [PATCHES] distutils-r1: support 'edefault' in sub-phase functions Michał Górny
@ 2013-05-01 20:42 ` Michał Górny
  2013-05-11  9:30   ` [gentoo-dev] [PATCH FIXED] " Michał Górny
  2013-05-01 20:42 ` [gentoo-dev] [PATCH 2/2] Example use of edefault Michał Górny
  2013-05-15 19:03 ` [gentoo-dev] [PATCHES] distutils-r1: support 'edefault' in sub-phase functions Michał Górny
  2 siblings, 1 reply; 8+ messages in thread
From: Michał Górny @ 2013-05-01 20:42 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, Michał Górny

---
 gx86/eclass/distutils-r1.eclass | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index 47b5b97..4c2e819 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -206,6 +206,20 @@ fi
 # }
 # @CODE
 
+# @FUNCTION: edefault
+# @USAGE: [<args>...]
+# @DESCRIPTION:
+# Runs the default distutils-r1 sub-phase implementation for the current
+# sub-phase. Available only in distutils-r1 sub-phases.
+#
+# Example:
+# @CODE
+# python_install_all() {
+#   use doc && local HTML_DOCS=( doc/html/. )
+#   edefault # == distutils-r1_python_install_all
+# }
+# @CODE
+
 # @FUNCTION: esetup.py
 # @USAGE: [<args>...]
 # @DESCRIPTION:
@@ -515,8 +529,12 @@ distutils-r1_run_phase() {
 
 	mkdir -p "${TMPDIR}" || die
 
+	eval "edefault() { ${1} }"
+
 	"${@}"
 
+	unset -f edefault
+
 	if [[ ${DISTUTILS_IN_SOURCE_BUILD} && ! ${DISTUTILS_SINGLE_IMPL} ]]
 	then
 		popd >/dev/null || die
-- 
1.8.2.1



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

* [gentoo-dev] [PATCH 2/2] Example use of edefault.
  2013-05-01 20:42 [gentoo-dev] [PATCHES] distutils-r1: support 'edefault' in sub-phase functions Michał Górny
  2013-05-01 20:42 ` [gentoo-dev] [PATCH 1/2] Introduce edefault() as a friendly default sub-phase wrapper Michał Górny
@ 2013-05-01 20:42 ` Michał Górny
  2013-05-15 19:03 ` [gentoo-dev] [PATCHES] distutils-r1: support 'edefault' in sub-phase functions Michał Górny
  2 siblings, 0 replies; 8+ messages in thread
From: Michał Górny @ 2013-05-01 20:42 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, Michał Górny

---
 gx86/dev-python/setuptools/setuptools-0.6.33.ebuild | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gx86/dev-python/setuptools/setuptools-0.6.33.ebuild b/gx86/dev-python/setuptools/setuptools-0.6.33.ebuild
index 4f4f3aa..91a8d57 100644
--- a/gx86/dev-python/setuptools/setuptools-0.6.33.ebuild
+++ b/gx86/dev-python/setuptools/setuptools-0.6.33.ebuild
@@ -37,7 +37,7 @@ python_prepare_all() {
 	# Disable tests requiring network connection.
 	rm -f setuptools/tests/test_packageindex.py
 
-	distutils-r1_python_prepare_all
+	edefault
 }
 
 python_test() {
@@ -48,5 +48,5 @@ python_test() {
 python_install() {
 	DISTRIBUTE_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT="1" \
 		DONT_PATCH_SETUPTOOLS="1" \
-		distutils-r1_python_install
+		edefault
 }
-- 
1.8.2.1



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

* [gentoo-dev] [PATCH FIXED] Introduce edefault() as a friendly default sub-phase wrapper.
  2013-05-01 20:42 ` [gentoo-dev] [PATCH 1/2] Introduce edefault() as a friendly default sub-phase wrapper Michał Górny
@ 2013-05-11  9:30   ` Michał Górny
  2013-05-11 15:51     ` [gentoo-dev] " Mike Gilbert
  0 siblings, 1 reply; 8+ messages in thread
From: Michał Górny @ 2013-05-11  9:30 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, Michał Górny

Fixed naming the proper default sub-phase and declaring 'edefault'
in python_prepare_all().
---
 gx86/eclass/distutils-r1.eclass | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index 47b5b97..e5c2a3a 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -206,6 +206,20 @@ fi
 # }
 # @CODE
 
+# @FUNCTION: edefault
+# @USAGE: [<args>...]
+# @DESCRIPTION:
+# Runs the default distutils-r1 sub-phase implementation for the current
+# sub-phase. Available only in distutils-r1 sub-phases.
+#
+# Example:
+# @CODE
+# python_install_all() {
+#   use doc && local HTML_DOCS=( doc/html/. )
+#   edefault # == distutils-r1_python_install_all
+# }
+# @CODE
+
 # @FUNCTION: esetup.py
 # @USAGE: [<args>...]
 # @DESCRIPTION:
@@ -515,8 +529,12 @@ distutils-r1_run_phase() {
 
 	mkdir -p "${TMPDIR}" || die
 
+	eval "edefault() { distutils-r1_${1}; }"
+
 	"${@}"
 
+	unset -f edefault
+
 	if [[ ${DISTUTILS_IN_SOURCE_BUILD} && ! ${DISTUTILS_SINGLE_IMPL} ]]
 	then
 		popd >/dev/null || die
@@ -579,7 +597,11 @@ distutils-r1_src_prepare() {
 
 	# common preparations
 	if declare -f python_prepare_all >/dev/null; then
+		eval "edefault() { distutils-r1_python_prepare_all; }"
+
 		python_prepare_all
+
+		unset -f edefault
 	else
 		distutils-r1_python_prepare_all
 	fi
-- 
1.8.2.1



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

* [gentoo-dev] Re: [PATCH FIXED] Introduce edefault() as a friendly default sub-phase wrapper.
  2013-05-11  9:30   ` [gentoo-dev] [PATCH FIXED] " Michał Górny
@ 2013-05-11 15:51     ` Mike Gilbert
  2013-05-11 16:35       ` Michał Górny
  2013-05-11 16:41       ` Ralph Sennhauser
  0 siblings, 2 replies; 8+ messages in thread
From: Mike Gilbert @ 2013-05-11 15:51 UTC (permalink / raw
  To: Gentoo Dev

On Sat, May 11, 2013 at 5:30 AM, Michał Górny <mgorny@gentoo.org> wrote:
> Fixed naming the proper default sub-phase and declaring 'edefault'
> in python_prepare_all().
> ---

I think I prefer to explicitly name the function I want to call, so I
don't really see any great benefit here. I'm not strongly opposed to
it, but I don't see myself using it either.

Also, how would this interact with other eclasses which may define a
similar "edefault" function? Packages using distutils-r1 don't often
utilize other phase-happy eclasses, but I'm sure it will happen
eventually.


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

* Re: [gentoo-dev] Re: [PATCH FIXED] Introduce edefault() as a friendly default sub-phase wrapper.
  2013-05-11 15:51     ` [gentoo-dev] " Mike Gilbert
@ 2013-05-11 16:35       ` Michał Górny
  2013-05-11 16:41       ` Ralph Sennhauser
  1 sibling, 0 replies; 8+ messages in thread
From: Michał Górny @ 2013-05-11 16:35 UTC (permalink / raw
  To: gentoo-dev; +Cc: floppym

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

On Sat, 11 May 2013 11:51:39 -0400
Mike Gilbert <floppym@gentoo.org> wrote:

> On Sat, May 11, 2013 at 5:30 AM, Michał Górny <mgorny@gentoo.org> wrote:
> > Fixed naming the proper default sub-phase and declaring 'edefault'
> > in python_prepare_all().
> > ---
> 
> I think I prefer to explicitly name the function I want to call, so I
> don't really see any great benefit here. I'm not strongly opposed to
> it, but I don't see myself using it either.
> 
> Also, how would this interact with other eclasses which may define a
> similar "edefault" function? Packages using distutils-r1 don't often
> utilize other phase-happy eclasses, but I'm sure it will happen
> eventually.

Well, the idea is that 'edefault' is defined by the eclass inventing
the particular sub-phase. So if sub-phase A calls sub-phase B
indirectly (trough the eclass and so on), edefault points to B
eventually.

Other thing would be, that after returning to A edefault will be no
longer defined. That's fixable though, if ever needed.

-- 
Best regards,
Michał Górny

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

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

* Re: [gentoo-dev] Re: [PATCH FIXED] Introduce edefault() as a friendly default sub-phase wrapper.
  2013-05-11 15:51     ` [gentoo-dev] " Mike Gilbert
  2013-05-11 16:35       ` Michał Górny
@ 2013-05-11 16:41       ` Ralph Sennhauser
  1 sibling, 0 replies; 8+ messages in thread
From: Ralph Sennhauser @ 2013-05-11 16:41 UTC (permalink / raw
  To: gentoo-dev

On Sat, 11 May 2013 11:51:39 -0400
Mike Gilbert <floppym@gentoo.org> wrote:

> On Sat, May 11, 2013 at 5:30 AM, Michał Górny <mgorny@gentoo.org>
> wrote:
> > Fixed naming the proper default sub-phase and declaring 'edefault'
> > in python_prepare_all().
> > ---
> 
> I think I prefer to explicitly name the function I want to call, so I
> don't really see any great benefit here. I'm not strongly opposed to
> it, but I don't see myself using it either.

Same here for the reason you mention below. Long term I expect it to be
more of a hassle than typing a few additional letters now.

> Also, how would this interact with other eclasses which may define a
> similar "edefault" function? Packages using distutils-r1 don't often
> utilize other phase-happy eclasses, but I'm sure it will happen
> eventually.
> 



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

* Re: [gentoo-dev] [PATCHES] distutils-r1: support 'edefault' in sub-phase functions
  2013-05-01 20:42 [gentoo-dev] [PATCHES] distutils-r1: support 'edefault' in sub-phase functions Michał Górny
  2013-05-01 20:42 ` [gentoo-dev] [PATCH 1/2] Introduce edefault() as a friendly default sub-phase wrapper Michał Górny
  2013-05-01 20:42 ` [gentoo-dev] [PATCH 2/2] Example use of edefault Michał Górny
@ 2013-05-15 19:03 ` Michał Górny
  2 siblings, 0 replies; 8+ messages in thread
From: Michał Górny @ 2013-05-15 19:03 UTC (permalink / raw
  To: gentoo-dev; +Cc: python

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

On Wed, 1 May 2013 22:42:05 +0200
Michał Górny <mgorny@gentoo.org> wrote:

> To make this more friendly, I would likely to locally introduce
> 'edefault' function in the eclass (name can change). The function would
> -- similarly to 'default' in regular phase functions -- call
> the default code for the sub-phase.

I've decided to withdraw the patch due to no interest from devs
in the feature. If anyone feels like it would be useful, we can get
back to it later.

-- 
Best regards,
Michał Górny

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

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

end of thread, other threads:[~2013-05-15 19:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-01 20:42 [gentoo-dev] [PATCHES] distutils-r1: support 'edefault' in sub-phase functions Michał Górny
2013-05-01 20:42 ` [gentoo-dev] [PATCH 1/2] Introduce edefault() as a friendly default sub-phase wrapper Michał Górny
2013-05-11  9:30   ` [gentoo-dev] [PATCH FIXED] " Michał Górny
2013-05-11 15:51     ` [gentoo-dev] " Mike Gilbert
2013-05-11 16:35       ` Michał Górny
2013-05-11 16:41       ` Ralph Sennhauser
2013-05-01 20:42 ` [gentoo-dev] [PATCH 2/2] Example use of edefault Michał Górny
2013-05-15 19:03 ` [gentoo-dev] [PATCHES] distutils-r1: support 'edefault' in sub-phase 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