Patchwork Properly initialize version string in python-hglib setup.py

login
register
mail settings
Submitter Peter Elmers
Date May 26, 2015, 10:56 p.m.
Message ID <2047584718.2485446.1432680989484.JavaMail.yahoo@mail.yahoo.com>
Download mbox | patch
Permalink /patch/9291/
State Changes Requested
Delegated to: Matt Mackall
Headers show

Comments

Peter Elmers - May 26, 2015, 10:56 p.m.
# HG changeset patch
# User Peter Elmers <peter.elmers@yahoo.com>
# Date 1432680605 25200
#      Tue May 26 15:50:05 2015 -0700
# Node ID 9afa1d6c9da357b3f61f7e4eb4b08390c4bc5fd1
# Parent  ec935041d1ff0fd2aa8cb666d79e6dcca398ddba
version: declare a default version in setup.py (issue3924)

Leaving version as "unknown" breaks `pip freeze`, so we should default the
version to the current version and let it update itself if a more precise one
can be pulled from version control.
Augie Fackler - May 27, 2015, 6:33 p.m.
mpm, as an FYI here's an hglib patch that I'm just delegating to you.

On Tue, May 26, 2015 at 10:56:29PM +0000, Peter Elmers wrote:
> # HG changeset patch
> # User Peter Elmers <peter.elmers@yahoo.com>
> # Date 1432680605 25200
> #      Tue May 26 15:50:05 2015 -0700
> # Node ID 9afa1d6c9da357b3f61f7e4eb4b08390c4bc5fd1
> # Parent  ec935041d1ff0fd2aa8cb666d79e6dcca398ddba
> version: declare a default version in setup.py (issue3924)
>
> Leaving version as "unknown" breaks `pip freeze`, so we should default the
> version to the current version and let it update itself if a more precise one
> can be pulled from version control.
>
> diff -r ec935041d1ff -r 9afa1d6c9da3 setup.py
> --- a/setup.py    Wed Apr 01 13:34:58 2015 -0500
> +++ b/setup.py    Tue May 26 15:50:05 2015 -0700
> @@ -2,7 +2,7 @@
>  from distutils.core import setup
>
>  # query Mercurial for version number
> -version = 'unknown'
> +version = '1.6'
>  if os.path.isdir('.hg'):
>      cmd = "hg id -i -t"
>      l = os.popen(cmd).read().split()
>

> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
Yuya Nishihara - May 28, 2015, 12:37 p.m.
On Wed, 27 May 2015 14:33:28 -0400, Augie Fackler wrote:
> mpm, as an FYI here's an hglib patch that I'm just delegating to you.
> On Tue, May 26, 2015 at 10:56:29PM +0000, Peter Elmers wrote:
> > # HG changeset patch
> > # User Peter Elmers <peter.elmers@yahoo.com>
> > # Date 1432680605 25200
> > #      Tue May 26 15:50:05 2015 -0700
> > # Node ID 9afa1d6c9da357b3f61f7e4eb4b08390c4bc5fd1
> > # Parent  ec935041d1ff0fd2aa8cb666d79e6dcca398ddba
> > version: declare a default version in setup.py (issue3924)
> >
> > Leaving version as "unknown" breaks `pip freeze`, so we should default the
> > version to the current version and let it update itself if a more precise one
> > can be pulled from version control.
> >
> > diff -r ec935041d1ff -r 9afa1d6c9da3 setup.py
> > --- a/setup.py    Wed Apr 01 13:34:58 2015 -0500
> > +++ b/setup.py    Tue May 26 15:50:05 2015 -0700
> > @@ -2,7 +2,7 @@
> >  from distutils.core import setup
> >
> >  # query Mercurial for version number
> > -version = 'unknown'
> > +version = '1.6'

Perhaps we can parse PKG-INFO file just like we do for .hg_archival.txt.

https://www.python.org/dev/peps/pep-0314/
Peter Elmers - May 29, 2015, 6:20 p.m.
If it were up to me, I'd fill out the version number directly and update it on each release by hand rather than tussle with pulling it out of the version control. Maybe I'm missing something; what is the motivation for the parsing that we do here? https://www.selenic.com/repo/python-hglib/file/ec935041d1ff/setup.py#l4




     On Thursday, May 28, 2015 5:38 AM, Yuya Nishihara <yuya@tcha.org> wrote:
   

 On Wed, 27 May 2015 14:33:28 -0400, Augie Fackler wrote:
> mpm, as an FYI here's an hglib patch that I'm just delegating to you.
> On Tue, May 26, 2015 at 10:56:29PM +0000, Peter Elmers wrote:
> > # HG changeset patch
> > # User Peter Elmers <peter.elmers@yahoo.com>
> > # Date 1432680605 25200
> > #      Tue May 26 15:50:05 2015 -0700
> > # Node ID 9afa1d6c9da357b3f61f7e4eb4b08390c4bc5fd1
> > # Parent  ec935041d1ff0fd2aa8cb666d79e6dcca398ddba
> > version: declare a default version in setup.py (issue3924)
> >
> > Leaving version as "unknown" breaks `pip freeze`, so we should default the
> > version to the current version and let it update itself if a more precise one
> > can be pulled from version control.
> >
> > diff -r ec935041d1ff -r 9afa1d6c9da3 setup.py
> > --- a/setup.py    Wed Apr 01 13:34:58 2015 -0500
> > +++ b/setup.py    Tue May 26 15:50:05 2015 -0700
> > @@ -2,7 +2,7 @@
> >  from distutils.core import setup
> >
> >  # query Mercurial for version number
> > -version = 'unknown'
> > +version = '1.6'

Perhaps we can parse PKG-INFO file just like we do for .hg_archival.txt.

https://www.python.org/dev/peps/pep-0314/
Yuya Nishihara - May 30, 2015, 2:11 a.m.
On Fri, 29 May 2015 18:20:46 +0000 (UTC), Peter Elmers wrote:
> If it were up to me, I'd fill out the version number directly and update
> it on each release by hand rather than tussle with pulling it out of the
> version control. Maybe I'm missing something; what is the motivation for the
> parsing that we do here?
> https://www.selenic.com/repo/python-hglib/file/ec935041d1ff/setup.py#l4

IIRC, we do want to eliminate manual steps for making a release.
Pierre-Yves David - May 30, 2015, 2:33 a.m.
On 05/29/2015 07:11 PM, Yuya Nishihara wrote:
> On Fri, 29 May 2015 18:20:46 +0000 (UTC), Peter Elmers wrote:
>> If it were up to me, I'd fill out the version number directly and update
>> it on each release by hand rather than tussle with pulling it out of the
>> version control. Maybe I'm missing something; what is the motivation for the
>> parsing that we do here?
>> https://www.selenic.com/repo/python-hglib/file/ec935041d1ff/setup.py#l4
>
> IIRC, we do want to eliminate manual steps for making a release.

And non-tagger version get a magic +2345-somehash addition to mark this 
fact.
Matt Mackall - June 2, 2015, 10 p.m.
On Thu, 2015-05-28 at 21:37 +0900, Yuya Nishihara wrote:

> Perhaps we can parse PKG-INFO file just like we do for .hg_archival.txt.
> 
> https://www.python.org/dev/peps/pep-0314/

Sounds promising.
Peter Elmers - July 20, 2015, 11:27 p.m.
Hi,

Sorry for the long silence on the topic. I've attached an updated patch that will look at PKG-INFO as well, if it cannot find the .hg directory or the archival file.
Cheers!



     On Tuesday, June 2, 2015 3:00 PM, Matt Mackall <mpm@selenic.com> wrote:
   

 On Thu, 2015-05-28 at 21:37 +0900, Yuya Nishihara wrote:

> Perhaps we can parse PKG-INFO file just like we do for .hg_archival.txt.
> 
> https://www.python.org/dev/peps/pep-0314/

Sounds promising.
Yuya Nishihara - July 21, 2015, 3:39 p.m.
On Mon, 20 Jul 2015 23:27:02 +0000 (UTC), Peter Elmers wrote:
> # HG changeset patch
> # User Peter Elmers <peter.elmers@yahoo.com>
> # Date 1437434738 25200
> #      Mon Jul 20 16:25:38 2015 -0700
> # Node ID c0f73a10ceb96a60c178f6057ce90309d08d3974
> # Parent  ec935041d1ff0fd2aa8cb666d79e6dcca398ddba
> Issue 3924: default version to 1.6, parse PKG-INFO.

Thanks for the revised patch, but we prefer patch in body, not as an
attachment.

https://mercurial.selenic.com/wiki/ContributingChanges#Submission_checklist

Couple of comments follow...

> -# query Mercurial for version number
> -version = 'unknown'
> +version = '1.6'

Hmm, it must be updated per release? That is what we want to avoid.

>  elif os.path.exists('.hg_archival.txt'):
>      kw = dict([[t.strip() for t in l.split(':', 1)]
>                 for l in open('.hg_archival.txt')])
>      if 'tag' in kw:
> -        version =  kw['tag']
> +        version = kw['tag']

Good catch, but whitespace cleanup should be a separate patch.

>      elif 'latesttag' in kw:
>          version = '%(latesttag)s+%(latesttagdistance)s-%(node).12s' % kw
>      else:
>          version = kw.get('node', '')[:12]
> +elif os.path.exists('PKG-INFO'):
> +    with open('PKG-INFO') as pkginfo:
> +        kw = dict([[t.strip() for t in l.split(':', 1)]
> +                  for l in pkginfo if ':' in l])
> +        version = kw.get('Version', version)

Perhaps hglib should be compatible with ancient Python, so I think "with"
statement isn't allowed.

Patch

diff -r ec935041d1ff -r 9afa1d6c9da3 setup.py
--- a/setup.py    Wed Apr 01 13:34:58 2015 -0500
+++ b/setup.py    Tue May 26 15:50:05 2015 -0700
@@ -2,7 +2,7 @@ 
 from distutils.core import setup
 
 # query Mercurial for version number
-version = 'unknown'
+version = '1.6'
 if os.path.isdir('.hg'):
     cmd = "hg id -i -t"
     l = os.popen(cmd).read().split()