[python] Add python2_version_nodots macro

Matej Stuchlik mstuchli at redhat.com
Tue Nov 18 10:24:51 UTC 2014


I think this is more of a problem with unclear macro names. As we currently
use them (e.g. [0]) and as they were intended [1], both python2_version and
python2_version_nodots are supposed to contain major and minor version numbers
only, which they do and as far as I can see will continue to do so even if micro > 9.

It's true that they would stop working if the minor version ever got to > 9 however,
so I'll change the definition as you advise, using version_info, just without the leading
zero. :)

Thanks for noticing this!
Matt

[0] from python-click.spec:
PYTHONPATH=$(pwd) py.test-%{python2_version} tests --tb=long --verbose

[1] https://bugzilla.redhat.com/show_bug.cgi?id=731800


----- Original Message -----
> From: "Nick Coghlan" <ncoghlan at redhat.com>
> To: "Fedora Python SIG" <python-devel at lists.fedoraproject.org>
> Sent: Monday, November 17, 2014 5:17:48 AM
> Subject: Re: [python] Add python2_version_nodots macro
> 
> On 11/14/2014 12:05 AM, Matej Stuchlik wrote:
> > commit 6875a63831616c6c8e722632e24faaa1a09cc831
> > Author: Matej Stuchlik <mstuchli at redhat.com>
> > Date:   Thu Nov 13 15:04:28 2014 +0100
> > 
> >     Add python2_version_nodots macro
> > 
> >  macros.python2 |    1 +
> >  python.spec    |    5 ++++-
> >  2 files changed, 5 insertions(+), 1 deletions(-)
> > ---
> > diff --git a/macros.python2 b/macros.python2
> > index 982b51f..d090296 100644
> > --- a/macros.python2
> > +++ b/macros.python2
> > @@ -2,3 +2,4 @@
> >  %python2_sitelib %(%{__python2} -c "from distutils.sysconfig import
> >  get_python_lib; print(get_python_lib())")
> >  %python2_sitearch %(%{__python2} -c "from distutils.sysconfig import
> >  get_python_lib; print(get_python_lib(1))")
> >  %python2_version %(%{__python2} -c "import sys;
> >  sys.stdout.write(sys.version[:3])")
> > +%python2_version_nodots %(%{__python2} -c "import sys;
> > sys.stdout.write(sys.version[:3].replace('.',''))")
> 
> I just saw this commit go by on python-owners.
> 
> These macros are going to fail when Python 2.7.10 is released next year.
> Anything currently depending on the new "no dots" version in particular
> may also fail when it moves from 3 digits to 4 (since 2710 sorts
> lexically lower than 279).
> 
> The version with dots can be fixed by using
> "'.'.join(sys.version_info[:3])" instead of ignoring the explicit "Do
> not extract version information out of it" guidance for sys.version.
> 
> The version without dots can be addressed by including the leading zero:
> "{0.major}{0.minor}{0.micro:02d}".format(sys.version_info)
> 
> Cheers,
> Nick.
> 
> --
> Nick Coghlan
> Red Hat Hosted & Shared Services
> Software Engineering & Development, Brisbane
> 
> HSS Provisioning Architect
> _______________________________________________
> python-devel mailing list
> python-devel at lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/python-devel


More information about the python-devel mailing list