0

I am using cffi to write a Python wrapper to a C library. I cannot manage to compile the library, distutils throws some cryptic distutils.errors.DistutilsPlatformError "\"GNU was unexpected at this time

Traceback (most recent call last):
  File "pre.py", line 26, in <module>
    ffi.compile()
  File "C:\Python34\lib\site-packages\cffi\api.py", line 583, in compile
    source_extension=source_extension, **kwds)
  File "C:\Python34\lib\site-packages\cffi\recompiler.py", line 1227, in recompi
le
    outputfilename = ffiplatform.compile('.', ext)
  File "C:\Python34\lib\site-packages\cffi\ffiplatform.py", line 38, in compile
    outputfilename = _build(tmpdir, ext)
  File "C:\Python34\lib\site-packages\cffi\ffiplatform.py", line 62, in _build
    dist.run_command('build_ext')
  File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Python34\lib\site-packages\setuptools\command\build_ext.py", line 49,
 in run
    _build_ext.run(self)
  File "C:\Python34\lib\distutils\command\build_ext.py", line 339, in run
    self.build_extensions()
  File "C:\Python34\lib\distutils\command\build_ext.py", line 448, in build_exte
nsions
    self.build_extension(ext)
  File "C:\Python34\lib\site-packages\setuptools\command\build_ext.py", line 174
, in build_extension
    _build_ext.build_extension(self, ext)
  File "C:\Python34\lib\distutils\command\build_ext.py", line 503, in build_exte
nsion
    depends=ext.depends)
  File "C:\Python34\lib\distutils\msvc9compiler.py", line 460, in compile
    self.initialize()
  File "C:\Python34\lib\distutils\msvc9compiler.py", line 371, in initialize
    vc_env = query_vcvarsall(VERSION, plat_spec)
  File "C:\Python34\lib\site-packages\setuptools\msvc9_support.py", line 52, in
query_vcvarsall
    return unpatched['query_vcvarsall'](version, *args, **kwargs)
  File "C:\Python34\lib\distutils\msvc9compiler.py", line 267, in query_vcvarsal
l
    raise DistutilsPlatformError(stderr.decode("mbcs"))
distutils.errors.DistutilsPlatformError: "\"GNU was unexpected at this time.

There is strictly nothing about this error in the Python docs.

My setup is the following: Windows 7 Visual studio C++ 2010

Running python in the console outputs this

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (In
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

And the toolchain environment variable is set properly

C:\Users\***>echo %VS100COMNTOOLS%
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\

I'm puzzled, cannot figure out what is going on here.

Overdrivr
  • 6,296
  • 5
  • 44
  • 70
  • The first question is if it has anything to do with cffi, or if you also get this obscure error when using distutils to compile any regular CPython C extension module (try "python setup.py build" in the source of, for example, cffi) – Armin Rigo Jan 19 '16 at 14:45
  • I was wondering the same thing. Turns out I am getting the same error while building cffi so it is definitely related to distutil and not cffi. – Overdrivr Jan 19 '16 at 14:59
  • I see that the build errors come from the file msvc9compiler.py, and if I open that file at the beginning the header is ```distutils.msvc9compiler Contains MSVCCompiler, an implementation of the abstract CCompiler class for the Microsoft Visual Studio 2008. The module is compatible with VS 2005 and VS 2008. You can find legacy support for older versions of VS in distutils.msvccompiler. ``` I thought with Python 3+ I needed to use Visual Studio 2010, not 2008. – Overdrivr Jan 19 '16 at 15:01
  • @ArminRigo Using python 2.7 and visual C++ compiler for python 2.7 (https://www.microsoft.com/en-us/download/confirmation.aspx?id=44266) everything builds just fine. Any idea why python 3 is performing the build with msvc9compiler (visual studio C++ 2008) ? – Overdrivr Jan 19 '16 at 15:53
  • 1
    Sorry, no idea. Wrong person to ask :-) You should probably try to rephrase the question to generally ask why you can't compile any C extension module with Python (not related to cffi). Write as many details of your config as possible, because googling around doesn't show other people getting the same error message. – Armin Rigo Jan 20 '16 at 15:20

0 Answers0