#!/usr/bin/env python

###########################################################################
# TextIndexNG V 3                
# The next generation TextIndex for Zope
#
# This software is governed by a license. See
# LICENSE.txt for the terms of this license.
###########################################################################


import sys
import os
from setuptools import setup, find_packages, Extension

unicode_arg = sys.maxunicode>0xffff and "-DUNICODE_WIDTH=4" or "-DUNICODE_WIDTH=2" 
ext_args = sys.platform != "win32" and ['-Wall'] or [] 

version_txt = open('version.txt').read().strip()
description_txt = open('README.txt').read()
description_txt += '\n\nChanges\n-------\n\n'
description_txt += open('CHANGES.txt').read()


setup(name="zopyx.textindexng3",
      version = version_txt,
      maintainer= "Andreas Jung, ZOPYX Ltd. & Co. KG",
      maintainer_email = "info@zopyx.com",
      author = "Andreas Jung, ZOPYX Ltd. & Co. KG",
      author_email = "info@zopyx.com",
      description = 'Helper modules for TextIndexNG3 (Snowball stemmer, normalizer, splitter, etc.)',
      long_description = description_txt,
      url = "http://sf.net/projects/textindexng/",
      py_modules=['zopyx.__init__', 'zopyx.txng3.__init__'],
      install_requires=('setuptools',),
      namespace_packages=('zopyx',),

          ext_modules=[

            Extension("zopyx.txng3.normalizer",
                [ "zopyx/txng3/normalizer/normalizer.c" ],
            ),

            Extension("zopyx.txng3.splitter",
                [ "zopyx/txng3/splitter/splitter.c",
                  "zopyx/txng3/splitter/hashtable.c",
                  "zopyx/txng3/splitter/dict.c" 
                ],
            ),

            Extension("zopyx.txng3.support",
                [ "zopyx/txng3/support.c" ],
            ),

            Extension('zopyx.txng3.levenshtein',
                      sources = ['zopyx/txng3/python-Levenshtein-0.10/Levenshtein.c'],
                      extra_compile_args=ext_args),

            Extension("zopyx.txng3.stemmer",
                ["zopyx/txng3/stemmer/stemmer.c" ,
                 "zopyx/txng3/stemmer/libstemmer_c/libstemmer/libstemmer.c",
                 "zopyx/txng3/stemmer/libstemmer_c/runtime/api.c",
                 "zopyx/txng3/stemmer/libstemmer_c/runtime/utilities.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_ISO_8859_1_danish.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_ISO_8859_1_dutch.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_ISO_8859_1_english.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_ISO_8859_1_finnish.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_ISO_8859_1_french.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_ISO_8859_1_german.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_ISO_8859_1_hungarian.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_ISO_8859_1_italian.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_ISO_8859_1_norwegian.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_ISO_8859_1_porter.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_ISO_8859_1_portuguese.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_ISO_8859_2_romanian.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_ISO_8859_1_spanish.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_ISO_8859_1_swedish.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_KOI8_R_russian.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_UTF_8_danish.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_UTF_8_dutch.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_UTF_8_english.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_UTF_8_finnish.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_UTF_8_french.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_UTF_8_german.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_UTF_8_hungarian.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_UTF_8_kraaij_pohlmann.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_UTF_8_italian.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_UTF_8_norwegian.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_UTF_8_porter.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_UTF_8_portuguese.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_UTF_8_romanian.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_UTF_8_russian.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_UTF_8_spanish.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_UTF_8_swedish.c",
                 "zopyx/txng3/stemmer/libstemmer_c/src_c/stem_UTF_8_turkish.c",
                ],
                include_dirs=['zopyx/txng3/stemmer/libstemmer_c/include', 
                              'zopyx/txng3/stemmer/libstemmer_c',
                              'zopyx/txng3/stemmer/libstemmer_c/libstemmer'],
            ),
        ]
    )

