From: Mike Frysinger <vapier@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Subject: Re: [gentoo-portage-dev] [PATCH] runtests: rewrite in python
Date: Thu, 4 Jun 2015 00:26:32 -0400 [thread overview]
Message-ID: <20150604042632.GI23039@vapier> (raw)
In-Reply-To: <20150530123006.3aa8110c.dolsen@gentoo.org>
[-- Attachment #1: Type: text/plain, Size: 3157 bytes --]
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)
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-06-04 4:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-30 16:29 [gentoo-portage-dev] [PATCH] runtests: rewrite in python Mike Frysinger
2015-05-30 17:18 ` Brian Dolbec
2015-05-30 18:27 ` Mike Frysinger
2015-05-30 19:30 ` Brian Dolbec
2015-06-04 4:26 ` Mike Frysinger [this message]
2015-06-01 21:16 ` Alexander Berntsen
2015-06-11 7:12 ` Brian Dolbec
2015-05-30 18:42 ` Mike Gilbert
2015-05-30 19:16 ` Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150604042632.GI23039@vapier \
--to=vapier@gentoo.org \
--cc=gentoo-portage-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox