tags:

views:

513

answers:

1

Hi,

I'm trying to set up thrift in order to incorporate with Cassandra, so when I ran the

setup.py

it out puts this message in command line

running build
running build_py
running build_ext
building 'thrift.protocol.fastbinary' extension
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python26\include -IC:\Pytho
n26\PC -c src/protocol/fastbinary.c -o build\temp.win32-2.6\Release\src\protocol
\fastbinary.o
src/protocol/fastbinary.c:24:24: netinet/in.h: No such file or directory
src/protocol/fastbinary.c:85:4: #error "Cannot determine endianness"
src/protocol/fastbinary.c: In function `writeI16':
src/protocol/fastbinary.c:295: warning: implicit declaration of function `htons'

src/protocol/fastbinary.c: In function `writeI32':
src/protocol/fastbinary.c:300: warning: implicit declaration of function `htonl'

src/protocol/fastbinary.c: In function `readI16':
src/protocol/fastbinary.c:688: warning: implicit declaration of function `ntohs'

src/protocol/fastbinary.c: In function `readI32':
src/protocol/fastbinary.c:696: warning: implicit declaration of function `ntohl'

error: command 'gcc' failed with exit status 1

Need some helping on this issue.I have already install the MigW32

Thanks.

A: 

I've only succeeded in installing Thrift with MSVC.

  • Install MSVC
  • Get Thrift
  • Apply thrift-252-python-msvc-1.diff patch (google it)

The fastbinary.c will be patched, but setup.py patch will fail, update manually from hints at setup.py.rej, here's a (seemingly) correct copy:

from distutils.core import setup, Extension
import sys

libraries = []

if sys.platform == 'win32':
    libraries.append('ws2_32')

fastbinarymod = Extension('thrift.protocol.fastbinary',
                          sources = ['src/protocol/fastbinary.c'],
                          libraries = libraries, 
        )

setup(name = 'Thrift',
      version = '0.1',
      description = 'Thrift Python Libraries',
      author = 'Thrift Developers',
      author_email = '[email protected]',
      url = 'http://incubator.apache.org/thrift/',
      license = 'Apache License 2.0',
      packages = [
        'thrift',
        'thrift.protocol',
        'thrift.transport',
        'thrift.server',
      ],
      package_dir = {'thrift' : 'src'},
      ext_modules = [fastbinarymod],
      )

Endianness test will fail, modify fastbinary.c (around line 68):

#ifdef _MSC_VER
  #define __BYTE_ORDER __LITTLE_ENDIAN
#endif

After that run python setup.py install, hopefully, you'll get what you need.

Slava N