Message189871
I have written a function that can be used to determine if the gcc
that distutils will use is from Cygwin or MinGW:
def is_cygwingcc():
'''Try to determine if the gcc that would be used is from cygwin.'''
out = Popen(['gcc', '-dumpmachine'], shell=True, stdout=PIPE).stdout
try:
out_string = out.read()
finally:
out.close()
# out_string is the target triplet cpu-vendor-os
# Cygwin's gcc sets the os to 'cygwin'
return out_string.strip().endswith('cygwin')
The idea is that 'gcc -dumpmachine' emits a string that always ends in
'cygwin' for the Cygwin gcc (please let me know if I'm wrong about
that). Earnie Boyd at mingw-users described this method for
distinguishing MinGW and Cygwin gcc as not being a bad idea:
http://permalink.gmane.org/gmane.comp.gnu.mingw.user/42137
With this the Mingw32CCompiler.__init__ method can be modified to do:
if self.gcc_version < '4' or is_cygwingcc():
no_cygwin = ' -mno-cygwin'
else:
no_cygwin = ''
self.set_executables(compiler='gcc%s -O -Wall' % no_cygwin,
compiler_so='gcc%s -mdll -O -Wall' % no_cygwin,
compiler_cxx='g++%s -O -Wall' % no_cygwin,
linker_exe='gcc%s' % no_cygwin,
linker_so='%s%s %s %s'
% (self.linker_dll, no_cygwin,
shared_option, entry_point))
This will fix the problem for MinGW, should not break existing
no-cygwin/gcc 3.x setups and preserves the error message currently
seen for no-cygwin with gcc 4.x. In other words it should satisfy
users in all three groups A, B and C referred to above. In particular
the is_cygwingcc() function hopefully addresses Martin's concern for
users in group C.
Is this approach acceptable?
Thanks,
Oscar |
|
Date |
User |
Action |
Args |
2013-05-23 17:57:54 | oscarbenjamin | set | recipients:
+ oscarbenjamin, loewis, doko, paul.moore, pje, geertj, schmir, tarek, jwilk, eric.araujo, rpetrov, cmcqueen1975, rubenvb, santoso.wijaya, alexis, Seppo.Yli-Olli, jonforums, RubyTuesdayDONO, Jeffrey.Armstrong, danmbox, Martin.Fiers, Pete.Forman |
2013-05-23 17:57:54 | oscarbenjamin | link | issue12641 messages |
2013-05-23 17:57:53 | oscarbenjamin | create | |
|