This commit is contained in:
PyYoshi 2016-10-17 14:36:43 +09:00
parent 9f5f50ad7d
commit a9d0533a1c

View file

@ -13,8 +13,10 @@ except ImportError:
from distutils.core import setup, Extension
import glob
try:
import Cython.Compiler.Main as cython_compiler
have_cython = True
except ImportError:
have_cython = False
@ -35,32 +37,33 @@ ext_dir = os.path.join(src_dir,'ext')
build_dir = 'build'
cchardet_dir = os.path.join(src_dir, 'cchardet/')
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/")
nspr_emu_dir = os.path.join(charsetdetect_dir, 'nspr-emu/')
uchardet_dir = os.path.join(charsetdetect_dir, 'mozilla/extensions/universalchardet/src/base/')
if have_cython:
pyx_sources = glob.glob(cchardet_dir + '*.pyx')
sys.stderr.write("cythonize: %r\n" % (pyx_sources,))
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')
sources = cchardet_sources + [os.path.join(charsetdetect_dir, 'charsetdetect.cpp')] + glob.glob(uchardet_dir + '*.cpp')
macros = []
extra_compile_args = []
extra_link_args = []
if platform.system() == "Windows":
macros.append(("WIN32","1"))
if platform.system() == 'Windows':
macros.append(('WIN32', '1'))
if DEBUG:
macros.append(("DEBUG_chardet","1"))
extra_compile_args.append("-g"),
extra_link_args.append("-g"),
macros.append(('DEBUG_chardet', '1'))
extra_compile_args.append('-g'),
extra_link_args.append('-g'),
cchardet_module = Extension("cchardet._cchardet",
cchardet_module = Extension(
'cchardet._cchardet',
sources=sources,
include_dirs=[uchardet_dir, nspr_emu_dir, charsetdetect_dir],
language = "c++",
language='c++',
define_macros=macros,
)
@ -68,11 +71,11 @@ setup(
name='cchardet',
author='PyYoshi',
author_email='myoshi321go_at_gmail_dot_com',
url = r"https://github.com/PyYoshi/cChardet",
url=r'https://github.com/PyYoshi/cChardet',
description='Universal encoding detector. This library is faster than chardet.',
long_description= """cChardet is high speed universal character encoding detector. - binding to charsetdetect.
long_description='''cChardet is high speed universal character encoding detector. - binding to charsetdetect.
This library is faster than chardet.
""",
''',
version='1.0.0',
license='MIT License',
classifiers=[
@ -89,7 +92,7 @@ This library is faster than chardet.
'charsetdetect'
],
cmdclass={'build_ext': build_ext},
package_dir = {"":src_dir},
package_dir={'': src_dir},
packages=['cchardet', ],
ext_modules=[
cchardet_module