95 extra['console'] = ['hg'] |
95 extra['console'] = ['hg'] |
96 |
96 |
97 except ImportError: |
97 except ImportError: |
98 pass |
98 pass |
99 |
99 |
|
100 version = None |
|
101 |
100 if os.path.isdir('.hg'): |
102 if os.path.isdir('.hg'): |
101 # execute hg out of this directory with a custom environment which |
103 # execute hg out of this directory with a custom environment which |
102 # includes the pure Python modules in mercurial/pure |
104 # includes the pure Python modules in mercurial/pure |
103 pypath = os.environ.get('PYTHONPATH', '') |
105 pypath = os.environ.get('PYTHONPATH', '') |
104 purepath = os.path.join('mercurial', 'pure') |
106 purepath = os.path.join('mercurial', 'pure') |
105 os.environ['PYTHONPATH'] = os.pathsep.join(['mercurial', purepath, pypath]) |
107 os.environ['PYTHONPATH'] = os.pathsep.join(['mercurial', purepath, pypath]) |
106 os.environ['HGRCPATH'] = '' # do not read any config file |
108 os.environ['HGRCPATH'] = '' # do not read any config file |
107 cmd = [sys.executable, 'hg', 'id', '-i', '-t'] |
109 cmd = [sys.executable, 'hg', 'id', '-i', '-t'] |
108 version = None |
|
109 |
110 |
110 l, e = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
111 l, e = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
111 stderr=subprocess.PIPE).communicate() |
112 stderr=subprocess.PIPE).communicate() |
112 os.environ['PYTHONPATH'] = pypath |
113 os.environ['PYTHONPATH'] = pypath |
113 |
114 |
120 l.pop() |
121 l.pop() |
121 if l: |
122 if l: |
122 version = l[-1] # latest tag or revision number |
123 version = l[-1] # latest tag or revision number |
123 if version.endswith('+'): |
124 if version.endswith('+'): |
124 version += time.strftime('%Y%m%d') |
125 version += time.strftime('%Y%m%d') |
125 |
126 elif os.path.exists('.hg_archival.txt'): |
126 if version: |
127 hgarchival = open('.hg_archival.txt') |
127 f = file("mercurial/__version__.py", "w") |
128 for line in hgarchival: |
128 f.write('# this file is autogenerated by setup.py\n') |
129 if line.startswith('node:'): |
129 f.write('version = "%s"\n' % version) |
130 version = line.split(':')[1].strip()[:12] |
130 f.close() |
131 break |
|
132 |
|
133 if version: |
|
134 f = file("mercurial/__version__.py", "w") |
|
135 f.write('# this file is autogenerated by setup.py\n') |
|
136 f.write('version = "%s"\n' % version) |
|
137 f.close() |
|
138 |
131 |
139 |
132 try: |
140 try: |
133 from mercurial import __version__ |
141 from mercurial import __version__ |
134 version = __version__.version |
142 version = __version__.version |
135 except ImportError: |
143 except ImportError: |