##// END OF EJS Templates
setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho -
r6373:7010e455 default
parent child Browse files
Show More
@@ -24,20 +24,32 b' extra = {}'
24 # that actually removes its temporary files.
24 # that actually removes its temporary files.
25 def has_function(cc, funcname):
25 def has_function(cc, funcname):
26 tmpdir = tempfile.mkdtemp(prefix='hg-install-')
26 tmpdir = tempfile.mkdtemp(prefix='hg-install-')
27 devnull = oldstderr = None
27 try:
28 try:
28 fname = os.path.join(tmpdir, 'funcname.c')
29 f = open(fname, 'w')
30 f.write('int main(void) {\n')
31 f.write(' %s();\n' % funcname)
32 f.write('}\n')
33 f.close()
34 try:
29 try:
30 fname = os.path.join(tmpdir, 'funcname.c')
31 f = open(fname, 'w')
32 f.write('int main(void) {\n')
33 f.write(' %s();\n' % funcname)
34 f.write('}\n')
35 f.close()
36 # Redirect stderr to /dev/null to hide any error messages
37 # from the compiler.
38 # This will have to be changed if we ever have to check
39 # for a function on Windows.
40 devnull = open('/dev/null', 'w')
41 oldstderr = os.dup(sys.stderr.fileno())
42 os.dup2(devnull.fileno(), sys.stderr.fileno())
35 objects = cc.compile([fname])
43 objects = cc.compile([fname])
36 cc.link_executable(objects, os.path.join(tmpdir, "a.out"))
44 cc.link_executable(objects, os.path.join(tmpdir, "a.out"))
37 except:
45 except:
38 return False
46 return False
39 return True
47 return True
40 finally:
48 finally:
49 if oldstderr is not None:
50 os.dup2(oldstderr, sys.stderr.fileno())
51 if devnull is not None:
52 devnull.close()
41 shutil.rmtree(tmpdir)
53 shutil.rmtree(tmpdir)
42
54
43 # py2exe needs to be installed to work
55 # py2exe needs to be installed to work
General Comments 0
You need to be logged in to leave comments. Login now