views:

364

answers:

2

I would like to install bitarray in Windows running python 2.6.

I have mingw32 installed, and I have C:\Python26\Lib\distutils\distutils.cfg set to:

[build]
compiler = mingw32

If I type, in a cmd.exe window:

C:\Documents and Settings\john\My Documents\bitarray-0.3.5>python setup.py install

I get:

[normal python messages skipped]
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python26\include -IC:\Python26\PC -c bitarray/_bitarray.c -o build\temp.win32-2.6\Release\bitarray\_bitarray.o
bitarray/_bitarray.c:2197: error: initializer element is not constant
bitarray/_bitarray.c:2197: error: (near initialization for `BitarrayIter_Type.tp_getattro')
bitarray/_bitarray.c:2206: error: initializer element is not constant
bitarray/_bitarray.c:2206: error: (near initialization for `BitarrayIter_Type.tp_iter')
bitarray/_bitarray.c:2232: error: initializer element is not constant
bitarray/_bitarray.c:2232: error: (near initialization for `Bitarraytype.tp_getattro')
bitarray/_bitarray.c:2253: error: initializer element is not constant
bitarray/_bitarray.c:2253: error: (near initialization for `Bitarraytype.tp_alloc')
bitarray/_bitarray.c:2255: error: initializer element is not constant
bitarray/_bitarray.c:2255: error: (near initialization for `Bitarraytype.tp_free')
error: command 'gcc' failed with exit status 1

Can anyone help?

+3  A: 

MingW cannot compile the bitarray sources, I tried with version 3.4.5 and get the same errors. However, it compiles fine with the Microsoft compiler.

For your convenience I've build msi and exe installers for Python 2.6:

http://starship.python.net/crew/theller/bitarray-0.3.5.win32-py2.6.msi

http://starship.python.net/crew/theller/bitarray-0.3.5.win32-py2.6.exe

Please point the bitarray author to them so that he can upload them to pypi.

theller
Thank you very much!
John Fouhy
A: 

I needed to build bitarray for myself (I needed bit shift), so I couldn't use your pre-built binaries. The problem lies in mingw not working properly with __declspec(dllimport). Python already solves this problem for cygwin builds by using auto-import instead of declspec. However, this is not enabled for mingw builds. So you either need to modify the PyAPI_FUNC macro in pyport.h or add

#define __CYGWIN__

to the bitarray sources.

Roman Plášil