From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-python+bounces-203-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id 8E66C1381F3
	for <garchives@archives.gentoo.org>; Sat,  3 Nov 2012 07:33:09 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id A8A8721C048;
	Sat,  3 Nov 2012 07:33:00 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by pigeon.gentoo.org (Postfix) with ESMTP id E38FC21C048
	for <gentoo-python@lists.gentoo.org>; Sat,  3 Nov 2012 07:32:59 +0000 (UTC)
Received: from pomiocik.lan (213-238-96-169.adsl.inetia.pl [213.238.96.169])
	(using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))
	(No client certificate requested)
	(Authenticated sender: mgorny)
	by smtp.gentoo.org (Postfix) with ESMTPSA id D45F933D7EC;
	Sat,  3 Nov 2012 07:32:57 +0000 (UTC)
Date: Sat, 3 Nov 2012 08:33:46 +0100
From: =?UTF-8?B?TWljaGHFgiBHw7Nybnk=?= <mgorny@gentoo.org>
To: Brian Harring <ferringb@gmail.com>
Cc: Mike Gilbert <floppym@gentoo.org>, gentoo-python@lists.gentoo.org
Subject: Re: [gentoo-python] Re: [PATCH eselect-python 1/2] Store
 per-version interpreter preference in a file as well.
Message-ID: <20121103083346.1d21d1a5@pomiocik.lan>
In-Reply-To: <20121103033538.GI3299@localhost>
References: <1351770893-1217-1-git-send-email-mgorny@gentoo.org>
	<CAJ0EP41Ww9GKYto8A8gX-L+D2=3+MFhYHmUZXZNvm+Ni5ApSbw@mail.gmail.com>
	<CAJ0EP42u9vNaC70ui-YPjRR1SOY9n8fCmnXA1EgijmRdsRdK8Q@mail.gmail.com>
	<20121101222719.2717ff05@pomiocik.lan>
	<20121101224242.GE3299@localhost>
	<20121102100305.4acfc927@pomiocik.lan>
	<20121103033538.GI3299@localhost>
Organization: Gentoo
X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.13; x86_64-pc-linux-gnu)
Precedence: bulk
List-Post: <mailto:gentoo-python@lists.gentoo.org>
List-Help: <mailto:gentoo-python+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-python+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-python+subscribe@lists.gentoo.org>
List-Id: Discussions centering around the Python ecosystem in Gentoo Linux <gentoo-python.gentoo.org>
X-BeenThere: gentoo-python@gentoo.org
X-BeenThere: gentoo-python@lists.gentoo.org
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=PGP-SHA256;
 boundary="Sig_/NCdpyJaww+8RYW9wHxSjrIL"; protocol="application/pgp-signature"
X-Archives-Salt: 9e802d76-50c3-4df8-a5c6-efaf1b419d8b
X-Archives-Hash: 31c364b2833e4896fc04600e8549e4e8

--Sig_/NCdpyJaww+8RYW9wHxSjrIL
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Fri, 2 Nov 2012 20:35:38 -0700
Brian Harring <ferringb@gmail.com> wrote:

> On Fri, Nov 02, 2012 at 10:03:05AM +0100, Micha?? G??rny wrote:
> > On Thu, 1 Nov 2012 15:42:42 -0700
> > Brian Harring <ferringb@gmail.com> wrote:
> >=20
> > > That's a shebang based version of what I proposed a while back.  It=20
> > > works now and has tests.  It's written to be basically a drop in for=
=20
> > > existing python.eclass generation of shebangs, w/ the=20
> > > hardlinking/de-duplication/farking-fast/fix python3.2=20
> > > /usr/bin/sphinx-build scenario.
> >=20
> > Could you please provide an explanation of what it does? I mean, a few
> > points of what happens when you run it in various scenarios. That's 600
> > lines of C code, I think Python folks would appreciate not having to
> > read that line by line.
>=20
> Grumble.  Don't think you read my commit messages at all, just=20
> responded looking for points to claim "it sucks".

Unless I'm missing something, the commit message says how to use it
and what are its advantages. But thanks for the list, that's what I was
asking for.

> What I have written here is a python-shebang based solution.  That=20
> shebang target includes the EPYTHON's it supports.
>=20
> For the usual sphinx-build example, sphinx-build-2.7 goes from
> #!/usr/bin/python2.7
>=20
> to
>=20
> #!/usr/bin/python-shebang python2.7,python3.2
>=20
> This means that sphinx-build-2.7 and sphinx-build-3.2 are now the same=20
> content.  They can be hardlinked together (space savings).
>=20
> This additionally means that sphinx-build can be hardlinked to the=20
> same underlying inode.  Why?  Because python-shebang is smart enough=20
> to recognize the context it is invoked in.
>=20
> This additionally means that the follow commands:
>=20
> eselect python set 3.2
> python2.7 /usr/bin/sphinx-build
>=20
> properly work- invoking sphinx-bulid in a 2.7 context (for anyone=20
> trying to write distutils/setup bits that aren't gentoo/EPYTHON=20
> specific, this is fricking useful to say the least).

I think you've missed my question: what code does the 'sphinx-build'
contain, except for the shebang? Is that a Python version
of the wrapper? Some kind of os.exec()?

> > > Frankly, you should be looking at this imo, rather than trying=20
> > > standalone files.  Yes, files is simpler- but you'll wind up sooner o=
r=20
> > > later rebuilding it into what I already built out here.
> >=20
> > I think you are missing the point I'm raising here. Mostly because your
> > python-wrapper doesn't handle per-version preferences like python-exec
> > does, unless I'm missing something.
>=20
> You're misunderstanding what was written; hell, I even referenced=20
> that it supports EPYTHON preference in #5 (java-config cycle=20
> breaking).

EPYTHON preference is rarely used by users. Users are using
eselect-python. And eselect-python uses two levels of preferences:

1. 'Main' python interpreter preference,

2. Per-Python2/Python3 interpreter preference.

With the former being stored in a file, the latter in symlinks.
The goal of my patches were to store both in files so that the symlink
reading code could be removed to make the code simpler.

> > > """
> > > Add a python-shebang utility, slave python-wrapper to it.
> > >=20
> > > Going forward, the intent is to push the PYTHON_ABIs of a given
> > > script down into it's shebang, pointing the shebang at python-shebang.
> > >=20
> > > In this way, all known/supported abi's are available at the time of
> > > execution; further, if the target is told to respect-EPYTHON (meaning
> > > no searching for something to execute, either active python version or
> > > EPYTHON var), we can push this down into that list and have that code
> > > handle it.
> > >=20
> > > [...]
> > >
> > > to the simpler form of:
> > > for x in sphinx{,-{2.7,3.2}}; do echo > $x <<EOF
> > > #!/usr/bin/python-shebang python2.7,python3.2
> > > <code>
> > > EOF
> > > done
> >=20
> > Hmm, are you assuming that /usr/bin/sphinx carries the actual code?
> > Or some special wrapper code?
> >=20
> > Not to mention you still bind the whole thing to installed package.
> > If you need to fix those files, you need to reinstall all packages
> > installing them.
>=20
> This critique makes no sense... and I'm pretty sure that any point you=20
> may manage to come up with, will apply directly to python-exec just as=20
> equally.
>=20
> Either clarify your claim, or drop the noise there.

python-exec can't be executed like that currently, correct. By I can
make it so just by replacing the python-exec executable as the symlinks
will make it effectively to every single package.

In your case, any change won't apply globally.

> > > The gains of this are thus:
> >=20
> > Could you please compare it to the modern solution (python-exec) rather
> > than the deprecated one? You are no longer on the uncharted waters.
>=20
> Respectfully, your 'modern solution' (vs deprecated) is purely in your=20
> head; distutils/python eclasses of your making aren't the tree. =20
>=20
> They're your playground right now- one that you're pushing, but I've=20
> yet to see real traction on.  That's just reality; you may think it's=20
> a done deal (or will be), but the on the ground reality right now-=20
> including the pushback you've been getting from people in certain=20
> cases- makes me unwilling to pin my hopes on your work.

It is just a difference in methods. You want to push your solution to
the whole tree at once and see what happens next. I rather prefer
testing it on new ebuilds first, then getting it stable and thinking
about replacing the old one when the new one is ready.

> Either way, you asked, so here's the list of python-exec con's in=20
> comparison to python-shebang:
>=20
> 1) Your solution actually doesn't work as a fricking wrapper for a=20
> core usage case; `python /usr/bin/sphinx-build`.  That perfectly=20
> innocuous/valid invocation would result in the interpretter trying=20
> to execute an elf binary.  That pretty much renders your solution as a=20
> no go right from the get go.  Your only way to fix that is to have=20
> sphinx-build be a python implementation that does wrapping, and use a=20
> shebang of python-exec (so you can maintain speed for direct=20
> /usr/bin/sphinx-build invocations); meaning once you spotted that=20
> flaw, you'd evolve your attempt into something nearing what I wrote.

No, not really. I still am afraid that you're missing some point of how
Python interpreter works but considering the fight you put protecting
'python /usr/bin/c-file', I won't continue that topic until you finally
answer my questions wrt that file.

By the way, I doubt it is a 'core usage case'. Maybe just because it
never worked as intended, maybe because people simply don't do that
usually because people usually don't care whether stuff in /usr/bin
is Python, C or shell.

> 2) Everytime there is a new python interpretter, python-exec has to=20
> be re-built updating it's hardcoded list of interpretters.  Goes without=
=20
> saying, this sucks a fair bit; your solution there likely would be=20
> walk env.d/python/* in some fashion extracting the list of targets (or=20
> walk /usr/bin/python* and run into problems w/ the names used there=20
> now matching EPYTHON usage).  End result, you'd evolve it into=20
> something nearing what I did w/ shebangs.

How often does this happen? Is this really problematic?

And how an user can disable a particular (say, problematic) Python
implementation globally in your solution? Without reinstalling all
the packages which provide scripts for it?

> 3) It's a hardcoded lookup list that is forced for all scripts; if=20
> that list is python3.2,python3.1,python2.7, and the active python=20
> version doesn't intersect that (say jython-2.5), your approach forces=20
> 3.2.  My solution actually allows the script, in the absense of an=20
> enforcement via active python or EPYTHON, to use it's own preferred=20
> ordering.  Using pkgcore as an example, we prefer py2k execution over=20
> py3k- py2k is faster since the extensions are enabled.  This=20
> capability doesn't exist in your solution, nor the existing wrapper;=20
> it's a useful byproduct of how my solution is structured.  Etc etc,=20
> you know the response; where you'll go with this sooner or later is=20
> where python-shebang is already.

And, hmm, are you the first person requesting such a feature over
the whole lifetime of python-wrapper?

I believe that hardcoded list is *simpler*. If user enabled jython-2.5
(suicidal type?), then he's aware of the consequences. And in my
solution, preferred Python 2 will be used. Then preferred Python 3.
Then Python 2.7, 2.6, 2.5... then 3.2. It is predictable.

In your solution, it is completely unpredictable. Developer can
(supposedly) do whatever he wants. Most of the devs probably won't use
that, except for a few cases where users will simply hit (if ever)
an unexpected behavior.

> 5) Via going with a standalone package from eselect-python, you're=20
> introducing the potential for the two to be out of sync/incompatible. =20
> Addressable via folding it inline into eselect-python (as I did), but=20
> it's a con against your solution in it's current claimed form.  Same=20
> thing, you'll do what I did sooner or later since it's the better=20
> approach.

It's a better development practice to split things. You should've known
that by now. In any case, python-exec can work *without*
eselect-python. You can try it if you don't believe.

> 7) My solution doesn't hardcode /usr/bin/* pathways.  User sticks a=20
> python2.7 into /usr/local/ (for whatever reason they choose to do so),=20
> it will honor that.

Errr? Where does your suggestion come from?

As far as I'm aware, user can put into per-implementation copy whatever
he wants. Including a shell script, a C executable or whatever. It will
work. With your, it won't.

As far as I'm aware, you solution can't handle per-implementation
Python options (command-line arguments) either. In mine, it's as simple
as dropping them onto the shebang.

> 8) Your solution doesn't work in the context of being used for=20
> /usr/bin/python wrapper; it's close, but as you yourself said, it=20
> requires symlinks (python-python2.7).

Or adding a conditional which your solution simply does. So, where are
you going with this point? To the fact that I'm asking others for
opinion while you're ignoring their existence?

> 9) No tests.  Every. Fucking. Pathway. is tested with what I wrote. =20
> Python-exec lacks that, else issue #1 would've been spotted up front.

Great. Awesome. You are so awesome I can't even spell it.

Now feel free to grep the bugzie. That 'issue #1' is known. So far,
I haven't get anyone to say he believes that's really important
or useful.=20

> The only flaws with it at this point are thus:
>=20
> 1) There is a 127 char limit on shebang length.  This is addressable=20
> via having python-shebang reach grab the list from the target itself=20
> if that limit is encountered.
>=20
> 2) fleshing out the tools for doing de-duplication; it's easy enough,=20
> I've just been busy with other things, and this code was done as a=20
> side project for entertainment.  I'll finish it soon enough (else if=20
> someone wants to sort the remaining issues, I can detail exactly how).
>=20
>=20
> The nice part about my solution here is that it's not something that=20
> is hinged mgorny's python/distutils eclasses becoming the norm; it's=20
> usable now for existing python eclass (simple enough to plug it in),=20
> and any followup solution would be insane not to use it.

Did you ever have a bit of modesty? I think this is what gets me so mad
at you. Every thing you do is so perfect and bug-free everyone else
should be insane not to start using it immediately. Except when it
doesn't work at all but then others are just 'getting you pissy'.

--=20
Best regards,
Micha=C5=82 G=C3=B3rny

--Sig_/NCdpyJaww+8RYW9wHxSjrIL
Content-Type: application/pgp-signature; name=signature.asc
Content-Disposition: attachment; filename=signature.asc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)

iJwEAQEIAAYFAlCUyOEACgkQfXuS5UK5QB1CNwP7BDkaEEhdHeERgRQA28qzNvHb
OAvxYHRZC6zfG42McAeFf6VqYsJAvY2KZvsXY9efWpB1TIdINLWMsdADnHlWfykO
TKa5GlUrM40Ho3Y6NICC/TO4l8kzHgOOrI8wa2TGhPFHv2elIcV3gU8bWMeSdQwh
JqLZgik4JdU51h6566U=
=SAjg
-----END PGP SIGNATURE-----

--Sig_/NCdpyJaww+8RYW9wHxSjrIL--