forked from PyYoshi/cChardet
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix pep517 builds `python3 -m pep517.check` now passes * fix actions * try again * skip 36 * build portable * build portable * build portable * build portable * build portable * check * check * adjust * fix * pytest * pytest * pytest * pytest
- Loading branch information
Showing
4 changed files
with
117 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,8 @@ | |
# coding: utf-8 | ||
|
||
import os | ||
import sys | ||
import glob | ||
import codecs | ||
import re | ||
import pkgconfig | ||
from distutils.command.build_ext import build_ext | ||
from distutils import sysconfig | ||
|
||
|
@@ -17,19 +14,31 @@ | |
|
||
from Cython.Build import cythonize | ||
|
||
cchardet_dir = os.path.join("src", "cchardet") + os.path.sep | ||
|
||
try: | ||
ext_args = pkgconfig.parse('uchardet') | ||
except pkgconfig.PackageNotFoundError: | ||
include_path = os.environ.get('INCLUDE_PATH') | ||
library_path = os.environ.get('LIBRARY_PATH') | ||
join = os.path.join | ||
|
||
cchardet_dir = join("src", "cchardet") + os.path.sep | ||
uchardet_dir = join("src", "ext", "uchardet", "src") | ||
uchardet_lang_models_dir = join(uchardet_dir, "LangModels") | ||
|
||
cchardet_sources = [join("src", "cchardet", "_cchardet.pyx")] | ||
uchardet_sources = [ | ||
join(uchardet_dir, file) | ||
for file in os.listdir(uchardet_dir) | ||
if file.endswith(".cpp") | ||
] | ||
uchardet_lang_source = [ | ||
join(uchardet_lang_models_dir, file) | ||
for file in os.listdir(uchardet_lang_models_dir) | ||
if file.endswith(".cpp") | ||
] | ||
sources = cchardet_sources + uchardet_sources + uchardet_lang_source | ||
|
||
ext_args = { | ||
"include_dirs": uchardet_dir.split(os.pathsep), | ||
"library_dirs": uchardet_dir.split(os.pathsep), | ||
} | ||
|
||
ext_args = { | ||
'include_dirs': include_path.split(os.pathsep) if include_path else [], | ||
'library_dirs': library_path.split(os.pathsep) if library_path else [], | ||
'libraries': ['uchardet'], | ||
} | ||
|
||
# Remove the "-Wstrict-prototypes" compiler option, which isn't valid for C++. | ||
cfg_vars = sysconfig.get_config_vars() | ||
|
@@ -40,61 +49,61 @@ | |
# cfg_vars[key] = value.replace("-O2", "-O3") | ||
|
||
|
||
cchardet_module = Extension( | ||
'cchardet._cchardet', | ||
[ | ||
os.path.join('src', 'cchardet', '_cchardet.pyx') | ||
], | ||
language='c++', | ||
**ext_args | ||
) | ||
cchardet_module = Extension("cchardet._cchardet", sources, language="c++", **ext_args) | ||
|
||
|
||
def read(f): | ||
return open(os.path.join(os.path.dirname(__file__), f)).read().strip() | ||
|
||
|
||
with codecs.open(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'src', 'cchardet', 'version.py'), 'r', 'latin1') as fp: | ||
with codecs.open( | ||
os.path.join( | ||
os.path.abspath(os.path.dirname(__file__)), "src", "cchardet", "version.py" | ||
), | ||
"r", | ||
"latin1", | ||
) as fp: | ||
try: | ||
version = re.findall( | ||
r"^__version__ = '([^']+)'\r?$", fp.read(), re.M)[0] | ||
version = re.findall(r"^__version__ = '([^']+)'\r?$", fp.read(), re.M)[0] | ||
except IndexError: | ||
raise RuntimeError('Unable to determine version.') | ||
raise RuntimeError("Unable to determine version.") | ||
|
||
setup( | ||
name='faust-cchardet', | ||
author='PyYoshi', | ||
author_email='[email protected]', | ||
url=r'https://github.com/faust-streaming/cChardet', | ||
description='cChardet is high speed universal character encoding detector.', | ||
long_description='\n\n'.join((read('README.rst'), read('CHANGES.rst'))), | ||
name="faust-cchardet", | ||
author="PyYoshi", | ||
author_email="[email protected]", | ||
url=r"https://github.com/faust-streaming/cChardet", | ||
description="cChardet is high speed universal character encoding detector.", | ||
long_description="\n\n".join((read("README.rst"), read("CHANGES.rst"))), | ||
version=version, | ||
license='Mozilla Public License', | ||
license="Mozilla Public License", | ||
classifiers=[ | ||
'License :: OSI Approved :: Mozilla Public License 1.1 (MPL 1.1)', | ||
'License :: OSI Approved :: GNU General Public License (GPL)', | ||
'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)', | ||
'Programming Language :: Cython', | ||
'Programming Language :: Python', | ||
'Topic :: Software Development :: Libraries', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.6', | ||
'Programming Language :: Python :: 3.7', | ||
'Programming Language :: Python :: 3.8', | ||
'Programming Language :: Python :: 3.9', | ||
'Programming Language :: Python :: 3.10', | ||
'Programming Language :: Python :: 3.11', | ||
"License :: OSI Approved :: Mozilla Public License 1.1 (MPL 1.1)", | ||
"License :: OSI Approved :: GNU General Public License (GPL)", | ||
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)", | ||
"Programming Language :: Cython", | ||
"Programming Language :: Python", | ||
"Topic :: Software Development :: Libraries", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.6", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
], | ||
keywords=[ | ||
'cython', | ||
'chardet', | ||
'charsetdetect' | ||
keywords=["cython", "chardet", "charsetdetect"], | ||
cmdclass={"build_ext": build_ext}, | ||
package_dir={"": "src"}, | ||
packages=[ | ||
"cchardet", | ||
], | ||
cmdclass={'build_ext': build_ext}, | ||
package_dir={'': 'src'}, | ||
packages=['cchardet', ], | ||
scripts=['bin/cchardetect'], | ||
ext_modules=cythonize([ | ||
cchardet_module, | ||
]), | ||
scripts=["bin/cchardetect"], | ||
ext_modules=cythonize( | ||
[ | ||
cchardet_module, | ||
], | ||
cplus=True, | ||
compiler_directives={"language_level": "3"}, # Python 3 | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters