Gentoo Archives: gentoo-portage-dev

From: Brian Dolbec <dolsen@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] runtests: rewrite in python
Date: Sat, 30 May 2015 19:30:11
Message-Id: 20150530123006.3aa8110c.dolsen@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH] runtests: rewrite in python by Mike Frysinger
1 On Sat, 30 May 2015 14:27:25 -0400
2 Mike Frysinger <vapier@g.o> wrote:
3
4 >
5 > > > +def get_python_executable(ver):
6 > > > + """Find the right python executable for |ver|"""
7 > > > + if ver == 'pypy':
8 > > > + prog = 'pypy'
9 > > > + else:
10 > > > + prog = 'python' + ver
11 > > > + return os.path.join(EPREFIX, 'usr', 'bin', prog)
12 > >
13 > >
14 > > The only thing I don't like about this is it could mean more
15 > > maintenance changes in the future if others come along.
16 >
17 > to be clear: this is not new code. this is (more or less) a straight
18 > port from bash to python. your feedback here applies to the bash
19 > version as well. i'd like to minimize the changes when converting
20 > languages and then address feedback like this on top of that.
21 >
22 > > I think making the lists have more complete naming would be better
23 > >
24 > > PYTHON_SUPPORTED_VERSIONS = [
25 > > 'python2.7',
26 > > 'python3.3',
27 > > 'python3.4',
28 > > ]
29 > >
30 > > # The rest are just "nice to have".
31 > > PYTHON_NICE_VERSIONS = [
32 > > 'pypy',
33 > > 'python3.5',
34 > > 'foo-bar-7.6',
35 > > ]
36 > >
37 > > Then all that is needed in get_python_executable() is the final
38 > > path. No other future code changes are likely to be needed.
39 > > Also easier to override from the environment without editing code.
40 >
41 > this makes the command line interface a bit more annoying. today you
42 > can do: $ runtests --python-version '2.7 3.3'
43 >
44 > but with this change, it'd be:
45 > $ runtests --python-version 'python2.7 python3.3'
46 >
47 > we could add some logic so that if the arg is composed of dots &
48 > digits, we'd blindly prefix it with "python".
49 > -mike
50
51 Well, that get's back to almost the same kind of
52 get_python_executable(). But I think it would be a little better than
53 the existing.
54
55 We could instead do a string search and include any
56 member with that substring. That would include python3.3 and
57 foo-bar-3.3 for a 3.3 cli entry. It could make for a more flexible cli
58
59 versions = []
60 for y in args.python_versions:
61 versions.extend([x for x in all_pythons if y in x])
62 --
63 Brian Dolbec <dolsen>

Replies

Subject Author
Re: [gentoo-portage-dev] [PATCH] runtests: rewrite in python Mike Frysinger <vapier@g.o>