setup.py
changeset 35246 d73ccc63b8f9
parent 35229 61ff0d7d56fd
child 35774 854a7315603e
equal deleted inserted replaced
35245:414114a7c18f 35246:d73ccc63b8f9
    27 
    27 
    28 import sys, platform
    28 import sys, platform
    29 if sys.version_info[0] >= 3:
    29 if sys.version_info[0] >= 3:
    30     printf = eval('print')
    30     printf = eval('print')
    31     libdir_escape = 'unicode_escape'
    31     libdir_escape = 'unicode_escape'
       
    32     def sysstr(s):
       
    33         return s.decode('latin-1')
    32 else:
    34 else:
    33     libdir_escape = 'string_escape'
    35     libdir_escape = 'string_escape'
    34     def printf(*args, **kwargs):
    36     def printf(*args, **kwargs):
    35         f = kwargs.get('file', sys.stdout)
    37         f = kwargs.get('file', sys.stdout)
    36         end = kwargs.get('end', '\n')
    38         end = kwargs.get('end', '\n')
    37         f.write(b' '.join(args) + end)
    39         f.write(b' '.join(args) + end)
       
    40     def sysstr(s):
       
    41         return s
    38 
    42 
    39 # Attempt to guide users to a modern pip - this means that 2.6 users
    43 # Attempt to guide users to a modern pip - this means that 2.6 users
    40 # should have a chance of getting a 4.2 release, and when we ratchet
    44 # should have a chance of getting a 4.2 release, and when we ratchet
    41 # the version requirement forward again hopefully everyone will get
    45 # the version requirement forward again hopefully everyone will get
    42 # something that works for them.
    46 # something that works for them.
   293 version = ''
   297 version = ''
   294 
   298 
   295 if os.path.isdir('.hg'):
   299 if os.path.isdir('.hg'):
   296     hg = findhg()
   300     hg = findhg()
   297     cmd = ['log', '-r', '.', '--template', '{tags}\n']
   301     cmd = ['log', '-r', '.', '--template', '{tags}\n']
   298     numerictags = [t for t in hg.run(cmd).split() if t[0:1].isdigit()]
   302     numerictags = [t for t in sysstr(hg.run(cmd)).split() if t[0:1].isdigit()]
   299     hgid = hg.run(['id', '-i']).strip()
   303     hgid = sysstr(hg.run(['id', '-i'])).strip()
   300     if not hgid:
   304     if not hgid:
   301         # Bail out if hg is having problems interacting with this repository,
   305         # Bail out if hg is having problems interacting with this repository,
   302         # rather than falling through and producing a bogus version number.
   306         # rather than falling through and producing a bogus version number.
   303         # Continuing with an invalid version number will break extensions
   307         # Continuing with an invalid version number will break extensions
   304         # that define minimumhgversion.
   308         # that define minimumhgversion.
   307         version = numerictags[-1]
   311         version = numerictags[-1]
   308         if hgid.endswith('+'): # propagate the dirty status to the tag
   312         if hgid.endswith('+'): # propagate the dirty status to the tag
   309             version += '+'
   313             version += '+'
   310     else: # no tag found
   314     else: # no tag found
   311         ltagcmd = ['parents', '--template', '{latesttag}']
   315         ltagcmd = ['parents', '--template', '{latesttag}']
   312         ltag = hg.run(ltagcmd)
   316         ltag = sysstr(hg.run(ltagcmd))
   313         changessincecmd = ['log', '-T', 'x\n', '-r', "only(.,'%s')" % ltag]
   317         changessincecmd = ['log', '-T', 'x\n', '-r', "only(.,'%s')" % ltag]
   314         changessince = len(hg.run(changessincecmd).splitlines())
   318         changessince = len(hg.run(changessincecmd).splitlines())
   315         version = '%s+%s-%s' % (ltag, changessince, hgid)
   319         version = '%s+%s-%s' % (ltag, changessince, hgid)
   316     if version.endswith('+'):
   320     if version.endswith('+'):
   317         version += time.strftime('%Y%m%d')
   321         version += time.strftime('%Y%m%d')