From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 7AEBF138CD8 for ; Thu, 4 Jun 2015 04:26:41 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8667DE08FC; Thu, 4 Jun 2015 04:26:35 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 934F6E08E5 for ; Thu, 4 Jun 2015 04:26:34 +0000 (UTC) Received: from vapier (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with SMTP id 57AD3340D7C for ; Thu, 4 Jun 2015 04:26:33 +0000 (UTC) Date: Thu, 4 Jun 2015 00:26:32 -0400 From: Mike Frysinger To: gentoo-portage-dev@lists.gentoo.org Subject: Re: [gentoo-portage-dev] [PATCH] runtests: rewrite in python Message-ID: <20150604042632.GI23039@vapier> Mail-Followup-To: gentoo-portage-dev@lists.gentoo.org References: <1433003354-18413-1-git-send-email-vapier@gentoo.org> <20150530101852.7b180cdf.dolsen@gentoo.org> <20150530182725.GH2101@vapier> <20150530123006.3aa8110c.dolsen@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="N8NGGaQn1mzfvaPg" Content-Disposition: inline In-Reply-To: <20150530123006.3aa8110c.dolsen@gentoo.org> X-Archives-Salt: 341e0d68-c8fb-4c00-b459-eb5da1507a1e X-Archives-Hash: c436fe1d1b6fba30003c0446095d3137 --N8NGGaQn1mzfvaPg Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 =3D=3D 'pypy': > > > > + prog =3D 'pypy' > > > > + else: > > > > + prog =3D 'python' + ver > > > > + return os.path.join(EPREFIX, 'usr', 'bin', prog) > > >=20 > > > The only thing I don't like about this is it could mean more > > > maintenance changes in the future if others come along. > >=20 > > 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. > >=20 > > > I think making the lists have more complete naming would be better > > >=20 > > > PYTHON_SUPPORTED_VERSIONS =3D [ > > > 'python2.7', > > > 'python3.3', > > > 'python3.4', > > > ] > > >=20 > > > # The rest are just "nice to have". > > > PYTHON_NICE_VERSIONS =3D [ > > > 'pypy', > > > 'python3.5', > > > 'foo-bar-7.6', > > > ] > > >=20 > > > 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. > >=20 > > this makes the command line interface a bit more annoying. today you > > can do: $ runtests --python-version '2.7 3.3' > >=20 > > but with this change, it'd be: > > $ runtests --python-version 'python2.7 python3.3' > >=20 > > we could add some logic so that if the arg is composed of dots & > > digits, we'd blindly prefix it with "python". >=20 > 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.=20 >=20 > 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 >=20 > versions =3D [] > 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 =20 import argparse import os +import re import sys import subprocess =20 =20 # These are the versions we fully support and require to pass tests. PYTHON_SUPPORTED_VERSIONS =3D [ - '2.7', - '3.3', - '3.4', + 'python2.7', + 'python3.3', + 'python3.4', ] # The rest are just "nice to have". PYTHON_NICE_VERSIONS =3D [ 'pypy', - '3.5', + 'python3.5', ] =20 EPREFIX =3D os.environ.get('PORTAGE_OVERRIDE_EPREFIX', '/') @@ -68,10 +69,10 @@ class Colors(object): =20 def get_python_executable(ver): """Find the right python executable for |ver|""" - if ver =3D=3D 'pypy': - prog =3D 'pypy' - else: + if re.match(r'[0-9.]+$', ver): prog =3D 'python' + ver + else: + prog =3D ver return os.path.join(EPREFIX, 'usr', 'bin', prog) =20 =20 --N8NGGaQn1mzfvaPg Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJVb9N4AAoJEEFjO5/oN/WBog0P/AlnRZsMointeuYP9UXFCe1g s6L9X4GozBif/IZqK6I23yuCuypa+UDT9GIiNRhQc874NnSmj0ZZvy5jcR6Ac+4i r67R6DMQ8/rTb/Yp0/BUuQ/1qAMKrmAJbAhsF8cdKcAU4mDrHMZWNn9kYai5F0Yz kaHQ1daWuole26SA9fnF2uFe0csh5FatsGZXphlidv/sOnu/NesKr0hJluckxp9/ fsty0vVr8cloz4S/zlrPQwU1+8RffrMQ13/JNQGYqUta/2wMmOAL5Qrg89hITDhr OwUz4Cyek8I08vU3oHqHBmdKl/ccJ4PNRHk42KvdnzzSyDKwhTPVd+z269TBrAwS SQTWZNRZqM6o476JYg5iuBviIRs/xNt5st62H3bZif8xKPrAuvRNJvPwhswIOuvl Cx7JlnNwMLAPRj715tp43Pa31txjrRQq0DCRS7hm58444RkLCtBCYP/U9/3tqbmK OVplMWt9WLere6CDFwk3j8leul6jG45TzqhaKzkijQoDgJ6qrbc/7L3W3tD2ePVZ 5gHU7+9KxllgYz2r/hbrhvajNOj6z0hUGr8Rmui+aObdTeWZHYMukXfxPqO+fddH c8rqd5xgjaV6IdwY+3g2IW4cvJ3s6eekFM6U1jGnjcDeLvZzS8jKpi7nIGEFIlDQ 0TpsdRFEnq94X/TQKrAQ =c4Hs -----END PGP SIGNATURE----- --N8NGGaQn1mzfvaPg--