##// END OF EJS Templates
setup.py: subprocess instead of os.popen, sys.stderr.write instead of print...
Christian Ebert -
r8547:548fd7a0 default
parent child Browse files
Show More
@@ -26,7 +26,7 b' except:'
26 26 raise SystemExit(
27 27 "Couldn't import standard zlib (incomplete Python install).")
28 28
29 import os, time
29 import os, subprocess, time
30 30 import shutil
31 31 import tempfile
32 32 from distutils.core import setup, Extension
@@ -97,23 +97,25 b' try:'
97 97 except ImportError:
98 98 pass
99 99
100 if os.path.exists('.hg'):
100 if os.path.isdir('.hg'):
101 101 # execute hg out of this directory with a custom environment which
102 102 # includes the pure Python modules in mercurial/pure
103 103 pypath = os.environ.get('PYTHONPATH', '')
104 104 purepath = os.path.join('mercurial', 'pure')
105 105 os.environ['PYTHONPATH'] = os.pathsep.join(['mercurial', purepath, pypath])
106 106 os.environ['HGRCPATH'] = '' # do not read any config file
107 cmd = '%s hg id -it' % sys.executable
107 cmd = [sys.executable, 'hg', 'id', '-i', '-t']
108 108 version = None
109 109
110 try:
111 l = os.popen(cmd).read().split()
112 except OSError, e:
113 print "warning: could not establish Mercurial version: %s" % e
114
110 l, e = subprocess.Popen(cmd, stdout=subprocess.PIPE,
111 stderr=subprocess.PIPE).communicate()
115 112 os.environ['PYTHONPATH'] = pypath
116 113
114 if e:
115 sys.stderr.write('warning: could not establish Mercurial version: %s'
116 % e)
117 else:
118 l = l.split()
117 119 while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags
118 120 l.pop()
119 121 if l:
General Comments 0
You need to be logged in to leave comments. Login now