Repository: python-pillow/Pillow

Issue:
CI: AppVeyor mingw32 build failing
It's failing for all new builds.

Last good, 9 days ago:

* https://ci.appveyor.com/project/Python-pillow/pillow/builds/26385393

First bad, 8 days ago:

* https://ci.appveyor.com/project/Python-pillow/pillow/builds/26416349

```
...
  Running setup.py install for coverage: started
    Running setup.py install for coverage: finished with status 'error'
c:\msys64\usr\bin\bash :     ERROR: Command errored out with exit status 1:
At line:3 char:3
+   c:\msys64\usr\bin\bash -l -c c:\\pillow\\winbuild\\appveyor_install ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (    ERROR: Comm... exit status 1::String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
     command: c:/msys64/mingw32/bin/python3.exe -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:/Users/appveyor/AppData/Local/Temp/1/pip-install-k08_wbqc/coverage/setup.py'"'"'; 
__file__='"'"'C:/Users/appveyor/AppData/Local/Temp/1/pip-install-k08_wbqc/coverage/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', 
'"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record C:/Users/appveyor/AppData/Local/Temp/1/pip-record-navslj1n/install-record.txt --single-version-externally-managed --compile
         cwd: C:/Users/appveyor/AppData/Local/Temp/1/pip-install-k08_wbqc/coverage/
    Complete output (91 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.mingw-3.7
    creating build/lib.mingw-3.7/coverage
    copying coverage/annotate.py -> build/lib.mingw-3.7/coverage
    copying coverage/backunittest.py -> build/lib.mingw-3.7/coverage
    copying coverage/backward.py -> build/lib.mingw-3.7/coverage
    copying coverage/bytecode.py -> build/lib.mingw-3.7/coverage
    copying coverage/cmdline.py -> build/lib.mingw-3.7/coverage
    copying coverage/collector.py -> build/lib.mingw-3.7/coverage
    copying coverage/config.py -> build/lib.mingw-3.7/coverage
    copying coverage/control.py -> build/lib.mingw-3.7/coverage
    copying coverage/data.py -> build/lib.mingw-3.7/coverage
    copying coverage/debug.py -> build/lib.mingw-3.7/coverage
    copying coverage/env.py -> build/lib.mingw-3.7/coverage
    copying coverage/execfile.py -> build/lib.mingw-3.7/coverage
    copying coverage/files.py -> build/lib.mingw-3.7/coverage
    copying coverage/html.py -> build/lib.mingw-3.7/coverage
    copying coverage/misc.py -> build/lib.mingw-3.7/coverage
    copying coverage/multiproc.py -> build/lib.mingw-3.7/coverage
    copying coverage/parser.py -> build/lib.mingw-3.7/coverage
    copying coverage/phystokens.py -> build/lib.mingw-3.7/coverage
    copying coverage/pickle2json.py -> build/lib.mingw-3.7/coverage
    copying coverage/plugin.py -> build/lib.mingw-3.7/coverage
    copying coverage/plugin_support.py -> build/lib.mingw-3.7/coverage
    copying coverage/python.py -> build/lib.mingw-3.7/coverage
    copying coverage/pytracer.py -> build/lib.mingw-3.7/coverage
    copying coverage/report.py -> build/lib.mingw-3.7/coverage
    copying coverage/results.py -> build/lib.mingw-3.7/coverage
    copying coverage/summary.py -> build/lib.mingw-3.7/coverage
    copying coverage/templite.py -> build/lib.mingw-3.7/coverage
    copying coverage/version.py -> build/lib.mingw-3.7/coverage
    copying coverage/xmlreport.py -> build/lib.mingw-3.7/coverage
    copying coverage/__init__.py -> build/lib.mingw-3.7/coverage
    copying coverage/__main__.py -> build/lib.mingw-3.7/coverage
    creating build/lib.mingw-3.7/coverage/htmlfiles
    copying coverage/htmlfiles/coverage_html.js -> build/lib.mingw-3.7/coverage/htmlfiles
    copying coverage/htmlfiles/index.html -> build/lib.mingw-3.7/coverage/htmlfiles
    copying coverage/htmlfiles/jquery.ba-throttle-debounce.min.js -> build/lib.mingw-3.7/coverage/htmlfiles
    copying coverage/htmlfiles/jquery.hotkeys.js -> build/lib.mingw-3.7/coverage/htmlfiles
    copying coverage/htmlfiles/jquery.isonscreen.js -> build/lib.mingw-3.7/coverage/htmlfiles
    copying coverage/htmlfiles/jquery.min.js -> build/lib.mingw-3.7/coverage/htmlfiles
    copying coverage/htmlfiles/jquery.tablesorter.min.js -> build/lib.mingw-3.7/coverage/htmlfiles
    copying coverage/htmlfiles/keybd_closed.png -> build/lib.mingw-3.7/coverage/htmlfiles
    copying coverage/htmlfiles/keybd_open.png -> build/lib.mingw-3.7/coverage/htmlfiles
    copying coverage/htmlfiles/pyfile.html -> build/lib.mingw-3.7/coverage/htmlfiles
    copying coverage/htmlfiles/style.css -> build/lib.mingw-3.7/coverage/htmlfiles
    creating build/lib.mingw-3.7/coverage/fullcoverage
    copying coverage/fullcoverage/encodings.py -> build/lib.mingw-3.7/coverage/ful
lcoverage
    running build_ext
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:/Users/appveyor/AppData/Local/Temp/1/pip-install-k08_wbqc/coverage/setup.py", line 213, in <module>
        main()
      File "C:/Users/appveyor/AppData/Local/Temp/1/pip-install-k08_wbqc/coverage/setup.py", line 203, in main
        setup(**setup_args)
      File "C:/msys64/mingw32/lib/python3.7/site-packages\setuptools\__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "C:/msys64/mingw32/lib/python3.7\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:/msys64/mingw32/lib/python3.7\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "C:/msys64/mingw32/lib/python3.7\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:/msys64/mingw32/lib/python3.7/site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "C:/msys64/mingw32/lib/python3.7\distutils\command\install.py", line 546, in run
        self.run_command('build')
      File "C:/msys64/mingw32/lib/python3.7\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:/msys64/mingw32/lib/python3.7\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:/msys64/mingw32/lib/python3.7\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "C:/msys64/mingw32/lib/python3.7\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:/msys64/mingw32/lib/python3.7\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:/Users/appveyor/AppData/Local/Temp/1/pip-install-k08_wbqc/coverage/setup.py", line 141, in run
        build_ext.run(self)
      File "C:/msys64/mingw32/lib/python3.7\distutils\command\build_ext.py", line 310, in run
        force=self.force)
      File "C:/msys64/mingw32/lib/python3.7\distutils\ccompiler.py", line 1033, in new_compiler
        return klass(None, dry_run, force)
      File "C:/msys64/mingw32/lib/python3.7\distutils\cygwinccompiler.py", line 288, in __init__
        CygwinCCompiler.__init__ (self, verbose, dry_run, force)
      File "C:/msys64/mingw32/lib/python3.7\distutils\cygwinccompiler.py", line 127, in __init__
        if self.ld_version >= "2.10.90":
    TypeError: '>=' not supported between instances of 'NoneType' and 'str'
    ----------------------------------------
ERROR: Command errored out with exit status 1: c:/msys64/mingw32/bin/python3.exe -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:/Users/appveyor/AppData/Local/Temp/1/pip-install-k08_wbqc/coverage/setup.py'"'"'; 
__file__='"'"'C:/Users/appveyor/AppData/Local/Temp/1/pip-install-k08_wbqc/coverage/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', 
'"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record C:/Users/appveyor/AppData/Local/Temp/1/pip-record-navslj1n/install-record.txt --single-version-externally-managed --compile Check the logs 
for full command output.
```



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -118,6 +118,18 @@ class RequiredDependencyException(Exception):
 PLATFORM_MINGW = "mingw" in ccompiler.get_default_compiler()
 PLATFORM_PYPY = hasattr(sys, "pypy_version_info")
 
+if sys.platform == "win32" and PLATFORM_MINGW:
+    from distutils import cygwinccompiler
+
+    cygwin_versions = cygwinccompiler.get_versions()
+    if cygwin_versions[1] is None:
+        # ld version is None
+        # distutils cygwinccompiler might fetch the ld path from gcc
+        # Try the normal path instead
+        cygwin_versions = list(cygwin_versions)
+        cygwin_versions[1] = cygwinccompiler._find_exe_version("ld -v")
+        cygwinccompiler.get_versions = lambda: tuple(cygwin_versions)
+
 
 def _dbg(s, tp=None):
     if DEBUG:


Test patch: