-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathsetup.py
61 lines (53 loc) · 1.91 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import pathlib
import setuptools
import subprocess
import os
from distutils.core import setup
from distutils.extension import Extension
def mecab_config(arg):
output = subprocess.check_output(["mecab-config", arg])
if not isinstance(output, str):
output = output.decode("utf-8")
return output.split()
is_windows = os.name == 'nt'
win_mecab_dir = r'C:\mecab'
win_sdk_dir = win_mecab_dir
win_bin_dir = win_mecab_dir
# If you want to use official Windows binary, you can comment out following variables
#is_64bits = sys.maxsize > 2**32
#win_mecab_dir = r'C:\Program Files{}\MeCab'.format('' if is_64bits else ' (x86)')
#win_sdk_dir = r'{}\sdk'.format(win_mecab_dir)
#win_bin_dir = r'{}\bin'.format(win_mecab_dir)
if is_windows:
include_dirs = [win_sdk_dir]
library_dirs = [win_sdk_dir]
libraries = ["libmecab"]
data_files = [("lib\\site-packages\\", ["{}\\libmecab.dll".format(win_bin_dir)])]
else:
include_dirs = mecab_config("--inc-dir")
library_dirs = mecab_config("--libs-only-L")
libraries = mecab_config("--libs-only-l")
data_files = []
extensions = Extension('fugashi',
['fugashi/fugashi.pyx'],
libraries=libraries,
library_dirs=library_dirs,
include_dirs=include_dirs)
setup(name='fugashi',
use_scm_version=True,
author="Paul O'Leary McCann",
author_email="[email protected]",
description="A Cython wrapper for MeCab",
long_description=pathlib.Path('README.md').read_text('utf8'),
long_description_content_type="text/markdown",
url="https://github.com/polm/fugashi",
packages=setuptools.find_packages(),
install_requires=['Cython'],
classifiers=[
"License :: OSI Approved :: MIT License",
"Natural Language :: Japanese",
],
python_requires='>=3.6',
ext_modules=[extensions],
data_files=data_files,
setup_requires=['wheel', 'Cython', 'setuptools_scm'])