public inbox for gentoo-python@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-python] [PATCH updated 1/3] Set env for best Python impl in *_all() phases.
@ 2012-12-03 11:00 Michał Górny
  2012-12-03 11:00 ` [gentoo-python] [PATCH updated 2/3] Don't rely on phase function return code Michał Górny
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Michał Górny @ 2012-12-03 11:00 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

Export the best implementation's build dir as BEST_BUILD_DIR, in order
to avoid clobbering original BUILD_DIR.
---
 gx86/eclass/distutils-r1.eclass | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index b1b3f90..db8fe86 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -388,6 +388,27 @@ distutils-r1_run_phase() {
 	if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
 		popd &>/dev/null || die
 	fi
+
+	# Store them for reuse.
+	_DISTUTILS_BEST_IMPL=(
+		"${EPYTHON}" "${PYTHON}" "${BUILD_DIR}" "${PYTHONPATH}"
+	)
+}
+
+# @FUNCTION: _distutils-r1_run_common_phase
+# @USAGE: [<argv>...]
+# @INTERNAL
+# @DESCRIPTION:
+# Run the given command, restoring the best-implementation state.
+_distutils-r1_run_common_phase() {
+	local EPYTHON=${_DISTUTILS_BEST_IMPL[0]}
+	local PYTHON=${_DISTUTILS_BEST_IMPL[1]}
+	local BEST_BUILD_DIR=${_DISTUTILS_BEST_IMPL[2]}
+	local PYTHONPATH=${_DISTUTILS_BEST_IMPL[3]}
+
+	export EPYTHON PYTHON PYTHONPATH
+
+	"${@}"
 }
 
 distutils-r1_src_prepare() {
@@ -419,7 +440,7 @@ distutils-r1_src_configure() {
 	multijob_finish
 
 	if declare -f python_configure_all >/dev/null; then
-		python_configure_all
+		_distutils-r1_run_common_phase python_configure_all
 	fi
 }
 
@@ -435,7 +456,7 @@ distutils-r1_src_compile() {
 	multijob_finish
 
 	if declare -f python_compile_all >/dev/null; then
-		python_compile_all
+		_distutils-r1_run_common_phase python_compile_all
 	fi
 }
 
@@ -451,7 +472,7 @@ distutils-r1_src_test() {
 	multijob_finish
 
 	if declare -f python_test_all >/dev/null; then
-		python_test_all
+		_distutils-r1_run_common_phase python_test_all
 	fi
 }
 
@@ -467,9 +488,9 @@ distutils-r1_src_install() {
 	multijob_finish
 
 	if declare -f python_install_all >/dev/null; then
-		python_install_all
+		_distutils-r1_run_common_phase python_install_all
 	else
-		distutils-r1_python_install_all
+		_distutils-r1_run_common_phase distutils-r1_python_install_all
 	fi
 }
 
-- 
1.8.0



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

* [gentoo-python] [PATCH updated 2/3] Don't rely on phase function return code.
  2012-12-03 11:00 [gentoo-python] [PATCH updated 1/3] Set env for best Python impl in *_all() phases Michał Górny
@ 2012-12-03 11:00 ` Michał Górny
  2012-12-03 11:00 ` [gentoo-python] [PATCH updated 3/3] Example benefit of those changes Michał Górny
  2012-12-03 15:46 ` [gentoo-python] Re: [PATCH updated 1/3] Set env for best Python impl in *_all() phases Mike Gilbert
  2 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2012-12-03 11:00 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

It prohibits constructs like 'use x && y', and is not really necessary
when '|| die' should be used there anyway.
---
 gx86/eclass/distutils-r1.eclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index db8fe86..a490252 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -380,9 +380,9 @@ distutils-r1_run_phase() {
 	fi
 
 	if [[ ${DISTUTILS_NO_PARALLEL_BUILD} ]]; then
-		"${@}" || die "${1} failed."
+		"${@}"
 	else
-		multijob_child_init "${@}" || die "${1} failed."
+		multijob_child_init "${@}"
 	fi
 
 	if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
-- 
1.8.0



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

* [gentoo-python] [PATCH updated 3/3] Example benefit of those changes.
  2012-12-03 11:00 [gentoo-python] [PATCH updated 1/3] Set env for best Python impl in *_all() phases Michał Górny
  2012-12-03 11:00 ` [gentoo-python] [PATCH updated 2/3] Don't rely on phase function return code Michał Górny
@ 2012-12-03 11:00 ` Michał Górny
  2012-12-03 15:46 ` [gentoo-python] Re: [PATCH updated 1/3] Set env for best Python impl in *_all() phases Mike Gilbert
  2 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2012-12-03 11:00 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

---
 gx86/dev-python/pytest/pytest-2.3.3-r1.ebuild | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/gx86/dev-python/pytest/pytest-2.3.3-r1.ebuild b/gx86/dev-python/pytest/pytest-2.3.3-r1.ebuild
index decab54..2c4d7f2 100644
--- a/gx86/dev-python/pytest/pytest-2.3.3-r1.ebuild
+++ b/gx86/dev-python/pytest/pytest-2.3.3-r1.ebuild
@@ -37,14 +37,7 @@ python_prepare_all() {
 }
 
 python_compile_all() {
-	if use doc; then
-		python_export_best EPYTHON
-
-		local PYTHONPATH=${S}/doc:${S}-${EPYTHON}/lib
-		export PYTHONPATH
-
-		emake -C doc/en html
-	fi
+	use doc && emake -C doc/en html
 }
 
 python_test() {
-- 
1.8.0



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

* [gentoo-python] Re: [PATCH updated 1/3] Set env for best Python impl in *_all() phases.
  2012-12-03 11:00 [gentoo-python] [PATCH updated 1/3] Set env for best Python impl in *_all() phases Michał Górny
  2012-12-03 11:00 ` [gentoo-python] [PATCH updated 2/3] Don't rely on phase function return code Michał Górny
  2012-12-03 11:00 ` [gentoo-python] [PATCH updated 3/3] Example benefit of those changes Michał Górny
@ 2012-12-03 15:46 ` Mike Gilbert
  2012-12-03 18:52   ` Michał Górny
  2 siblings, 1 reply; 5+ messages in thread
From: Mike Gilbert @ 2012-12-03 15:46 UTC (permalink / raw
  To: Michał Górny; +Cc: gentoo-python, python

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

On 12/3/2012 6:00 AM, Michał Górny wrote:
> Export the best implementation's build dir as BEST_BUILD_DIR, in order
> to avoid clobbering original BUILD_DIR.
> ---
>  gx86/eclass/distutils-r1.eclass | 31 ++++++++++++++++++++++++++-----
>  1 file changed, 26 insertions(+), 5 deletions(-)
> 
> diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
> index b1b3f90..db8fe86 100644
> --- a/gx86/eclass/distutils-r1.eclass
> +++ b/gx86/eclass/distutils-r1.eclass
> @@ -388,6 +388,27 @@ distutils-r1_run_phase() {
>  	if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
>  		popd &>/dev/null || die
>  	fi
> +
> +	# Store them for reuse.
> +	_DISTUTILS_BEST_IMPL=(
> +		"${EPYTHON}" "${PYTHON}" "${BUILD_DIR}" "${PYTHONPATH}"
> +	)

Why are you using an array here? To save 1 line of code?

Putting the values in an array makes them anonymous for no reason I can see.

> +}
> +
> +# @FUNCTION: _distutils-r1_run_common_phase
> +# @USAGE: [<argv>...]
> +# @INTERNAL
> +# @DESCRIPTION:
> +# Run the given command, restoring the best-implementation state.
> +_distutils-r1_run_common_phase() {
> +	local EPYTHON=${_DISTUTILS_BEST_IMPL[0]}
> +	local PYTHON=${_DISTUTILS_BEST_IMPL[1]}
> +	local BEST_BUILD_DIR=${_DISTUTILS_BEST_IMPL[2]}
> +	local PYTHONPATH=${_DISTUTILS_BEST_IMPL[3]}
> +
> +	export EPYTHON PYTHON PYTHONPATH
> +
> +	"${@}"
>  }
>  
>  distutils-r1_src_prepare() {
> @@ -419,7 +440,7 @@ distutils-r1_src_configure() {
>  	multijob_finish
>  
>  	if declare -f python_configure_all >/dev/null; then
> -		python_configure_all
> +		_distutils-r1_run_common_phase python_configure_all
>  	fi
>  }
>  
> @@ -435,7 +456,7 @@ distutils-r1_src_compile() {
>  	multijob_finish
>  
>  	if declare -f python_compile_all >/dev/null; then
> -		python_compile_all
> +		_distutils-r1_run_common_phase python_compile_all
>  	fi
>  }
>  
> @@ -451,7 +472,7 @@ distutils-r1_src_test() {
>  	multijob_finish
>  
>  	if declare -f python_test_all >/dev/null; then
> -		python_test_all
> +		_distutils-r1_run_common_phase python_test_all
>  	fi
>  }
>  
> @@ -467,9 +488,9 @@ distutils-r1_src_install() {
>  	multijob_finish
>  
>  	if declare -f python_install_all >/dev/null; then
> -		python_install_all
> +		_distutils-r1_run_common_phase python_install_all
>  	else
> -		distutils-r1_python_install_all
> +		_distutils-r1_run_common_phase distutils-r1_python_install_all
>  	fi
>  }
>  

I haven't run into a situation that patch series is intended to address,
so I don't have any strong opinion on it. If you think it is useful,
fine by me.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [gentoo-python] Re: [PATCH updated 1/3] Set env for best Python impl in *_all() phases.
  2012-12-03 15:46 ` [gentoo-python] Re: [PATCH updated 1/3] Set env for best Python impl in *_all() phases Mike Gilbert
@ 2012-12-03 18:52   ` Michał Górny
  0 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2012-12-03 18:52 UTC (permalink / raw
  To: Mike Gilbert; +Cc: gentoo-python, python

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

On Mon, 03 Dec 2012 10:46:42 -0500
Mike Gilbert <floppym@gentoo.org> wrote:

> On 12/3/2012 6:00 AM, Michał Górny wrote:
> > Export the best implementation's build dir as BEST_BUILD_DIR, in order
> > to avoid clobbering original BUILD_DIR.
> > ---
> >  gx86/eclass/distutils-r1.eclass | 31 ++++++++++++++++++++++++++-----
> >  1 file changed, 26 insertions(+), 5 deletions(-)
> > 
> > diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
> > index b1b3f90..db8fe86 100644
> > --- a/gx86/eclass/distutils-r1.eclass
> > +++ b/gx86/eclass/distutils-r1.eclass
> > @@ -388,6 +388,27 @@ distutils-r1_run_phase() {
> >  	if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
> >  		popd &>/dev/null || die
> >  	fi
> > +
> > +	# Store them for reuse.
> > +	_DISTUTILS_BEST_IMPL=(
> > +		"${EPYTHON}" "${PYTHON}" "${BUILD_DIR}" "${PYTHONPATH}"
> > +	)
> 
> Why are you using an array here? To save 1 line of code?

Yes, something like that. Plus do not have to invent names for all
of them.

> Putting the values in an array makes them anonymous for no reason I can see.

To be honest, I don't see a reason for them to be non-anonymous. It's
not something user should touch. A bit like four variables == four
times as much risk of random collision.

> > +}
> > +
> > +# @FUNCTION: _distutils-r1_run_common_phase
> > +# @USAGE: [<argv>...]
> > +# @INTERNAL
> > +# @DESCRIPTION:
> > +# Run the given command, restoring the best-implementation state.
> > +_distutils-r1_run_common_phase() {
> > +	local EPYTHON=${_DISTUTILS_BEST_IMPL[0]}
> > +	local PYTHON=${_DISTUTILS_BEST_IMPL[1]}
> > +	local BEST_BUILD_DIR=${_DISTUTILS_BEST_IMPL[2]}
> > +	local PYTHONPATH=${_DISTUTILS_BEST_IMPL[3]}
> > +
> > +	export EPYTHON PYTHON PYTHONPATH
> > +
> > +	"${@}"
> >  }
> >  
> >  distutils-r1_src_prepare() {
> > @@ -419,7 +440,7 @@ distutils-r1_src_configure() {
> >  	multijob_finish
> >  
> >  	if declare -f python_configure_all >/dev/null; then
> > -		python_configure_all
> > +		_distutils-r1_run_common_phase python_configure_all
> >  	fi
> >  }
> >  
> > @@ -435,7 +456,7 @@ distutils-r1_src_compile() {
> >  	multijob_finish
> >  
> >  	if declare -f python_compile_all >/dev/null; then
> > -		python_compile_all
> > +		_distutils-r1_run_common_phase python_compile_all
> >  	fi
> >  }
> >  
> > @@ -451,7 +472,7 @@ distutils-r1_src_test() {
> >  	multijob_finish
> >  
> >  	if declare -f python_test_all >/dev/null; then
> > -		python_test_all
> > +		_distutils-r1_run_common_phase python_test_all
> >  	fi
> >  }
> >  
> > @@ -467,9 +488,9 @@ distutils-r1_src_install() {
> >  	multijob_finish
> >  
> >  	if declare -f python_install_all >/dev/null; then
> > -		python_install_all
> > +		_distutils-r1_run_common_phase python_install_all
> >  	else
> > -		distutils-r1_python_install_all
> > +		_distutils-r1_run_common_phase distutils-r1_python_install_all
> >  	fi
> >  }
> >  
> 
> I haven't run into a situation that patch series is intended to address,
> so I don't have any strong opinion on it. If you think it is useful,
> fine by me.

Well, the common case I can think of is building docs. Although it
isn't really necessary to bind that strongly to any specific
implementation, doing so allows packages to use compiled modules.

-- 
Best regards,
Michał Górny

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

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

end of thread, other threads:[~2012-12-03 18:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-03 11:00 [gentoo-python] [PATCH updated 1/3] Set env for best Python impl in *_all() phases Michał Górny
2012-12-03 11:00 ` [gentoo-python] [PATCH updated 2/3] Don't rely on phase function return code Michał Górny
2012-12-03 11:00 ` [gentoo-python] [PATCH updated 3/3] Example benefit of those changes Michał Górny
2012-12-03 15:46 ` [gentoo-python] Re: [PATCH updated 1/3] Set env for best Python impl in *_all() phases Mike Gilbert
2012-12-03 18:52   ` 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