-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathsetup.py
327 lines (298 loc) · 8.94 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import glob
import itertools
import os
from pathlib import Path
from setuptools import find_packages, setup
DEP_SPECS = {
"aiohttp": ">= 3.9",
"bce-python-sdk": ">= 0.9",
"chardet": "",
"chinese-calendar": "",
"colorlog": "",
"decord": "== 0.6.0; (platform_machine == 'x86_64' or platform_machine == 'AMD64') and sys_platform != 'darwin'",
"einops": "",
"faiss-cpu": "",
"fastapi": ">= 0.110",
"filelock": "",
"filetype": ">= 1.2",
"ftfy": "",
"GPUtil": ">= 1.4",
"imagesize": "",
"Jinja2": "",
"joblib": "",
"langchain": "== 0.2.17",
"langchain-community": "== 0.2.17",
"langchain-core": "",
"langchain-openai": "== 0.1.25",
"lxml": "",
"matplotlib": "",
"numpy": [
"== 1.24.4; python_version < '3.12'",
"== 1.26.4; python_version >= '3.12'",
],
"openai": "== 1.63.2",
"opencv-contrib-python": "== 4.10.0.84",
"openpyxl": "",
"packaging": "",
"pandas": "<= 1.5.3",
"pillow": "",
"premailer": "",
"prettytable": "",
"py-cpuinfo": "",
"pyclipper": "",
"pycocotools": "",
"pydantic": ">= 2",
"PyMuPDF": "",
"PyYAML": "== 6.0.2",
"regex": "",
"requests": "",
"ruamel.yaml": "",
"scikit-image": "",
"scikit-learn": "",
"shapely": "",
"soundfile": "",
"starlette": ">= 0.36",
"tokenizers": "== 0.19.1",
"tqdm": "",
"typing-extensions": "",
"ujson": "",
"uvicorn": ">= 0.16",
"yarl": ">= 1.9",
}
REQUIRED_DEPS = [
"chardet",
"colorlog",
"filelock",
"GPUtil",
"numpy",
"packaging",
# Currently it is not easy to make `pandas` optional
"pandas",
"pillow",
"prettytable",
"py-cpuinfo",
"pydantic",
"PyYAML",
"requests",
"ruamel.yaml",
"typing-extensions",
"ujson",
]
EXTRAS = {
"base": {
"cv": [
"faiss-cpu",
"matplotlib",
"opencv-contrib-python",
"pycocotools",
# Currently `PyMuPDF` is required by the image batch sampler
"PyMuPDF",
"scikit-image",
],
"multimodal": [
"einops",
"ftfy",
"Jinja2",
"opencv-contrib-python",
# For the same reason as in `cv`
"PyMuPDF",
"regex",
],
"ie": [
"ftfy",
"imagesize",
"langchain",
"langchain-community",
"langchain-core",
"langchain-openai",
"lxml",
"openai",
"opencv-contrib-python",
"openpyxl",
"premailer",
"pyclipper",
"PyMuPDF",
"scikit-learn",
"shapely",
"tokenizers",
],
"ocr": [
"ftfy",
"imagesize",
"lxml",
"opencv-contrib-python",
"openpyxl",
"premailer",
"pyclipper",
"PyMuPDF",
"scikit-learn",
"shapely",
"tokenizers",
],
"speech": [
"ftfy",
"Jinja2",
"regex",
"soundfile",
"tqdm",
],
"ts": [
"chinese-calendar",
"joblib",
"matplotlib",
"scikit-learn",
],
"video": [
"decord",
"opencv-contrib-python",
],
},
"plugins": {
"serving": [
"aiohttp",
"bce-python-sdk",
"fastapi",
"filetype",
"starlette",
"uvicorn",
"yarl",
],
},
}
def _get_dep_specs(deps):
dep_specs = []
for dep in deps:
val = DEP_SPECS[dep]
if not isinstance(val, list):
val = [val]
for v in val:
if not v:
dep_specs.append(dep)
else:
dep_specs.append(dep + " " + v)
return dep_specs
def _sort_dep_specs(dep_specs):
return sorted(dep_specs, key=str.lower)
def readme():
"""get readme"""
with open("README.md", "r", encoding="utf-8") as file:
return file.read()
def dependencies():
dep_specs = _get_dep_specs(REQUIRED_DEPS)
return _sort_dep_specs(dep_specs)
def extras():
dic = {}
all_dep_specs = set()
for group_name, group in EXTRAS.items():
group_dep_specs = set()
for extra_name, extra_deps in group.items():
extra_dep_specs = _get_dep_specs(extra_deps)
dic[extra_name] = _sort_dep_specs(extra_dep_specs)
group_dep_specs.update(extra_dep_specs)
dic[group_name] = _sort_dep_specs(group_dep_specs)
all_dep_specs.update(group_dep_specs)
dic["all"] = _sort_dep_specs(all_dep_specs)
return dic
def version():
"""get version"""
with open(os.path.join("paddlex", ".version"), "r") as file:
return file.read().rstrip()
def get_data_files(directory: str, filetypes: list = None):
all_files = []
filetypes = filetypes or []
for root, _, files in os.walk(directory):
rel_root = os.path.relpath(root, directory)
for file in files:
filepath = os.path.join(rel_root, file)
filetype = os.path.splitext(file)[1][1:]
if filetype in filetypes:
all_files.append(filepath)
return all_files
def packages_and_package_data():
"""get packages and package_data"""
def _recursively_find(pattern, exts=None):
for dir_ in glob.iglob(pattern):
for root, _, files in os.walk(dir_):
for f in files:
if exts is not None:
ext = os.path.splitext(f)[1]
if ext not in exts:
continue
yield os.path.join(root, f)
pkgs = find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"])
pkg_data = []
for p in itertools.chain(
_recursively_find("paddlex/configs/*", exts=[".yml", ".yaml"]),
):
if Path(p).suffix in (".pyc", ".pyo"):
continue
pkg_data.append(Path(p).relative_to("paddlex").as_posix())
pipeline_config = [
Path(p).relative_to("paddlex").as_posix()
for p in glob.glob("paddlex/pipelines/*.yaml")
]
pkg_data.append("inference/pipelines/ppchatocrv3/ch_prompt.yaml")
pkg_data.extend(pipeline_config)
pkg_data.append(".version")
pkg_data.append("hpip_links.html")
pkg_data.append("inference/utils/hpi_model_info_collection.json")
ops_file_dir = "paddlex/ops"
ops_file_types = ["h", "hpp", "cpp", "cc", "cu"]
return pkgs, {
"paddlex.ops": get_data_files(ops_file_dir, ops_file_types),
"paddlex": pkg_data,
}
if __name__ == "__main__":
pkgs, pkg_data = packages_and_package_data()
s = setup(
name="paddlex",
version=version(),
description=("Low-code development tool based on PaddlePaddle."),
long_description=readme(),
long_description_content_type="text/markdown",
author="PaddlePaddle Authors",
author_email="",
install_requires=dependencies(),
extras_require=extras(),
packages=pkgs,
package_data=pkg_data,
entry_points={
"console_scripts": [
"paddlex = paddlex.__main__:console_entry",
],
},
# PyPI package information
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
],
license="Apache 2.0",
keywords=["paddlepaddle"],
)