Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.7, 0.7.1, and 0.7.2

setup: mimic Mercurial's new version scheme

setup.py uses 'hg id' to determine version, then stores in tortoise/__version__.py
version.py is unnecessary and removed

Changeset cc4bb7cd1c8a

Parent 62149b7b5a07

by Steve Borho

Changes to 2 files · Browse files at cc4bb7cd1c8a Showing diff from parent 62149b7b5a07 Diff from another changeset...

Change 1 of 1 Show Changes Only setup.py Stacked
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
 
 
 
 
 
 
 
76
77
78
 
 
 
 
 
 
 
79
80
81
 
82
83
84
85
86
87
88
89
90
91
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
 
 
74
75
76
77
78
79
80
81
 
 
82
83
84
85
86
87
88
89
90
 
91
92
93
94
95
96
97
98
99
100
101
 # setup.py  # A distutils setup script to register TortoiseHg COM server    # To build stand-alone package, use 'python setup.py py2exe' then use  # InnoSetup to build the installer. By default, the installer will be  # created as dist\Output\setup.exe.    import time  import sys  import os    # non-Win32 platforms doesn't require setup  if os.name != 'nt':   sys.stderr.write("abort: %s is for Win32 platforms only" % sys.argv[0])   sys.exit(1)    # ModuleFinder can't handle runtime changes to __path__, but win32com uses them    try:   # if this doesn't work, try import modulefinder   import py2exe.mf as modulefinder   import win32com   for p in win32com.__path__[1:]:   modulefinder.AddPackagePath("win32com", p)   for extra in ["win32com.shell"]: #,"win32com.mapi"   __import__(extra)   m = sys.modules[extra]   for p in m.__path__[1:]:   modulefinder.AddPackagePath(extra, p)  except ImportError:   # no build path setup, no worries.   pass    from distutils.core import setup  import py2exe    _data_files = []  extra = {}  hgextmods = []    if 'py2exe' in sys.argv:   # FIXME: quick hack to include installed hg extensions in py2exe binary   import hgext   hgextdir = os.path.dirname(hgext.__file__)   hgextmods = set(["hgext." + os.path.splitext(f)[0]   for f in os.listdir(hgextdir)])   _data_files = [(root, [os.path.join(root, file_) for file_ in files])   for root, dirs, files in os.walk('icons')]   extra['windows'] = [   {"script":"hgproc.py",   "icon_resources": [(1, "icons/tortoise/hg.ico")]},   {"script":"tracelog.py",   "icon_resources": [(1, "icons/tortoise/python.ico")]}   ]   extra['com_server'] = ["tortoisehg"]   extra['console'] = ["contrib/hg", "contrib/hgtk"]    opts = {   "py2exe" : {   # Don't pull in all this MFC stuff used by the makepy UI.   "excludes" : "pywin,pywin.dialogs,pywin.dialogs.list",     # add library files to support PyGtk-based dialogs/windows   # Note:   # after py2exe build, copy GTK's etc and lib directories into   # the dist directory created by py2exe.   # also needed is the GTK's share/themes (as dist/share/themes),   # for dialogs to display in MS-Windows XP theme.   "includes" : "dbhash,pango,atk,pangocairo,cairo,gobject," + \   ",".join(hgextmods),   }  }   -# specify version string, otherwise 'hg identify' will be used: -version = '' +try: + l = os.popen('hg id -it').read().split() + while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags + l.pop() + version = l and l[-1] or 'unknown' # latest tag or revision number + if version.endswith('+'): + version += time.strftime('%Y%m%d')   -import tortoise.version -tortoise.version.remember_version(version) +except OSError: + version = "unknown" + +f = file("tortoise/__version__.py", "w") +f.write('# this file is autogenerated by setup.py\n') +f.write('version = "%s"\n' % version) +f.close()    setup(name="TortoiseHg", - version=tortoise.version.get_version(), + version=version,   author='TK Soh',   author_email='teekaysoh@gmail.com',   url='http://tortoisehg.sourceforge.net',   description='Windows shell extension for Mercurial VCS',   license='GNU GPL2',   packages=['tortoise', 'hggtk', 'hggtk.vis', 'hggtk.iniparse'],   data_files = _data_files,   options=opts,   **extra   )
Change 1 of 1 Show Entire File tortoise/​version.py Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,82 +0,0 @@
-# Copyright (C) 2005, 2006 by Intevation GmbH -# Copyright (C) 2007 TK Soh <teekaysoh@gmail.com> -# -# Author(s): -# Thomas Arendsen Hein <thomas@intevation.de> -# TK Soh <teekaysoh@gmail.com> -# -# This program is free software under the GNU GPL (>=v2) -# Read the file COPYING coming with the software for details. - -""" -Tortoise version -""" - -import os -import os.path -import re -import time -from mercurial import util - -unknown_version = 'unknown' -remembered_version = False - -def get_version(doreload=False): - """Return version information if available.""" - try: - import tortoise.__version__ - if doreload: - reload(tortoise.__version__) - version = tortoise.__version__.version - except ImportError: - version = unknown_version - return version - -def write_version(version): - """Overwrite version file.""" - if version == get_version(): - return - directory = os.path.dirname(__file__) - for suffix in ['py', 'pyc', 'pyo']: - try: - os.unlink(os.path.join(directory, '__version__.%s' % suffix)) - except OSError: - pass - f = open(os.path.join(directory, '__version__.py'), 'w') - f.write("# This file is auto-generated.\n") - f.write("version = %r\n" % version) - f.close() - # reload the file we've just written - get_version(True) - -def remember_version(version=None): - """Store version information.""" - global remembered_version - if not version and os.path.isdir(".hg"): - f = os.popen("hg identify 2> %s" % util.nulldev) # use real hg installation - ident = f.read()[:-1] - if not f.close() and ident: - ids = ident.split(' ', 1) - version = ids.pop(0) - if version[-1] == '+': - version = version[:-1] - modified = True - else: - modified = False - if version.isalnum() and ids: - for tag in ids[0].split('/'): - # is a tag is suitable as a version number? - if re.match(r'^(\d+\.)+[\w.-]+$', tag): - version = tag - break - if modified: - version += time.strftime('+%Y%m%d') - if version: - remembered_version = True - write_version(version) - -def forget_version(): - """Remove version information.""" - if remembered_version: - write_version(unknown_version) -