change the way to build in the absence of Cython

This commit is contained in:
PyYoshi 2013-05-08 11:33:32 +09:00
parent ea5a35d137
commit 5925c2415f
2 changed files with 13 additions and 5 deletions

View file

@ -1,4 +1,4 @@
include ez_setup.py *.txt
recursive-include src *.pyx *.pxd *.pxi *.py
recursive-include src *.pyx *.pxd *.pxi *.py *.cpp
recursive-include src/ext *.*
recursive-include test *.*

View file

@ -5,10 +5,16 @@
import ez_setup
ez_setup.use_setuptools()
import os,platform
import os
import sys
import platform
from setuptools import setup, Extension
import glob
import Cython.Compiler.Main as cython_compiler
try:
import Cython.Compiler.Main as cython_compiler
have_cython = True
except ImportError:
have_cython = False
from distutils.command.build_ext import build_ext
DEBUG = False
@ -21,8 +27,10 @@ charsetdetect_dir = os.path.join(ext_dir, 'libcharsetdetect/')
nspr_emu_dir = os.path.join(charsetdetect_dir,"nspr-emu/")
uchardet_dir = os.path.join(charsetdetect_dir,"mozilla/extensions/universalchardet/src/base/")
pyx_sources = glob.glob(cchardet_dir+'*.pyx')
cython_compiler.compile(pyx_sources,options=cython_compiler.CompilationOptions(cplus=True))
if have_cython:
pyx_sources = glob.glob(cchardet_dir+'*.pyx')
sys.stderr.write("cythonize: %r\n" % (pyx_sources,))
cython_compiler.compile(pyx_sources,options=cython_compiler.CompilationOptions(cplus=True))
cchardet_sources = glob.glob(cchardet_dir+'*.cpp')
sources = cchardet_sources + [os.path.join(charsetdetect_dir,"charsetdetect.cpp")] + glob.glob(uchardet_dir+'*.cpp')