1 |
On 30 May 2015 12:30, Brian Dolbec wrote: |
2 |
> On Sat, 30 May 2015 14:27:25 -0400 Mike Frysinger wrote: |
3 |
> > > > +def get_python_executable(ver): |
4 |
> > > > + """Find the right python executable for |ver|""" |
5 |
> > > > + if ver == 'pypy': |
6 |
> > > > + prog = 'pypy' |
7 |
> > > > + else: |
8 |
> > > > + prog = 'python' + ver |
9 |
> > > > + return os.path.join(EPREFIX, 'usr', 'bin', prog) |
10 |
> > > |
11 |
> > > The only thing I don't like about this is it could mean more |
12 |
> > > maintenance changes in the future if others come along. |
13 |
> > |
14 |
> > to be clear: this is not new code. this is (more or less) a straight |
15 |
> > port from bash to python. your feedback here applies to the bash |
16 |
> > version as well. i'd like to minimize the changes when converting |
17 |
> > languages and then address feedback like this on top of that. |
18 |
> > |
19 |
> > > I think making the lists have more complete naming would be better |
20 |
> > > |
21 |
> > > PYTHON_SUPPORTED_VERSIONS = [ |
22 |
> > > 'python2.7', |
23 |
> > > 'python3.3', |
24 |
> > > 'python3.4', |
25 |
> > > ] |
26 |
> > > |
27 |
> > > # The rest are just "nice to have". |
28 |
> > > PYTHON_NICE_VERSIONS = [ |
29 |
> > > 'pypy', |
30 |
> > > 'python3.5', |
31 |
> > > 'foo-bar-7.6', |
32 |
> > > ] |
33 |
> > > |
34 |
> > > Then all that is needed in get_python_executable() is the final |
35 |
> > > path. No other future code changes are likely to be needed. |
36 |
> > > Also easier to override from the environment without editing code. |
37 |
> > |
38 |
> > this makes the command line interface a bit more annoying. today you |
39 |
> > can do: $ runtests --python-version '2.7 3.3' |
40 |
> > |
41 |
> > but with this change, it'd be: |
42 |
> > $ runtests --python-version 'python2.7 python3.3' |
43 |
> > |
44 |
> > we could add some logic so that if the arg is composed of dots & |
45 |
> > digits, we'd blindly prefix it with "python". |
46 |
> |
47 |
> Well, that get's back to almost the same kind of |
48 |
> get_python_executable(). But I think it would be a little better than |
49 |
> the existing. |
50 |
> |
51 |
> We could instead do a string search and include any |
52 |
> member with that substring. That would include python3.3 and |
53 |
> foo-bar-3.3 for a 3.3 cli entry. It could make for a more flexible cli |
54 |
> |
55 |
> versions = [] |
56 |
> for y in args.python_versions: |
57 |
> versions.extend([x for x in all_pythons if y in x]) |
58 |
|
59 |
that would perform badly if you used "2" or "3" (as you'd match minors and |
60 |
such). what about this patch ? |
61 |
-mike |
62 |
|
63 |
--- a/runtests |
64 |
+++ b/runtests |
65 |
@@ -15,20 +15,21 @@ from __future__ import print_function |
66 |
|
67 |
import argparse |
68 |
import os |
69 |
+import re |
70 |
import sys |
71 |
import subprocess |
72 |
|
73 |
|
74 |
# These are the versions we fully support and require to pass tests. |
75 |
PYTHON_SUPPORTED_VERSIONS = [ |
76 |
- '2.7', |
77 |
- '3.3', |
78 |
- '3.4', |
79 |
+ 'python2.7', |
80 |
+ 'python3.3', |
81 |
+ 'python3.4', |
82 |
] |
83 |
# The rest are just "nice to have". |
84 |
PYTHON_NICE_VERSIONS = [ |
85 |
'pypy', |
86 |
- '3.5', |
87 |
+ 'python3.5', |
88 |
] |
89 |
|
90 |
EPREFIX = os.environ.get('PORTAGE_OVERRIDE_EPREFIX', '/') |
91 |
@@ -68,10 +69,10 @@ class Colors(object): |
92 |
|
93 |
def get_python_executable(ver): |
94 |
"""Find the right python executable for |ver|""" |
95 |
- if ver == 'pypy': |
96 |
- prog = 'pypy' |
97 |
- else: |
98 |
+ if re.match(r'[0-9.]+$', ver): |
99 |
prog = 'python' + ver |
100 |
+ else: |
101 |
+ prog = ver |
102 |
return os.path.join(EPREFIX, 'usr', 'bin', prog) |