On 30 May 2015 12:30, Brian Dolbec wrote: > On Sat, 30 May 2015 14:27:25 -0400 Mike Frysinger wrote: > > > > +def get_python_executable(ver): > > > > + """Find the right python executable for |ver|""" > > > > + if ver == 'pypy': > > > > + prog = 'pypy' > > > > + else: > > > > + prog = 'python' + ver > > > > + return os.path.join(EPREFIX, 'usr', 'bin', prog) > > > > > > The only thing I don't like about this is it could mean more > > > maintenance changes in the future if others come along. > > > > to be clear: this is not new code. this is (more or less) a straight > > port from bash to python. your feedback here applies to the bash > > version as well. i'd like to minimize the changes when converting > > languages and then address feedback like this on top of that. > > > > > I think making the lists have more complete naming would be better > > > > > > PYTHON_SUPPORTED_VERSIONS = [ > > > 'python2.7', > > > 'python3.3', > > > 'python3.4', > > > ] > > > > > > # The rest are just "nice to have". > > > PYTHON_NICE_VERSIONS = [ > > > 'pypy', > > > 'python3.5', > > > 'foo-bar-7.6', > > > ] > > > > > > Then all that is needed in get_python_executable() is the final > > > path. No other future code changes are likely to be needed. > > > Also easier to override from the environment without editing code. > > > > this makes the command line interface a bit more annoying. today you > > can do: $ runtests --python-version '2.7 3.3' > > > > but with this change, it'd be: > > $ runtests --python-version 'python2.7 python3.3' > > > > we could add some logic so that if the arg is composed of dots & > > digits, we'd blindly prefix it with "python". > > Well, that get's back to almost the same kind of > get_python_executable(). But I think it would be a little better than > the existing. > > We could instead do a string search and include any > member with that substring. That would include python3.3 and > foo-bar-3.3 for a 3.3 cli entry. It could make for a more flexible cli > > versions = [] > for y in args.python_versions: > versions.extend([x for x in all_pythons if y in x])
that would perform badly if you used "2" or "3" (as you'd match minors and such). what about this patch ? -mike --- a/runtests +++ b/runtests @@ -15,20 +15,21 @@ from __future__ import print_function import argparse import os +import re import sys import subprocess # These are the versions we fully support and require to pass tests. PYTHON_SUPPORTED_VERSIONS = [ - '2.7', - '3.3', - '3.4', + 'python2.7', + 'python3.3', + 'python3.4', ] # The rest are just "nice to have". PYTHON_NICE_VERSIONS = [ 'pypy', - '3.5', + 'python3.5', ] EPREFIX = os.environ.get('PORTAGE_OVERRIDE_EPREFIX', '/') @@ -68,10 +69,10 @@ class Colors(object): def get_python_executable(ver): """Find the right python executable for |ver|""" - if ver == 'pypy': - prog = 'pypy' - else: + if re.match(r'[0-9.]+$', ver): prog = 'python' + ver + else: + prog = ver return os.path.join(EPREFIX, 'usr', 'bin', prog)
signature.asc
Description: Digital signature