5

If I pip install cffi, I get this:

building '_cffi_backend' extension
c:\mingw\bin\gcc.exe -mdll -O -Wall -Ic/libffi_msvc -IC:\python27\include -IC:\python27\PC -c c/_cffi_backend.c -o build\temp.win32-2.7\Release\c\_cffi_backend.o
...
(lots of warnings)
...
c/libffi_msvc\win32.c: In function 'ffi_call_x86':
c/libffi_msvc\win32.c:48:2: error: '_asm' undeclared (first use in this function)
c/libffi_msvc\win32.c:48:2: note: each undeclared identifier is reported only once for each function it appears in
c/libffi_msvc\win32.c:48:7: error: expected ';' before '{' token
c/libffi_msvc\win32.c:162:1: warning: control reaches end of non-void function [-Wreturn-type]
error: command 'gcc' failed with exit status 1

This is using MinGW obviously.

I also tried installing from the wheel here:

pip install https://pypi.python.org/packages/cp27/c/cffi/cffi-0.8.6-cp27-none-win32.whl#md5=aedc78351af65c4f514df0f2812473eb

I get the following strange error:

Downloading/unpacking https://pypi.python.org/packages/cp27/c/cffi/cffi-0.8.6-cp27-none-win32.whl
  Downloading cffi-0.8.6-cp27-none-win32.whl (77kB): 77kB downloaded
  Running setup.py egg_info for package from https://pypi.python.org/packages/cp27/c/cffi/cffi-0.8.6-cp27-none-win32.whl
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
    IOError: [Errno 2] No such file or directory: 'c:\\users\\me\\appdata\\local\\temp\\pip-nkx4aq-build\\setup.py'

And in fact when I look in that (temp) pip-nkx4aq-build directory, I see that there is no setup.py there.

So, my question simply is, why would this fail, and what do I need to do to install cffi on Windows?

Range vs. Range
  • 325
  • 1
  • 3
  • 11

3 Answers3

1

It is known not to work, contributions welcome:

https://bitbucket.org/cffi/cffi/issue/159/python-setuppy-install-fails-with-mingw

Armin Rigo
  • 12,048
  • 37
  • 48
  • Are you saying that cffi is known not to be installable on Windows 32bit, or that cffi is there's a known incompatibility with MinGW but there are alternatives to MinGW so it's still possible to install cffi on Windows 32bit? (If the latter, of course I'd very much like to know what the work around is, and any pointers would be greatly appreciated!) – Range vs. Range Feb 15 '15 at 03:09
  • 1
    It works fine if you use the same compiler as the one with which the standard CPython is built (Visual C++ version xyz, for xyz depending on the version of CPython). This is the official position (https://docs.python.org/2/extending/windows.html): although sometimes other compilers will work too, you need to be aware of details to make it work --- which I am not, sorry `:-)` – Armin Rigo Feb 15 '15 at 09:20
1

You can download the cffi binary package and install, link address below: http://www.lfd.uci.edu/~gohlke/pythonlibs/

0

Two steps -

  1. run this command - sudo apt-get install libffi-dev (on Ubuntu and Debian)
  2. pip install cffi