2012-06-20 15:59:23 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# coding: utf-8
|
|
|
|
|
2012-06-26 07:00:39 +00:00
|
|
|
# python setup.py sdist --formats=gztar
|
|
|
|
|
2013-05-08 02:33:32 +00:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import platform
|
2013-06-09 10:37:34 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
from setuptools import setup, Extension
|
|
|
|
except ImportError:
|
|
|
|
from distutils.core import setup, Extension
|
|
|
|
|
2012-08-22 12:49:57 +00:00
|
|
|
import glob
|
2013-05-08 02:33:32 +00:00
|
|
|
try:
|
|
|
|
import Cython.Compiler.Main as cython_compiler
|
|
|
|
have_cython = True
|
|
|
|
except ImportError:
|
|
|
|
have_cython = False
|
2012-08-22 12:49:57 +00:00
|
|
|
from distutils.command.build_ext import build_ext
|
2012-06-23 03:27:19 +00:00
|
|
|
|
2013-05-08 05:58:19 +00:00
|
|
|
try:
|
|
|
|
import pypissh
|
|
|
|
except ImportError:
|
|
|
|
# non-developer
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
pypissh.monkeypatch()
|
|
|
|
|
2012-06-26 07:00:39 +00:00
|
|
|
DEBUG = False
|
|
|
|
|
2012-08-22 12:49:57 +00:00
|
|
|
src_dir = 'src'
|
2012-06-26 07:00:39 +00:00
|
|
|
ext_dir = os.path.join(src_dir,'ext')
|
2012-08-22 12:49:57 +00:00
|
|
|
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/")
|
2012-06-23 03:27:19 +00:00
|
|
|
|
2013-05-08 02:33:32 +00:00
|
|
|
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))
|
2012-08-22 12:49:57 +00:00
|
|
|
cchardet_sources = glob.glob(cchardet_dir+'*.cpp')
|
|
|
|
sources = cchardet_sources + [os.path.join(charsetdetect_dir,"charsetdetect.cpp")] + glob.glob(uchardet_dir+'*.cpp')
|
2012-06-23 03:27:19 +00:00
|
|
|
|
2012-06-26 00:44:17 +00:00
|
|
|
macros = []
|
2012-07-07 03:44:19 +00:00
|
|
|
extra_compile_args = []
|
|
|
|
extra_link_args = []
|
|
|
|
|
2012-06-26 00:44:17 +00:00
|
|
|
if platform.system() == "Windows":
|
|
|
|
macros.append(("WIN32","1"))
|
2012-06-23 03:27:19 +00:00
|
|
|
|
2012-06-26 07:00:39 +00:00
|
|
|
if DEBUG:
|
|
|
|
macros.append(("DEBUG_chardet","1"))
|
2012-07-07 03:44:19 +00:00
|
|
|
extra_compile_args.append("-g"),
|
|
|
|
extra_link_args.append("-g"),
|
2012-06-26 07:00:39 +00:00
|
|
|
|
|
|
|
cchardet_module = Extension("cchardet._cchardet",
|
2012-08-22 12:49:57 +00:00
|
|
|
sources = sources,
|
2012-06-26 00:44:17 +00:00
|
|
|
include_dirs = [uchardet_dir,nspr_emu_dir,charsetdetect_dir],
|
2012-06-23 03:27:19 +00:00
|
|
|
language = "c++",
|
2012-06-26 07:00:39 +00:00
|
|
|
define_macros=macros,
|
2012-06-23 03:27:19 +00:00
|
|
|
)
|
2012-06-20 01:41:36 +00:00
|
|
|
|
|
|
|
setup(
|
|
|
|
name = 'cchardet',
|
2012-06-26 07:00:39 +00:00
|
|
|
author = 'PyYoshi',
|
|
|
|
author_email = 'yohihiro_dot_m_at_gmail_dot_com',
|
2012-06-20 12:45:57 +00:00
|
|
|
url = r"https://github.com/PyYoshi/cChardet",
|
2012-06-26 07:00:39 +00:00
|
|
|
description = 'Universal encoding detector. This library is faster than chardet.',
|
2013-05-08 05:16:01 +00:00
|
|
|
long_description= """cChardet is high speed universal character encoding detector. - binding to charsetdetect.
|
2012-06-20 15:59:23 +00:00
|
|
|
This library is faster than chardet.
|
|
|
|
""",
|
2013-08-03 12:40:25 +00:00
|
|
|
version = '0.3.4',
|
2012-07-05 03:05:11 +00:00
|
|
|
license = 'MIT License',
|
2013-05-08 05:16:01 +00:00
|
|
|
classifiers = [
|
|
|
|
# http://pypi.python.org/pypi?:action=list_classifiers
|
|
|
|
'Development Status :: 4 - Beta',
|
|
|
|
'License :: OSI Approved :: MIT License',
|
|
|
|
'Programming Language :: Cython',
|
|
|
|
'Programming Language :: Python',
|
|
|
|
'Topic :: Software Development :: Libraries',
|
|
|
|
'Programming Language :: Python :: 2',
|
|
|
|
'Programming Language :: Python :: 3',
|
|
|
|
],
|
2012-06-20 15:59:23 +00:00
|
|
|
keywords = [
|
|
|
|
'cython',
|
|
|
|
'chardet',
|
|
|
|
'charsetdetect'
|
|
|
|
],
|
2012-06-20 01:41:36 +00:00
|
|
|
cmdclass = {'build_ext': build_ext},
|
2012-06-26 07:00:39 +00:00
|
|
|
package_dir = {"":src_dir},
|
|
|
|
packages = ['cchardet',],
|
2012-06-20 01:41:36 +00:00
|
|
|
ext_modules = [
|
2012-06-23 03:27:19 +00:00
|
|
|
cchardet_module
|
|
|
|
],
|
2013-08-03 12:40:25 +00:00
|
|
|
)
|