paddlenlp
97 строк · 3.2 Кб
1# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import os
16
17from setuptools import Distribution, setup
18from setuptools.command.install import install
19
20
21class BinaryDistribution(Distribution):
22# when build the package, it will add
23# platform name such as "cp37-cp37m-linux_x86_64"
24def has_ext_modules(self):
25return True
26
27
28class InstallPlatlib(install):
29def finalize_options(self):
30install.finalize_options(self)
31if self.distribution.has_ext_modules():
32self.install_lib = self.install_platlib
33
34
35if os.name != "nt":
36package_data = {"fast_tokenizer": ["core_tokenizers.so", "commit.log"]}
37package_data["fast_tokenizer.libs"] = []
38else:
39package_data = {"fast_tokenizer": ["core_tokenizers.pyd", "core_tokenizers.lib", "commit.log"]}
40# Add icu dll
41package_data["fast_tokenizer.libs"] = ["icuuc70.dll", "icudt70.dll"]
42
43
44def get_version():
45f = open(os.path.join("python", "fast_tokenizer", "__init__.py"))
46lines = f.readlines()
47version = ""
48for line in lines:
49if line.startswith("__version__"):
50version = line.split("=")[1]
51version = version.strip().replace('"', "")
52break
53return version
54
55
56long_description = "PaddleNLP Fast Tokenizer Library written in C++ "
57setup(
58name="fast-tokenizer-python",
59version=get_version(),
60author="PaddlePaddle Speech and Language Team",
61author_email="paddlesl@baidu.com",
62description=long_description,
63long_description=long_description,
64zip_safe=False,
65url="https://github.com/PaddlePaddle/PaddleNLP/fast_tokenizer",
66package_dir={"": "python"},
67packages=[
68"fast_tokenizer",
69"fast_tokenizer.tokenizers_impl",
70"fast_tokenizer.normalizers",
71"fast_tokenizer.pretokenizers",
72"fast_tokenizer.models",
73"fast_tokenizer.postprocessors",
74"fast_tokenizer.libs",
75"fast_tokenizer.decoders",
76],
77package_data=package_data,
78extras_require={"test": ["pytest>=6.0"]},
79python_requires=">=3.6",
80cmdclass={"install": InstallPlatlib},
81license="Apache 2.0",
82distclass=BinaryDistribution,
83classifiers=[
84"Development Status :: 5 - Production/Stable",
85"Operating System :: OS Independent",
86"Intended Audience :: Developers",
87"Intended Audience :: Education",
88"Intended Audience :: Science/Research",
89"License :: OSI Approved :: Apache Software License",
90"Programming Language :: C++",
91"Programming Language :: Python :: 3.6",
92"Programming Language :: Python :: 3.7",
93"Programming Language :: Python :: 3.8",
94"Programming Language :: Python :: 3.9",
95"Programming Language :: Python :: 3.10",
96],
97)
98