Mercurial > python-hglib
annotate setup.py @ 221:a2afbf236ca8
hglib tests: remove deprecated constructions
This mostly removes usage of 'assertEquals' (replaced with 'assertEqual'),
as well as opening files without closing them
(fixed using a 'with' statement).
author | Mathias De Mare <mathias.de_mare@nokia.com> |
---|---|
date | Thu, 09 Mar 2023 14:00:02 +0100 |
parents | ae6427d1c8f7 |
children | 3f9dd44be8c2 |
rev | line source |
---|---|
80
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
1 import os, time |
66 | 2 from distutils.core import setup |
3 | |
162
e0678dfb7aec
setup: parse PKG-INFO for version information (issue3924)
Peter Elmers <peter.elmers@yahoo.com>
parents:
160
diff
changeset
|
4 # query Mercurial for version number, or pull from PKG-INFO |
80
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
5 version = 'unknown' |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
6 if os.path.isdir('.hg'): |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
7 cmd = "hg id -i -t" |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
8 l = os.popen(cmd).read().split() |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
9 while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
10 l.pop() |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
11 if len(l) > 1: # tag found |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
12 version = l[-1] |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
13 if l[0].endswith('+'): # propagate the dirty status to the tag |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
14 version += '+' |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
15 elif len(l) == 1: # no tag found |
220
ae6427d1c8f7
hglib: try to fix version to comply with PEP440
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
186
diff
changeset
|
16 cmd1 = 'hg parents --template "{latesttag}"' |
ae6427d1c8f7
hglib: try to fix version to comply with PEP440
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
186
diff
changeset
|
17 cmd2 = 'hg parents --template "{latesttagdistance}"' |
ae6427d1c8f7
hglib: try to fix version to comply with PEP440
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
186
diff
changeset
|
18 version = os.popen(cmd1).read() + ".dev" + os.popen(cmd2).read() |
80
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
19 if version.endswith('+'): |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
20 version += time.strftime('%Y%m%d') |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
21 elif os.path.exists('.hg_archival.txt'): |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
22 kw = dict([[t.strip() for t in l.split(':', 1)] |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
23 for l in open('.hg_archival.txt')]) |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
24 if 'tag' in kw: |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
25 version = kw['tag'] |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
26 elif 'latesttag' in kw: |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
27 version = '%(latesttag)s+%(latesttagdistance)s-%(node).12s' % kw |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
28 else: |
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
29 version = kw.get('node', '')[:12] |
162
e0678dfb7aec
setup: parse PKG-INFO for version information (issue3924)
Peter Elmers <peter.elmers@yahoo.com>
parents:
160
diff
changeset
|
30 elif os.path.exists('PKG-INFO'): |
e0678dfb7aec
setup: parse PKG-INFO for version information (issue3924)
Peter Elmers <peter.elmers@yahoo.com>
parents:
160
diff
changeset
|
31 kw = dict([[t.strip() for t in l.split(':', 1)] |
e0678dfb7aec
setup: parse PKG-INFO for version information (issue3924)
Peter Elmers <peter.elmers@yahoo.com>
parents:
160
diff
changeset
|
32 for l in open('PKG-INFO') if ':' in l]) |
e0678dfb7aec
setup: parse PKG-INFO for version information (issue3924)
Peter Elmers <peter.elmers@yahoo.com>
parents:
160
diff
changeset
|
33 version = kw.get('Version', version) |
80
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
34 |
66 | 35 setup( |
36 name='python-hglib', | |
80
009e7858a93b
setup: add version number lookup
Matt Mackall <mpm@selenic.com>
parents:
66
diff
changeset
|
37 version=version, |
66 | 38 author='Idan Kamara', |
39 author_email='idankk86@gmail.com', | |
186
d06b48001662
package: update package url
Boris Feld <boris.feld@octobus.net>
parents:
162
diff
changeset
|
40 url='https://www.mercurial-scm.org/wiki/PythonHglibs', |
66 | 41 description='Mercurial Python library', |
134 | 42 long_description=open(os.path.join(os.path.dirname(__file__), |
43 'README')).read(), | |
160
91329df47df5
hglib: declare hglib's Python version support (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
44 classifiers=[ |
91329df47df5
hglib: declare hglib's Python version support (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
45 'Programming Language :: Python', |
91329df47df5
hglib: declare hglib's Python version support (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
46 'Programming Language :: Python :: 2.4', |
91329df47df5
hglib: declare hglib's Python version support (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
47 'Programming Language :: Python :: 2.5', |
91329df47df5
hglib: declare hglib's Python version support (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
48 'Programming Language :: Python :: 2.6', |
91329df47df5
hglib: declare hglib's Python version support (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
49 'Programming Language :: Python :: 2.7', |
91329df47df5
hglib: declare hglib's Python version support (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
50 'Programming Language :: Python :: 3', |
91329df47df5
hglib: declare hglib's Python version support (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
51 'Programming Language :: Python :: 3.4', |
91329df47df5
hglib: declare hglib's Python version support (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
52 |
91329df47df5
hglib: declare hglib's Python version support (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
53 ], |
66 | 54 license='MIT', |
55 packages=['hglib']) |