forked from OpenNMT/CTranslate2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
121 lines (106 loc) · 4.04 KB
/
Copy pathsetup.py
File metadata and controls
121 lines (106 loc) · 4.04 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import glob
import os
import sys
import pybind11
from pybind11.setup_helpers import ParallelCompile
from setuptools import Extension, find_packages, setup
base_dir = os.path.dirname(os.path.abspath(__file__))
include_dirs = [pybind11.get_include()]
library_dirs = []
def _get_long_description():
readme_path = os.path.join(base_dir, "README.md")
if not os.path.exists(readme_path):
return ""
with open(readme_path, encoding="utf-8") as readme_file:
return readme_file.read()
def _get_project_version():
version_path = os.path.join(base_dir, "ctranslate2", "version.py")
version = {}
with open(version_path, encoding="utf-8") as fp:
exec(fp.read(), version)
return version["__version__"]
def _maybe_add_library_root(lib_name):
if "%s_ROOT" % lib_name in os.environ:
root = os.environ["%s_ROOT" % lib_name]
include_dirs.append("%s/include" % root)
for lib_dir in ("lib", "lib64"):
path = "%s/%s" % (root, lib_dir)
if os.path.exists(path):
library_dirs.append(path)
break
_maybe_add_library_root("CTRANSLATE2")
cflags = ["-std=c++17", "-fvisibility=hidden"]
ldflags = []
package_data = {}
if sys.platform == "darwin":
# std::visit requires macOS 10.14
cflags.append("-mmacosx-version-min=10.14")
ldflags.append("-Wl,-rpath,/usr/local/lib")
elif sys.platform == "win32":
cflags = ["/std:c++17", "/d2FH4-"]
package_data["ctranslate2"] = ["*.dll"]
elif sys.platform == "linux":
cflags.append("-fPIC")
ldflags.append("-Wl,-rpath,/usr/local/lib64:/usr/local/lib")
ctranslate2_module = Extension(
"ctranslate2._ext",
sources=glob.glob(os.path.join("cpp", "*.cc")),
extra_compile_args=cflags,
extra_link_args=ldflags,
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=["ctranslate2"],
)
ParallelCompile("CMAKE_BUILD_PARALLEL_LEVEL").install()
setup(
name="ctranslate2",
version=_get_project_version(),
license="MIT",
description="Fast inference engine for Transformer models",
long_description=_get_long_description(),
long_description_content_type="text/markdown",
author="OpenNMT",
url="https://opennmt.net",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: GPU :: NVIDIA CUDA :: 12 :: 12.4",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
],
project_urls={
"Documentation": "https://opennmt.net/CTranslate2",
"Forum": "https://forum.opennmt.net",
"Gitter": "https://gitter.im/OpenNMT/CTranslate2",
"Source": "https://github.com/OpenNMT/CTranslate2",
},
keywords="opennmt nmt neural machine translation cuda mkl inference quantization",
packages=find_packages(exclude=["bin"]),
package_data=package_data,
ext_modules=[ctranslate2_module],
python_requires=">=3.9",
install_requires=[
"setuptools",
"numpy",
"pyyaml>=5.3,<7",
],
entry_points={
"console_scripts": [
"ct2-fairseq-converter=ctranslate2.converters.fairseq:main",
"ct2-marian-converter=ctranslate2.converters.marian:main",
"ct2-openai-gpt2-converter=ctranslate2.converters.openai_gpt2:main",
"ct2-opennmt-py-converter=ctranslate2.converters.opennmt_py:main",
"ct2-opennmt-tf-converter=ctranslate2.converters.opennmt_tf:main",
"ct2-opus-mt-converter=ctranslate2.converters.opus_mt:main",
"ct2-transformers-converter=ctranslate2.converters.transformers:main",
],
},
)