144 |
144 |
145 def runcmd(cmd, env): |
145 def runcmd(cmd, env): |
146 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
146 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
147 stderr=subprocess.PIPE, env=env) |
147 stderr=subprocess.PIPE, env=env) |
148 out, err = p.communicate() |
148 out, err = p.communicate() |
149 return out, err |
149 return p.returncode, out, err |
150 |
150 |
151 def runhg(cmd, env): |
151 def runhg(cmd, env): |
152 out, err = runcmd(cmd, env) |
152 returncode, out, err = runcmd(cmd, env) |
153 # If root is executing setup.py, but the repository is owned by |
153 # If root is executing setup.py, but the repository is owned by |
154 # another user (as in "sudo python setup.py install") we will get |
154 # another user (as in "sudo python setup.py install") we will get |
155 # trust warnings since the .hg/hgrc file is untrusted. That is |
155 # trust warnings since the .hg/hgrc file is untrusted. That is |
156 # fine, we don't want to load it anyway. Python may warn about |
156 # fine, we don't want to load it anyway. Python may warn about |
157 # a missing __init__.py in mercurial/locale, we also ignore that. |
157 # a missing __init__.py in mercurial/locale, we also ignore that. |
158 err = [e for e in err.splitlines() |
158 err = [e for e in err.splitlines() |
159 if not e.startswith(b'not trusting file') \ |
159 if not e.startswith(b'not trusting file') \ |
160 and not e.startswith(b'warning: Not importing') \ |
160 and not e.startswith(b'warning: Not importing') \ |
161 and not e.startswith(b'obsolete feature not enabled')] |
161 and not e.startswith(b'obsolete feature not enabled')] |
162 if err: |
162 if err or returncode != 0: |
163 printf("stderr from '%s':" % (' '.join(cmd)), file=sys.stderr) |
163 printf("stderr from '%s':" % (' '.join(cmd)), file=sys.stderr) |
164 printf(b'\n'.join([b' ' + e for e in err]), file=sys.stderr) |
164 printf(b'\n'.join([b' ' + e for e in err]), file=sys.stderr) |
165 return '' |
165 return '' |
166 return out |
166 return out |
167 |
167 |
402 f.write('# empty\n') |
402 f.write('# empty\n') |
403 |
403 |
404 # here no extension enabled, disabled() lists up everything |
404 # here no extension enabled, disabled() lists up everything |
405 code = ('import pprint; from mercurial import extensions; ' |
405 code = ('import pprint; from mercurial import extensions; ' |
406 'pprint.pprint(extensions.disabled())') |
406 'pprint.pprint(extensions.disabled())') |
407 out, err = runcmd([sys.executable, '-c', code], env) |
407 returncode, out, err = runcmd([sys.executable, '-c', code], env) |
408 if err: |
408 if err or returncode != 0: |
409 raise DistutilsExecError(err) |
409 raise DistutilsExecError(err) |
410 |
410 |
411 with open(self._indexfilename, 'w') as f: |
411 with open(self._indexfilename, 'w') as f: |
412 f.write('# this file is autogenerated by setup.py\n') |
412 f.write('# this file is autogenerated by setup.py\n') |
413 f.write('docs = ') |
413 f.write('docs = ') |