Roumen Petrov added the comment: Oscar Benjamin wrote: > Oscar Benjamin added the comment: > > 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():
It seems to me you try to find another method to detect support of some options. Where is written that compiler is gcc ? Yes this is current distutils code but please review my set of patches > 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 not work in new cygwin (1.7) environment with true cross-compilers. Reason is simple - executable is not gcc. > 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? It is not enough. > Thanks, > Oscar > > ---------- > Roumen ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12641> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com