Gentoo Archives: gentoo-python

From: "Michał Górny" <mgorny@g.o>
To: Brian Harring <ferringb@×××××.com>
Cc: Mike Gilbert <floppym@g.o>, gentoo-python@l.g.o
Subject: Re: [gentoo-python] Re: [PATCH eselect-python 1/2] Store per-version interpreter preference in a file as well.
Date: Sat, 03 Nov 2012 07:33:09
Message-Id: 20121103083346.1d21d1a5@pomiocik.lan
In Reply to: Re: [gentoo-python] Re: [PATCH eselect-python 1/2] Store per-version interpreter preference in a file as well. by Brian Harring
1 On Fri, 2 Nov 2012 20:35:38 -0700
2 Brian Harring <ferringb@×××××.com> wrote:
3
4 > On Fri, Nov 02, 2012 at 10:03:05AM +0100, Micha?? G??rny wrote:
5 > > On Thu, 1 Nov 2012 15:42:42 -0700
6 > > Brian Harring <ferringb@×××××.com> wrote:
7 > >
8 > > > That's a shebang based version of what I proposed a while back. It
9 > > > works now and has tests. It's written to be basically a drop in for
10 > > > existing python.eclass generation of shebangs, w/ the
11 > > > hardlinking/de-duplication/farking-fast/fix python3.2
12 > > > /usr/bin/sphinx-build scenario.
13 > >
14 > > Could you please provide an explanation of what it does? I mean, a few
15 > > points of what happens when you run it in various scenarios. That's 600
16 > > lines of C code, I think Python folks would appreciate not having to
17 > > read that line by line.
18 >
19 > Grumble. Don't think you read my commit messages at all, just
20 > responded looking for points to claim "it sucks".
21
22 Unless I'm missing something, the commit message says how to use it
23 and what are its advantages. But thanks for the list, that's what I was
24 asking for.
25
26 > What I have written here is a python-shebang based solution. That
27 > shebang target includes the EPYTHON's it supports.
28 >
29 > For the usual sphinx-build example, sphinx-build-2.7 goes from
30 > #!/usr/bin/python2.7
31 >
32 > to
33 >
34 > #!/usr/bin/python-shebang python2.7,python3.2
35 >
36 > This means that sphinx-build-2.7 and sphinx-build-3.2 are now the same
37 > content. They can be hardlinked together (space savings).
38 >
39 > This additionally means that sphinx-build can be hardlinked to the
40 > same underlying inode. Why? Because python-shebang is smart enough
41 > to recognize the context it is invoked in.
42 >
43 > This additionally means that the follow commands:
44 >
45 > eselect python set 3.2
46 > python2.7 /usr/bin/sphinx-build
47 >
48 > properly work- invoking sphinx-bulid in a 2.7 context (for anyone
49 > trying to write distutils/setup bits that aren't gentoo/EPYTHON
50 > specific, this is fricking useful to say the least).
51
52 I think you've missed my question: what code does the 'sphinx-build'
53 contain, except for the shebang? Is that a Python version
54 of the wrapper? Some kind of os.exec()?
55
56 > > > Frankly, you should be looking at this imo, rather than trying
57 > > > standalone files. Yes, files is simpler- but you'll wind up sooner or
58 > > > later rebuilding it into what I already built out here.
59 > >
60 > > I think you are missing the point I'm raising here. Mostly because your
61 > > python-wrapper doesn't handle per-version preferences like python-exec
62 > > does, unless I'm missing something.
63 >
64 > You're misunderstanding what was written; hell, I even referenced
65 > that it supports EPYTHON preference in #5 (java-config cycle
66 > breaking).
67
68 EPYTHON preference is rarely used by users. Users are using
69 eselect-python. And eselect-python uses two levels of preferences:
70
71 1. 'Main' python interpreter preference,
72
73 2. Per-Python2/Python3 interpreter preference.
74
75 With the former being stored in a file, the latter in symlinks.
76 The goal of my patches were to store both in files so that the symlink
77 reading code could be removed to make the code simpler.
78
79 > > > """
80 > > > Add a python-shebang utility, slave python-wrapper to it.
81 > > >
82 > > > Going forward, the intent is to push the PYTHON_ABIs of a given
83 > > > script down into it's shebang, pointing the shebang at python-shebang.
84 > > >
85 > > > In this way, all known/supported abi's are available at the time of
86 > > > execution; further, if the target is told to respect-EPYTHON (meaning
87 > > > no searching for something to execute, either active python version or
88 > > > EPYTHON var), we can push this down into that list and have that code
89 > > > handle it.
90 > > >
91 > > > [...]
92 > > >
93 > > > to the simpler form of:
94 > > > for x in sphinx{,-{2.7,3.2}}; do echo > $x <<EOF
95 > > > #!/usr/bin/python-shebang python2.7,python3.2
96 > > > <code>
97 > > > EOF
98 > > > done
99 > >
100 > > Hmm, are you assuming that /usr/bin/sphinx carries the actual code?
101 > > Or some special wrapper code?
102 > >
103 > > Not to mention you still bind the whole thing to installed package.
104 > > If you need to fix those files, you need to reinstall all packages
105 > > installing them.
106 >
107 > This critique makes no sense... and I'm pretty sure that any point you
108 > may manage to come up with, will apply directly to python-exec just as
109 > equally.
110 >
111 > Either clarify your claim, or drop the noise there.
112
113 python-exec can't be executed like that currently, correct. By I can
114 make it so just by replacing the python-exec executable as the symlinks
115 will make it effectively to every single package.
116
117 In your case, any change won't apply globally.
118
119 > > > The gains of this are thus:
120 > >
121 > > Could you please compare it to the modern solution (python-exec) rather
122 > > than the deprecated one? You are no longer on the uncharted waters.
123 >
124 > Respectfully, your 'modern solution' (vs deprecated) is purely in your
125 > head; distutils/python eclasses of your making aren't the tree.
126 >
127 > They're your playground right now- one that you're pushing, but I've
128 > yet to see real traction on. That's just reality; you may think it's
129 > a done deal (or will be), but the on the ground reality right now-
130 > including the pushback you've been getting from people in certain
131 > cases- makes me unwilling to pin my hopes on your work.
132
133 It is just a difference in methods. You want to push your solution to
134 the whole tree at once and see what happens next. I rather prefer
135 testing it on new ebuilds first, then getting it stable and thinking
136 about replacing the old one when the new one is ready.
137
138 > Either way, you asked, so here's the list of python-exec con's in
139 > comparison to python-shebang:
140 >
141 > 1) Your solution actually doesn't work as a fricking wrapper for a
142 > core usage case; `python /usr/bin/sphinx-build`. That perfectly
143 > innocuous/valid invocation would result in the interpretter trying
144 > to execute an elf binary. That pretty much renders your solution as a
145 > no go right from the get go. Your only way to fix that is to have
146 > sphinx-build be a python implementation that does wrapping, and use a
147 > shebang of python-exec (so you can maintain speed for direct
148 > /usr/bin/sphinx-build invocations); meaning once you spotted that
149 > flaw, you'd evolve your attempt into something nearing what I wrote.
150
151 No, not really. I still am afraid that you're missing some point of how
152 Python interpreter works but considering the fight you put protecting
153 'python /usr/bin/c-file', I won't continue that topic until you finally
154 answer my questions wrt that file.
155
156 By the way, I doubt it is a 'core usage case'. Maybe just because it
157 never worked as intended, maybe because people simply don't do that
158 usually because people usually don't care whether stuff in /usr/bin
159 is Python, C or shell.
160
161 > 2) Everytime there is a new python interpretter, python-exec has to
162 > be re-built updating it's hardcoded list of interpretters. Goes without
163 > saying, this sucks a fair bit; your solution there likely would be
164 > walk env.d/python/* in some fashion extracting the list of targets (or
165 > walk /usr/bin/python* and run into problems w/ the names used there
166 > now matching EPYTHON usage). End result, you'd evolve it into
167 > something nearing what I did w/ shebangs.
168
169 How often does this happen? Is this really problematic?
170
171 And how an user can disable a particular (say, problematic) Python
172 implementation globally in your solution? Without reinstalling all
173 the packages which provide scripts for it?
174
175 > 3) It's a hardcoded lookup list that is forced for all scripts; if
176 > that list is python3.2,python3.1,python2.7, and the active python
177 > version doesn't intersect that (say jython-2.5), your approach forces
178 > 3.2. My solution actually allows the script, in the absense of an
179 > enforcement via active python or EPYTHON, to use it's own preferred
180 > ordering. Using pkgcore as an example, we prefer py2k execution over
181 > py3k- py2k is faster since the extensions are enabled. This
182 > capability doesn't exist in your solution, nor the existing wrapper;
183 > it's a useful byproduct of how my solution is structured. Etc etc,
184 > you know the response; where you'll go with this sooner or later is
185 > where python-shebang is already.
186
187 And, hmm, are you the first person requesting such a feature over
188 the whole lifetime of python-wrapper?
189
190 I believe that hardcoded list is *simpler*. If user enabled jython-2.5
191 (suicidal type?), then he's aware of the consequences. And in my
192 solution, preferred Python 2 will be used. Then preferred Python 3.
193 Then Python 2.7, 2.6, 2.5... then 3.2. It is predictable.
194
195 In your solution, it is completely unpredictable. Developer can
196 (supposedly) do whatever he wants. Most of the devs probably won't use
197 that, except for a few cases where users will simply hit (if ever)
198 an unexpected behavior.
199
200 > 5) Via going with a standalone package from eselect-python, you're
201 > introducing the potential for the two to be out of sync/incompatible.
202 > Addressable via folding it inline into eselect-python (as I did), but
203 > it's a con against your solution in it's current claimed form. Same
204 > thing, you'll do what I did sooner or later since it's the better
205 > approach.
206
207 It's a better development practice to split things. You should've known
208 that by now. In any case, python-exec can work *without*
209 eselect-python. You can try it if you don't believe.
210
211 > 7) My solution doesn't hardcode /usr/bin/* pathways. User sticks a
212 > python2.7 into /usr/local/ (for whatever reason they choose to do so),
213 > it will honor that.
214
215 Errr? Where does your suggestion come from?
216
217 As far as I'm aware, user can put into per-implementation copy whatever
218 he wants. Including a shell script, a C executable or whatever. It will
219 work. With your, it won't.
220
221 As far as I'm aware, you solution can't handle per-implementation
222 Python options (command-line arguments) either. In mine, it's as simple
223 as dropping them onto the shebang.
224
225 > 8) Your solution doesn't work in the context of being used for
226 > /usr/bin/python wrapper; it's close, but as you yourself said, it
227 > requires symlinks (python-python2.7).
228
229 Or adding a conditional which your solution simply does. So, where are
230 you going with this point? To the fact that I'm asking others for
231 opinion while you're ignoring their existence?
232
233 > 9) No tests. Every. Fucking. Pathway. is tested with what I wrote.
234 > Python-exec lacks that, else issue #1 would've been spotted up front.
235
236 Great. Awesome. You are so awesome I can't even spell it.
237
238 Now feel free to grep the bugzie. That 'issue #1' is known. So far,
239 I haven't get anyone to say he believes that's really important
240 or useful.
241
242 > The only flaws with it at this point are thus:
243 >
244 > 1) There is a 127 char limit on shebang length. This is addressable
245 > via having python-shebang reach grab the list from the target itself
246 > if that limit is encountered.
247 >
248 > 2) fleshing out the tools for doing de-duplication; it's easy enough,
249 > I've just been busy with other things, and this code was done as a
250 > side project for entertainment. I'll finish it soon enough (else if
251 > someone wants to sort the remaining issues, I can detail exactly how).
252 >
253 >
254 > The nice part about my solution here is that it's not something that
255 > is hinged mgorny's python/distutils eclasses becoming the norm; it's
256 > usable now for existing python eclass (simple enough to plug it in),
257 > and any followup solution would be insane not to use it.
258
259 Did you ever have a bit of modesty? I think this is what gets me so mad
260 at you. Every thing you do is so perfect and bug-free everyone else
261 should be insane not to start using it immediately. Except when it
262 doesn't work at all but then others are just 'getting you pissy'.
263
264 --
265 Best regards,
266 Michał Górny

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies