public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCHSET python-utils-r1] python & python-config wrapper cleanup
@ 2015-07-25 10:37 Michał Górny
  2015-07-25 10:37 ` [gentoo-dev] [PATCH python-utils-r1 1/4] Use shell wrappers instead of symlinks for python{,-config} Michał Górny
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Michał Górny @ 2015-07-25 10:37 UTC (permalink / raw
  To: gentoo-dev; +Cc: python

Hi,

A small batch of patches intended to improve & fix
python_wrapper_setup(), pretty much thanks to perfinion.

Long story short, he noticed two issues:

1. we are missing pythonN-config, both in wrappers and in eselect-python
(addressed by patch 2),

2. since python3.4, some symlink reading magic is applied that causes
python to use wrong prefixes if python-config is symlinked somewhere
(addressed by patch 1).

While at it, I also added some 'unsupported' wrappers to ban trying to
use pythonY (accidental fallback to system python) when pythonX is
selected via wrapper, and changed the exit code for unsupp-scripts.

Patches 1 & 4 should be harmless.

Patch 2 should not cause issues either. Some scripts may start using
pythonN-config when they used to fallback to python-config. However,
fixing eselect-python side of this may actually cause issues if this
causes configure scripts to prefer python3-config over wrapped
python2-config. Patch 3 addresses this.

Patch 3 is going to cause issues if configure scripts look for
pythonN-config before python-config. For example, in python2.7 they are
going to find python3-config and try (and fail) to use that, while right
now they falled back to python-config. However, the worse would happen
if we fixed eselect-python without committing this patch first.



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

* [gentoo-dev] [PATCH python-utils-r1 1/4] Use shell wrappers instead of symlinks for python{,-config}
  2015-07-25 10:37 [gentoo-dev] [PATCHSET python-utils-r1] python & python-config wrapper cleanup Michał Górny
@ 2015-07-25 10:37 ` Michał Górny
  2015-07-26 15:09   ` [gentoo-dev] " Mike Gilbert
  2015-07-25 10:37 ` [gentoo-dev] [PATCH python-utils-r1 2/4] Wrap pythonN-config as well Michał Górny
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 17+ messages in thread
From: Michał Górny @ 2015-07-25 10:37 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, Michał Górny

Use shell wrappers to spawn python & python-config instead of symlinks
to fix magic applied by Python 3.4+ to symlinks.

Fixes: https://bugs.gentoo.org/show_bug.cgi?id=555752
---
 eclass/python-utils-r1.eclass | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index a292179..c1c5ea6 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -855,14 +855,25 @@ python_wrapper_setup() {
 		fi
 
 		# Python interpreter
-		ln -s "${PYTHON}" "${workdir}"/bin/python || die
-		ln -s python "${workdir}"/bin/python${pyver} || die
+		# note: we don't use symlinks because python likes to do some
+		# symlink reading magic that breaks stuff
+		# https://bugs.gentoo.org/show_bug.cgi?id=555752
+		cat > "${workdir}/bin/python" <<-_EOF_
+			#!/bin/sh
+			exec "${PYTHON}" "\${@}"
+		_EOF_
+		cp "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die
+		chmod +x "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die
 
 		local nonsupp=()
 
 		# CPython-specific
 		if [[ ${EPYTHON} == python* ]]; then
-			ln -s "${PYTHON}-config" "${workdir}"/bin/python-config || die
+			cat > "${workdir}/bin/python-config" <<-_EOF_
+				#!/bin/sh
+				exec "${PYTHON}-config" "\${@}"
+			_EOF_
+			chmod +x "${workdir}/bin/python-config" || die
 
 			# Python 2.6+.
 			ln -s "${PYTHON/python/2to3-}" "${workdir}"/bin/2to3 || die
-- 
2.4.6



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

* [gentoo-dev] [PATCH python-utils-r1 2/4] Wrap pythonN-config as well
  2015-07-25 10:37 [gentoo-dev] [PATCHSET python-utils-r1] python & python-config wrapper cleanup Michał Górny
  2015-07-25 10:37 ` [gentoo-dev] [PATCH python-utils-r1 1/4] Use shell wrappers instead of symlinks for python{,-config} Michał Górny
@ 2015-07-25 10:37 ` Michał Górny
  2015-07-25 14:12   ` Jason Zaman
  2015-07-25 10:37 ` [gentoo-dev] [PATCH python-utils-r1 3/4] Ban calling pythonY and pythonY-config when pythonX is used Michał Górny
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 17+ messages in thread
From: Michał Górny @ 2015-07-25 10:37 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, Michał Górny

Fixes: https://bugs.gentoo.org/show_bug.cgi?id=555594
---
 eclass/python-utils-r1.eclass | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index c1c5ea6..69d3262 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -873,7 +873,10 @@ python_wrapper_setup() {
 				#!/bin/sh
 				exec "${PYTHON}-config" "\${@}"
 			_EOF_
-			chmod +x "${workdir}/bin/python-config" || die
+			cp "${workdir}/bin/python-config" \
+				"${workdir}/bin/python${pyver}-config" || die
+			chmod +x "${workdir}/bin/python-config" \
+				"${workdir}/bin/python${pyver}-config" || die
 
 			# Python 2.6+.
 			ln -s "${PYTHON/python/2to3-}" "${workdir}"/bin/2to3 || die
@@ -883,7 +886,7 @@ python_wrapper_setup() {
 				"${workdir}"/pkgconfig/python.pc || die
 			ln -s python.pc "${workdir}"/pkgconfig/python${pyver}.pc || die
 		else
-			nonsupp+=( 2to3 python-config )
+			nonsupp+=( 2to3 python-config "python${pyver}-config" )
 		fi
 
 		local x
-- 
2.4.6



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

* [gentoo-dev] [PATCH python-utils-r1 3/4] Ban calling pythonY and pythonY-config when pythonX is used
  2015-07-25 10:37 [gentoo-dev] [PATCHSET python-utils-r1] python & python-config wrapper cleanup Michał Górny
  2015-07-25 10:37 ` [gentoo-dev] [PATCH python-utils-r1 1/4] Use shell wrappers instead of symlinks for python{,-config} Michał Górny
  2015-07-25 10:37 ` [gentoo-dev] [PATCH python-utils-r1 2/4] Wrap pythonN-config as well Michał Górny
@ 2015-07-25 10:37 ` Michał Górny
  2015-07-25 14:25   ` Jason Zaman
  2015-07-26 15:14   ` [gentoo-dev] " Mike Gilbert
  2015-07-25 10:37 ` [gentoo-dev] [PATCH python-utils-r1 4/4] Exit with 127 when banned command is called Michał Górny
  2015-07-25 11:37 ` [gentoo-dev] [PATCHSET python-utils-r1] python & python-config wrapper cleanup Davide Pesavento
  4 siblings, 2 replies; 17+ messages in thread
From: Michał Górny @ 2015-07-25 10:37 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, Michał Górny

Ban calling python3{,-config} when python2 is used, and the other way
around. While this will not prevent configure scripts from finding the
other Python version, it will cause them to fail eventually trying to
use it. Currently those attempt were able to pass through thanks to
python-config providing python{2,3} symlinks.
---
 eclass/python-utils-r1.eclass | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 69d3262..2584f3e 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -847,11 +847,13 @@ python_wrapper_setup() {
 		local EPYTHON PYTHON
 		python_export "${impl}" EPYTHON PYTHON
 
-		local pyver
+		local pyver pyother
 		if python_is_python3; then
 			pyver=3
+			pyother=2
 		else
 			pyver=2
+			pyother=3
 		fi
 
 		# Python interpreter
@@ -865,7 +867,7 @@ python_wrapper_setup() {
 		cp "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die
 		chmod +x "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die
 
-		local nonsupp=()
+		local nonsupp=( "python${pyother}" "python${pyother}-config" )
 
 		# CPython-specific
 		if [[ ${EPYTHON} == python* ]]; then
-- 
2.4.6



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

* [gentoo-dev] [PATCH python-utils-r1 4/4] Exit with 127 when banned command is called
  2015-07-25 10:37 [gentoo-dev] [PATCHSET python-utils-r1] python & python-config wrapper cleanup Michał Górny
                   ` (2 preceding siblings ...)
  2015-07-25 10:37 ` [gentoo-dev] [PATCH python-utils-r1 3/4] Ban calling pythonY and pythonY-config when pythonX is used Michał Górny
@ 2015-07-25 10:37 ` Michał Górny
  2015-07-25 11:37 ` [gentoo-dev] [PATCHSET python-utils-r1] python & python-config wrapper cleanup Davide Pesavento
  4 siblings, 0 replies; 17+ messages in thread
From: Michał Górny @ 2015-07-25 10:37 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, Michał Górny

Exit with code 127 (used by shell as 'command not found') when banned
command is used. Probably doesn't make any difference but looks nicer.
---
 eclass/python-utils-r1.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 2584f3e..5944f03 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -896,7 +896,7 @@ python_wrapper_setup() {
 			cat >"${workdir}"/bin/${x} <<__EOF__
 #!/bin/sh
 echo "${x} is not supported by ${EPYTHON}" >&2
-exit 1
+exit 127
 __EOF__
 			chmod +x "${workdir}"/bin/${x} || die
 		done
-- 
2.4.6



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

* Re: [gentoo-dev] [PATCHSET python-utils-r1] python & python-config wrapper cleanup
  2015-07-25 10:37 [gentoo-dev] [PATCHSET python-utils-r1] python & python-config wrapper cleanup Michał Górny
                   ` (3 preceding siblings ...)
  2015-07-25 10:37 ` [gentoo-dev] [PATCH python-utils-r1 4/4] Exit with 127 when banned command is called Michał Górny
@ 2015-07-25 11:37 ` Davide Pesavento
  2015-07-25 12:03   ` Michał Górny
  4 siblings, 1 reply; 17+ messages in thread
From: Davide Pesavento @ 2015-07-25 11:37 UTC (permalink / raw
  To: gentoo-dev; +Cc: python

On Sat, Jul 25, 2015 at 12:37 PM, Michał Górny <mgorny@gentoo.org> wrote:
> While at it, I also added some 'unsupported' wrappers to ban trying to
> use pythonY (accidental fallback to system python) when pythonX is
> selected via wrapper, and changed the exit code for unsupp-scripts.

Can you clarify the consequences of this change please? e.g. is it
still possible to call "naked" python2 from src_prepare() of a package
using python-r1.eclass, such as dev-python/sip?

Thanks,
Davide


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

* Re: [gentoo-dev] [PATCHSET python-utils-r1] python & python-config wrapper cleanup
  2015-07-25 11:37 ` [gentoo-dev] [PATCHSET python-utils-r1] python & python-config wrapper cleanup Davide Pesavento
@ 2015-07-25 12:03   ` Michał Górny
  2015-07-25 12:24     ` Davide Pesavento
  0 siblings, 1 reply; 17+ messages in thread
From: Michał Górny @ 2015-07-25 12:03 UTC (permalink / raw
  To: Davide Pesavento; +Cc: gentoo-dev, python

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

Dnia 2015-07-25, o godz. 13:37:03
Davide Pesavento <pesa@gentoo.org> napisał(a):

> On Sat, Jul 25, 2015 at 12:37 PM, Michał Górny <mgorny@gentoo.org> wrote:
> > While at it, I also added some 'unsupported' wrappers to ban trying to
> > use pythonY (accidental fallback to system python) when pythonX is
> > selected via wrapper, and changed the exit code for unsupp-scripts.
> 
> Can you clarify the consequences of this change please? e.g. is it
> still possible to call "naked" python2 from src_prepare() of a package
> using python-r1.eclass, such as dev-python/sip?

If you call python_setup and ensure python2 is selected beforehand,
yes. Otherwise, you're doing a QA violation and it never were supported.

-- 
Best regards,
Michał Górny
<http://dev.gentoo.org/~mgorny/>

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

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

* Re: [gentoo-dev] [PATCHSET python-utils-r1] python & python-config wrapper cleanup
  2015-07-25 12:03   ` Michał Górny
@ 2015-07-25 12:24     ` Davide Pesavento
  2015-07-25 12:48       ` Michał Górny
  0 siblings, 1 reply; 17+ messages in thread
From: Davide Pesavento @ 2015-07-25 12:24 UTC (permalink / raw
  To: Michał Górny; +Cc: gentoo-dev, python

On Sat, Jul 25, 2015 at 2:03 PM, Michał Górny <mgorny@gentoo.org> wrote:
> Dnia 2015-07-25, o godz. 13:37:03
> Davide Pesavento <pesa@gentoo.org> napisał(a):
>
>> On Sat, Jul 25, 2015 at 12:37 PM, Michał Górny <mgorny@gentoo.org> wrote:
>> > While at it, I also added some 'unsupported' wrappers to ban trying to
>> > use pythonY (accidental fallback to system python) when pythonX is
>> > selected via wrapper, and changed the exit code for unsupp-scripts.
>>
>> Can you clarify the consequences of this change please? e.g. is it
>> still possible to call "naked" python2 from src_prepare() of a package
>> using python-r1.eclass, such as dev-python/sip?
>
> If you call python_setup and ensure python2 is selected beforehand,
> yes. Otherwise, you're doing a QA violation and it never were supported.
>

Funny. I'm pretty sure you suggested the current implementation
(directly calling python2) when we first switched to
python-r1.eclass...


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

* Re: [gentoo-dev] [PATCHSET python-utils-r1] python & python-config wrapper cleanup
  2015-07-25 12:24     ` Davide Pesavento
@ 2015-07-25 12:48       ` Michał Górny
  2015-07-26  0:16         ` Davide Pesavento
  0 siblings, 1 reply; 17+ messages in thread
From: Michał Górny @ 2015-07-25 12:48 UTC (permalink / raw
  To: Davide Pesavento; +Cc: gentoo-dev, python

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

Dnia 2015-07-25, o godz. 14:24:27
Davide Pesavento <pesa@gentoo.org> napisał(a):

> On Sat, Jul 25, 2015 at 2:03 PM, Michał Górny <mgorny@gentoo.org> wrote:
> > Dnia 2015-07-25, o godz. 13:37:03
> > Davide Pesavento <pesa@gentoo.org> napisał(a):
> >
> >> On Sat, Jul 25, 2015 at 12:37 PM, Michał Górny <mgorny@gentoo.org> wrote:
> >> > While at it, I also added some 'unsupported' wrappers to ban trying to
> >> > use pythonY (accidental fallback to system python) when pythonX is
> >> > selected via wrapper, and changed the exit code for unsupp-scripts.
> >>
> >> Can you clarify the consequences of this change please? e.g. is it
> >> still possible to call "naked" python2 from src_prepare() of a package
> >> using python-r1.eclass, such as dev-python/sip?
> >
> > If you call python_setup and ensure python2 is selected beforehand,
> > yes. Otherwise, you're doing a QA violation and it never were supported.
> >
> 
> Funny. I'm pretty sure you suggested the current implementation
> (directly calling python2) when we first switched to
> python-r1.eclass...

Nope. I'm pretty sure I never suggested or accepted any kind of direct
dev-lang/python dependencies or python[23] calls.

-- 
Best regards,
Michał Górny
<http://dev.gentoo.org/~mgorny/>

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

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

* Re: [gentoo-dev] [PATCH python-utils-r1 2/4] Wrap pythonN-config as well
  2015-07-25 10:37 ` [gentoo-dev] [PATCH python-utils-r1 2/4] Wrap pythonN-config as well Michał Górny
@ 2015-07-25 14:12   ` Jason Zaman
  2015-07-25 15:26     ` Jason Zaman
  0 siblings, 1 reply; 17+ messages in thread
From: Jason Zaman @ 2015-07-25 14:12 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, Michał Górny

On Sat, Jul 25, 2015 at 12:37:42PM +0200, Michał Górny wrote:
> Fixes: https://bugs.gentoo.org/show_bug.cgi?id=555594
> ---
>  eclass/python-utils-r1.eclass | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
> index c1c5ea6..69d3262 100644
> --- a/eclass/python-utils-r1.eclass
> +++ b/eclass/python-utils-r1.eclass
> @@ -873,7 +873,10 @@ python_wrapper_setup() {
>  				#!/bin/sh
>  				exec "${PYTHON}-config" "\${@}"
>  			_EOF_
> -			chmod +x "${workdir}/bin/python-config" || die
> +			cp "${workdir}/bin/python-config" \
> +				"${workdir}/bin/python${pyver}-config" || die
> +			chmod +x "${workdir}/bin/python-config" \
> +				"${workdir}/bin/python${pyver}-config" || die

This could alternatively be python as a symlink -> python3 which is the
wrapper, but I dont think having two wrappers vs symlink to a wrapper
makes any real difference.
>  
>  			# Python 2.6+.
>  			ln -s "${PYTHON/python/2to3-}" "${workdir}"/bin/2to3 || die
> @@ -883,7 +886,7 @@ python_wrapper_setup() {
>  				"${workdir}"/pkgconfig/python.pc || die
>  			ln -s python.pc "${workdir}"/pkgconfig/python${pyver}.pc || die
>  		else
> -			nonsupp+=( 2to3 python-config )
> +			nonsupp+=( 2to3 python-config "python${pyver}-config" )

This should be both 2 and 3, if its not CPython, neither should be
allowed, this bans only $pyver.


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

* Re: [gentoo-dev] [PATCH python-utils-r1 3/4] Ban calling pythonY and pythonY-config when pythonX is used
  2015-07-25 10:37 ` [gentoo-dev] [PATCH python-utils-r1 3/4] Ban calling pythonY and pythonY-config when pythonX is used Michał Górny
@ 2015-07-25 14:25   ` Jason Zaman
  2015-07-25 15:46     ` Michał Górny
  2015-07-26 15:14   ` [gentoo-dev] " Mike Gilbert
  1 sibling, 1 reply; 17+ messages in thread
From: Jason Zaman @ 2015-07-25 14:25 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, Michał Górny

On Sat, Jul 25, 2015 at 12:37:43PM +0200, Michał Górny wrote:
> Ban calling python3{,-config} when python2 is used, and the other way
> around. While this will not prevent configure scripts from finding the
> other Python version, it will cause them to fail eventually trying to
> use it. Currently those attempt were able to pass through thanks to
> python-config providing python{2,3} symlinks.

you mean eselect providing.

> ---
>  eclass/python-utils-r1.eclass | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
> index 69d3262..2584f3e 100644
> --- a/eclass/python-utils-r1.eclass
> +++ b/eclass/python-utils-r1.eclass
> @@ -847,11 +847,13 @@ python_wrapper_setup() {
>  		local EPYTHON PYTHON
>  		python_export "${impl}" EPYTHON PYTHON
>  
> -		local pyver
> +		local pyver pyother
>  		if python_is_python3; then
>  			pyver=3
> +			pyother=2
>  		else
>  			pyver=2
> +			pyother=3
>  		fi
>  
>  		# Python interpreter
> @@ -865,7 +867,7 @@ python_wrapper_setup() {
>  		cp "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die
>  		chmod +x "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die
>  
> -		local nonsupp=()
> +		local nonsupp=( "python${pyother}" "python${pyother}-config" )

I have had basically this exact patch locally for a few days since we
talked about it and it hasnt been a problem yet but is not very much
testing. I was wondering if perhaps this should be a qawarn for a while
first instead of banning immediately?

>  		# CPython-specific
>  		if [[ ${EPYTHON} == python* ]]; then
> -- 
> 2.4.6


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

* Re: [gentoo-dev] [PATCH python-utils-r1 2/4] Wrap pythonN-config as well
  2015-07-25 14:12   ` Jason Zaman
@ 2015-07-25 15:26     ` Jason Zaman
  0 siblings, 0 replies; 17+ messages in thread
From: Jason Zaman @ 2015-07-25 15:26 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, Michał Górny

On Sat, Jul 25, 2015 at 10:12:48PM +0800, Jason Zaman wrote:
> On Sat, Jul 25, 2015 at 12:37:42PM +0200, Michał Górny wrote:
> > Fixes: https://bugs.gentoo.org/show_bug.cgi?id=555594
> > ---
> >  eclass/python-utils-r1.eclass | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
> > index c1c5ea6..69d3262 100644
> > --- a/eclass/python-utils-r1.eclass
> > +++ b/eclass/python-utils-r1.eclass
> > @@ -873,7 +873,10 @@ python_wrapper_setup() {
> >  				#!/bin/sh
> >  				exec "${PYTHON}-config" "\${@}"
> >  			_EOF_
> > -			chmod +x "${workdir}/bin/python-config" || die
> > +			cp "${workdir}/bin/python-config" \
> > +				"${workdir}/bin/python${pyver}-config" || die
> > +			chmod +x "${workdir}/bin/python-config" \
> > +				"${workdir}/bin/python${pyver}-config" || die
> 
> This could alternatively be python as a symlink -> python3 which is the
> wrapper, but I dont think having two wrappers vs symlink to a wrapper
> makes any real difference.
> >  
> >  			# Python 2.6+.
> >  			ln -s "${PYTHON/python/2to3-}" "${workdir}"/bin/2to3 || die
> > @@ -883,7 +886,7 @@ python_wrapper_setup() {
> >  				"${workdir}"/pkgconfig/python.pc || die
> >  			ln -s python.pc "${workdir}"/pkgconfig/python${pyver}.pc || die
> >  		else
> > -			nonsupp+=( 2to3 python-config )
> > +			nonsupp+=( 2to3 python-config "python${pyver}-config" )
> 
> This should be both 2 and 3, if its not CPython, neither should be
> allowed, this bans only $pyver.

The other patch adds $pyother earlier on, so this is correct. My
mistake.


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

* Re: [gentoo-dev] [PATCH python-utils-r1 3/4] Ban calling pythonY and pythonY-config when pythonX is used
  2015-07-25 14:25   ` Jason Zaman
@ 2015-07-25 15:46     ` Michał Górny
  0 siblings, 0 replies; 17+ messages in thread
From: Michał Górny @ 2015-07-25 15:46 UTC (permalink / raw
  To: Jason Zaman; +Cc: gentoo-dev, python

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

Dnia 2015-07-25, o godz. 22:25:57
Jason Zaman <perfinion@gentoo.org> napisał(a):

> On Sat, Jul 25, 2015 at 12:37:43PM +0200, Michał Górny wrote:
> > Ban calling python3{,-config} when python2 is used, and the other way
> > around. While this will not prevent configure scripts from finding the
> > other Python version, it will cause them to fail eventually trying to
> > use it. Currently those attempt were able to pass through thanks to
> > python-config providing python{2,3} symlinks.
> 
> you mean eselect providing.

Yes, you are correct.

> > ---
> >  eclass/python-utils-r1.eclass | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
> > index 69d3262..2584f3e 100644
> > --- a/eclass/python-utils-r1.eclass
> > +++ b/eclass/python-utils-r1.eclass
> > @@ -847,11 +847,13 @@ python_wrapper_setup() {
> >  		local EPYTHON PYTHON
> >  		python_export "${impl}" EPYTHON PYTHON
> >  
> > -		local pyver
> > +		local pyver pyother
> >  		if python_is_python3; then
> >  			pyver=3
> > +			pyother=2
> >  		else
> >  			pyver=2
> > +			pyother=3
> >  		fi
> >  
> >  		# Python interpreter
> > @@ -865,7 +867,7 @@ python_wrapper_setup() {
> >  		cp "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die
> >  		chmod +x "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die
> >  
> > -		local nonsupp=()
> > +		local nonsupp=( "python${pyother}" "python${pyother}-config" )
> 
> I have had basically this exact patch locally for a few days since we
> talked about it and it hasnt been a problem yet but is not very much
> testing. I was wondering if perhaps this should be a qawarn for a while
> first instead of banning immediately?

Well, the problem is that those wrappers are more likely to be called
indirectly than directly by ebuilds, so we'd need some hacky magic to
pass warnings from within the wrapper to the ebuild. It doesn't really
fit the eclass design to receive them afterwards.

> >  		# CPython-specific
> >  		if [[ ${EPYTHON} == python* ]]; then
> > -- 
> > 2.4.6

-- 
Best regards,
Michał Górny
<http://dev.gentoo.org/~mgorny/>

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

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

* Re: [gentoo-dev] [PATCHSET python-utils-r1] python & python-config wrapper cleanup
  2015-07-25 12:48       ` Michał Górny
@ 2015-07-26  0:16         ` Davide Pesavento
  0 siblings, 0 replies; 17+ messages in thread
From: Davide Pesavento @ 2015-07-26  0:16 UTC (permalink / raw
  To: Michał Górny; +Cc: gentoo-dev, python

On Sat, Jul 25, 2015 at 2:48 PM, Michał Górny <mgorny@gentoo.org> wrote:
> Dnia 2015-07-25, o godz. 14:24:27
> Davide Pesavento <pesa@gentoo.org> napisał(a):
>
>> On Sat, Jul 25, 2015 at 2:03 PM, Michał Górny <mgorny@gentoo.org> wrote:
>> > Dnia 2015-07-25, o godz. 13:37:03
>> > Davide Pesavento <pesa@gentoo.org> napisał(a):
>> >
>> >> On Sat, Jul 25, 2015 at 12:37 PM, Michał Górny <mgorny@gentoo.org> wrote:
>> >> > While at it, I also added some 'unsupported' wrappers to ban trying to
>> >> > use pythonY (accidental fallback to system python) when pythonX is
>> >> > selected via wrapper, and changed the exit code for unsupp-scripts.
>> >>
>> >> Can you clarify the consequences of this change please? e.g. is it
>> >> still possible to call "naked" python2 from src_prepare() of a package
>> >> using python-r1.eclass, such as dev-python/sip?
>> >
>> > If you call python_setup and ensure python2 is selected beforehand,
>> > yes. Otherwise, you're doing a QA violation and it never were supported.
>> >
>>
>> Funny. I'm pretty sure you suggested the current implementation
>> (directly calling python2) when we first switched to
>> python-r1.eclass...
>
> Nope. I'm pretty sure I never suggested or accepted any kind of direct
> dev-lang/python dependencies or python[23] calls.
>

Seriously, I'm not blaming you (or anybody else), but please just try
to be a little less arrogant and self-righteous in your emails. If you
don't believe me, look at your #gentoo-python logs around Jan 21,
2013. Also consider that python_setup was only introduced 9 months
after the conversion of dev-python/sip.

Anyway, I guess I have to fix sip-4.9999 then ;)

Thanks,
Davide


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

* [gentoo-dev] Re: [PATCH python-utils-r1 1/4] Use shell wrappers instead of symlinks for python{,-config}
  2015-07-25 10:37 ` [gentoo-dev] [PATCH python-utils-r1 1/4] Use shell wrappers instead of symlinks for python{,-config} Michał Górny
@ 2015-07-26 15:09   ` Mike Gilbert
  0 siblings, 0 replies; 17+ messages in thread
From: Mike Gilbert @ 2015-07-26 15:09 UTC (permalink / raw
  To: Michał Górny; +Cc: Gentoo Dev, Gentoo Python Project

On Sat, Jul 25, 2015 at 6:37 AM, Michał Górny <mgorny@gentoo.org> wrote:
> Use shell wrappers to spawn python & python-config instead of symlinks
> to fix magic applied by Python 3.4+ to symlinks.
>
> Fixes: https://bugs.gentoo.org/show_bug.cgi?id=555752

Looks ok to me.

The use of ${PYTHON} as a prefix for ${PYTHON}-config is somewhat
confusing at first glance, but the eclass seems to already use it that
way.


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

* [gentoo-dev] Re: [PATCH python-utils-r1 3/4] Ban calling pythonY and pythonY-config when pythonX is used
  2015-07-25 10:37 ` [gentoo-dev] [PATCH python-utils-r1 3/4] Ban calling pythonY and pythonY-config when pythonX is used Michał Górny
  2015-07-25 14:25   ` Jason Zaman
@ 2015-07-26 15:14   ` Mike Gilbert
  2015-07-26 21:46     ` Michał Górny
  1 sibling, 1 reply; 17+ messages in thread
From: Mike Gilbert @ 2015-07-26 15:14 UTC (permalink / raw
  To: Michał Górny; +Cc: Gentoo Dev, Gentoo Python Project

On Sat, Jul 25, 2015 at 6:37 AM, Michał Górny <mgorny@gentoo.org> wrote:
> Ban calling python3{,-config} when python2 is used, and the other way
> around. While this will not prevent configure scripts from finding the
> other Python version, it will cause them to fail eventually trying to
> use it. Currently those attempt were able to pass through thanks to
> python-config providing python{2,3} symlinks.

Do you anticipate this will break existing ebuilds then? It probably
makes sense, I just want to be prepared for any backlash or mass of
bugs.


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

* Re: [gentoo-dev] Re: [PATCH python-utils-r1 3/4] Ban calling pythonY and pythonY-config when pythonX is used
  2015-07-26 15:14   ` [gentoo-dev] " Mike Gilbert
@ 2015-07-26 21:46     ` Michał Górny
  0 siblings, 0 replies; 17+ messages in thread
From: Michał Górny @ 2015-07-26 21:46 UTC (permalink / raw
  To: Mike Gilbert; +Cc: Gentoo Dev, Gentoo Python Project

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

Dnia 2015-07-26, o godz. 11:14:50
Mike Gilbert <floppym@gentoo.org> napisał(a):

> On Sat, Jul 25, 2015 at 6:37 AM, Michał Górny <mgorny@gentoo.org> wrote:
> > Ban calling python3{,-config} when python2 is used, and the other way
> > around. While this will not prevent configure scripts from finding the
> > other Python version, it will cause them to fail eventually trying to
> > use it. Currently those attempt were able to pass through thanks to
> > python-config providing python{2,3} symlinks.
> 
> Do you anticipate this will break existing ebuilds then? It probably
> makes sense, I just want to be prepared for any backlash or mass of
> bugs.

Yes, I suspect a few ebuilds can break. However, I've tinderboxed this
against @world and gnome3, and all worked fine. So maybe it's not as
bad as I thought and only a few rarely used ebuilds will break :).

-- 
Best regards,
Michał Górny
<http://dev.gentoo.org/~mgorny/>

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

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

end of thread, other threads:[~2015-07-26 21:47 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-25 10:37 [gentoo-dev] [PATCHSET python-utils-r1] python & python-config wrapper cleanup Michał Górny
2015-07-25 10:37 ` [gentoo-dev] [PATCH python-utils-r1 1/4] Use shell wrappers instead of symlinks for python{,-config} Michał Górny
2015-07-26 15:09   ` [gentoo-dev] " Mike Gilbert
2015-07-25 10:37 ` [gentoo-dev] [PATCH python-utils-r1 2/4] Wrap pythonN-config as well Michał Górny
2015-07-25 14:12   ` Jason Zaman
2015-07-25 15:26     ` Jason Zaman
2015-07-25 10:37 ` [gentoo-dev] [PATCH python-utils-r1 3/4] Ban calling pythonY and pythonY-config when pythonX is used Michał Górny
2015-07-25 14:25   ` Jason Zaman
2015-07-25 15:46     ` Michał Górny
2015-07-26 15:14   ` [gentoo-dev] " Mike Gilbert
2015-07-26 21:46     ` Michał Górny
2015-07-25 10:37 ` [gentoo-dev] [PATCH python-utils-r1 4/4] Exit with 127 when banned command is called Michał Górny
2015-07-25 11:37 ` [gentoo-dev] [PATCHSET python-utils-r1] python & python-config wrapper cleanup Davide Pesavento
2015-07-25 12:03   ` Michał Górny
2015-07-25 12:24     ` Davide Pesavento
2015-07-25 12:48       ` Michał Górny
2015-07-26  0:16         ` Davide Pesavento

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