How to configure python cffi library to use mingw?
Asked Answered
E

1

6

Attempting to call cffi.FFI.verify() on windows will produce this error:

distutils.errors.DistutilsPlatformError: Unable to find vcvarsall.bat

I want to use mingw to compile instead of msvc. I tried to make distutils use mingw by creating c:\Python27\Lib\distutils\distutils.cfg with

[build]
compiler = mingw32

but this doesn't seem to affect cffi, I still get vcvarsall.bat missing error.

So how can I make cffi use gcc/mingw (or in general other C compiler)?

Endstopped answered 28/5, 2013 at 8:44 Comment(2)
What does return gcc --version in a Command Prompt ? Is the path to MinGW/bin correctly set in your PATH env. var. ?Creese
Yes they are. I can invoke gcc (GCC) 4.7.2 from the same cmd prompt I want to run the python script. Windows path contains MinGW/bin dirEndstopped
C
2

Try to reinstall cffi, now that distutils is properly configured. For example using easy_install

easy_install cffi

Or even rebuild & install it from source using MinGW that way :

cd cffi-src-dir
python setup.py config --compiler=mingw32 build --compiler=mingw32 install
cd ..

This will make sure that cffi is correctly setup for use with MinGW... I guess...

Creese answered 28/5, 2013 at 12:17 Comment(2)
well, using pip or easy_install first fails with a distutils error complaining about a bad "-mno-cygwin" argument. After I remove said compiler argument from distutils/cygwincompiler.py (as per this problem bugs.python.org/issue12641), compilation starts but down in other gcc errors. I'll give up for the moment.Endstopped
Compiling from sources does not help, because setup.py uses distutils, hence you run into exactly the same issues as with pip or easy_install. BTW, initially I installed cffi by using the unofficial binaries from here lfd.uci.edu/~gohlke/pythonlibs. It works if you only use ABI, but when trying to use the API (and hence compile C) it fails as described in my original questionEndstopped

© 2022 - 2024 — McMap. All rights reserved.