equal
deleted
inserted
replaced
92 scripts = ['hg'] |
92 scripts = ['hg'] |
93 if os.name == 'nt': |
93 if os.name == 'nt': |
94 # We remove hg.bat if we are able to build hg.exe. |
94 # We remove hg.bat if we are able to build hg.exe. |
95 scripts.append('contrib/win32/hg.bat') |
95 scripts.append('contrib/win32/hg.bat') |
96 |
96 |
97 # simplified version of distutils.ccompiler.CCompiler.has_function |
97 def cancompile(cc, code): |
98 # that actually removes its temporary files. |
|
99 def hasfunction(cc, funcname): |
|
100 tmpdir = tempfile.mkdtemp(prefix='hg-install-') |
98 tmpdir = tempfile.mkdtemp(prefix='hg-install-') |
101 devnull = oldstderr = None |
99 devnull = oldstderr = None |
102 try: |
100 try: |
103 fname = os.path.join(tmpdir, 'funcname.c') |
101 fname = os.path.join(tmpdir, 'testcomp.c') |
104 f = open(fname, 'w') |
102 f = open(fname, 'w') |
105 f.write('int main(void) {\n') |
103 f.write(code) |
106 f.write(' %s();\n' % funcname) |
|
107 f.write('}\n') |
|
108 f.close() |
104 f.close() |
109 # Redirect stderr to /dev/null to hide any error messages |
105 # Redirect stderr to /dev/null to hide any error messages |
110 # from the compiler. |
106 # from the compiler. |
111 # This will have to be changed if we ever have to check |
107 # This will have to be changed if we ever have to check |
112 # for a function on Windows. |
108 # for a function on Windows. |
122 if oldstderr is not None: |
118 if oldstderr is not None: |
123 os.dup2(oldstderr, sys.stderr.fileno()) |
119 os.dup2(oldstderr, sys.stderr.fileno()) |
124 if devnull is not None: |
120 if devnull is not None: |
125 devnull.close() |
121 devnull.close() |
126 shutil.rmtree(tmpdir) |
122 shutil.rmtree(tmpdir) |
|
123 |
|
124 # simplified version of distutils.ccompiler.CCompiler.has_function |
|
125 # that actually removes its temporary files. |
|
126 def hasfunction(cc, funcname): |
|
127 code = 'int main(void) { %s(); }\n' % funcname |
|
128 return cancompile(cc, code) |
127 |
129 |
128 # py2exe needs to be installed to work |
130 # py2exe needs to be installed to work |
129 try: |
131 try: |
130 import py2exe |
132 import py2exe |
131 py2exe.Distribution # silence unused import warning |
133 py2exe.Distribution # silence unused import warning |