HeleneMuri / pythonxy

Automatically exported from code.google.com/p/pythonxy
0 stars 0 forks source link

In the pythonxy 2.7.9.0, the MinGW -mno-cygwin bug appears again #768

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
1. 2.7.9.0
2. Recommended setup + MinGW as additional plugin
3. Not customized
5. default path
6. For "All users"
7. Windows 7
8. No
9. a regular user
10. simply by double-clicking on the installer
11. you uninstalled any previous Python distribution (including the
official .msi)

What steps will reproduce the problem?
1. Try to run something that uses distutils/mingw

Expected output: it compiles. Result: MinGW complains about not knowing 
"-mno-cygwin"

The exact error occurs in the version detection in cygwincompiler.py. The lines:

  out = os.popen(gcc_exe + ' -dumpversion', 'r')
  out_string = out.read()

return out_string = None leading to a gcc_version of None, that is seen as < 
'4' and so the cygwin switch is added.

This doesn't seem to have changed since 2.7.8, so presumably something else 
happened that broke the version detection or earlier pythonxy versions had a 
patch that wasn't applied after the switch to msvc?

Original issue reported on code.google.com by Michael....@gmail.com on 14 Mar 2015 at 12:24

GoogleCodeExporter commented 9 years ago
Ok, it turns out this only happens if the call to distutils is made from inside 
a PyQt application. It seems to work fine on windows xp but not on windows 7. 
Contrary to my earlier statement, I've now also seen in it python 2.7.6.1.

The issues seems to be with distutils rather than pythonxy, which uses the 
deprecated os.popen() command to determine the MinGW version.

If anyone else has this issue, the following monkey patch fixes it:

import platform
if platform.system() == 'Windows':
    import subprocess
    def _ospop(command, mode='r', bufsize=0):
        if mode == 'r':
            return subprocess.Popen(command, shell=True, bufsize=bufsize,
                stdout=subprocess.PIPE).stdout
        else:
            return subprocess.Popen(command, shell=True, bufsize=bufsize,
                stdin=subprocess.PIPE).stdin
    os.popen = _ospop

Original comment by Michael....@gmail.com on 15 Mar 2015 at 9:44