This repository has been archived by the owner on Jul 16, 2023. It is now read-only.
forked from jbaiter/cld3
-
Notifications
You must be signed in to change notification settings - Fork 9
/
setup.py
executable file
·98 lines (81 loc) · 2.97 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python
import subprocess
from os import path, makedirs
from setuptools import setup, Extension
from distutils.command.build import build
from Cython.Build import cythonize
PROTOS = ["src/sentence.proto", "src/feature_extractor.proto",
"src/task_spec.proto"]
SOURCES = ["src/cld3.pyx",
"src/base.cc",
"src/cld_3/protos/src/feature_extractor.pb.cc",
"src/cld_3/protos/src/sentence.pb.cc",
"src/cld_3/protos/src/task_spec.pb.cc",
"src/embedding_feature_extractor.cc",
"src/embedding_network.cc",
"src/feature_extractor.cc",
"src/feature_types.cc",
"src/fml_parser.cc",
"src/lang_id_nn_params.cc",
"src/language_identifier_features.cc",
"src/nnet_language_identifier.cc",
"src/registry.cc",
"src/relevant_script_feature.cc",
"src/script_span/fixunicodevalue.cc",
"src/script_span/generated_entities.cc",
"src/script_span/generated_ulscript.cc",
"src/script_span/getonescriptspan.cc",
"src/script_span/offsetmap.cc",
"src/script_span/text_processing.cc",
"src/script_span/utf8statetable.cc",
"src/sentence_features.cc",
"src/task_context.cc",
"src/task_context_params.cc",
"src/unicodetext.cc",
"src/utils.cc",
"src/workspace.cc"]
INCLUDES = ["./src", "./src/cld_3/protos/"]
LIBRARIES = ["protobuf"]
LONG_DESCRIPTION = \
"""Python bindings for the CLD3 language classification library by Google."""
CLASSIFIERS = [
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Programming Language :: C++",
"Operating System :: OS Independent",
"Development Status :: 4 - Beta",
"Topic :: Text Processing :: Linguistic",
"Intended Audience :: Developers",]
class BuildProtobuf(build):
def run(self):
if not path.exists("src/cld_3/protos"):
# Create protobufs dir
makedirs("src/cld_3/protos")
# Build protobuf stuff
command = ["protoc"]
command.extend(PROTOS)
command.append("--cpp_out={}".format(
path.join("src", "cld_3", "protos")))
subprocess.run(command, check=True)
build.run(self)
ext = Extension(
"cld3",
sources=SOURCES,
include_dirs=INCLUDES,
libraries=LIBRARIES,
language="c++",
extra_compile_args=["-std=c++11"])
setup(
name="cld3",
version="0.2.2",
cmdclass={"build": BuildProtobuf},
author="Google, Johannes Baiter, Elizabeth Myers",
author_email="[email protected]",
description="CLD3 Python bindings",
long_description=LONG_DESCRIPTION,
license="Apache2",
keywords=["cld3", "cffi"],
url="https://github.com/Elizafox/cld3",
ext_modules=cythonize([ext]))