Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
163 lines (142 loc) · 5.66 KB
/
Copy pathsetup.py
File metadata and controls
163 lines (142 loc) · 5.66 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
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
# -*- coding: utf-8 -*-
import os
import shutil
import setuptools
from setuptools.command.build_py import build_py as _build_py
package_root = os.path.abspath(os.path.dirname(__file__))
name = "dashscope"
description = "dashscope client sdk library"
def get_version():
version_file = os.path.join(package_root, name, "version.py")
version_ns = {}
with open(version_file, "r", encoding="utf-8") as f:
exec(compile(f.read(), version_file, "exec"), version_ns)
return version_ns["__version__"]
def get_dependencies(fname="requirements.txt"):
with open(
fname,
"r",
encoding="utf-8",
) as f: # pylint: disable=unspecified-encoding
dependencies = f.readlines()
return dependencies
url = "https://dashscope.aliyun.com/"
def readme():
with open(os.path.join(package_root, "README.md"), encoding="utf-8") as f:
content = f.read()
return content
class build_py(_build_py):
"""Build one clean package tree and bundle the top-level examples.
Setuptools incrementally copies files into ``build/lib`` but does not
delete modules removed from the source tree. That is unsafe for the 2.0
package migration: a stale ``dashscope/client/__init__.py`` shadows the
new ``dashscope/client.py`` and makes ``from dashscope.client import
Client`` fail in the built wheel. Remove the package build directory
before every build, then copy the current sources and examples only.
``examples/`` lives at the repository root (a sibling of
``dashscope/``) for visibility, but a wheel can only bundle files
that sit inside a package directory. Copy the tree into
``<build_lib>/dashscope/examples`` so an installed wheel exposes
``site-packages/dashscope/examples/``.
"""
def run(self):
source_package = os.path.abspath(os.path.join(package_root, name))
built_package = os.path.abspath(os.path.join(self.build_lib, name))
if built_package == source_package:
raise RuntimeError(
"build_lib must not point at the source package directory",
)
if os.path.isdir(built_package):
shutil.rmtree(built_package)
super().run()
src = os.path.join(package_root, "examples")
dst = os.path.join(self.build_lib, "dashscope", "examples")
if not os.path.isdir(src):
return
if os.path.exists(dst):
shutil.rmtree(dst)
shutil.copytree(
src,
dst,
ignore=shutil.ignore_patterns("__pycache__", "*.pyc"),
)
# Hoisted to a module-level name (like ``name``/``url`` above) so the
# static packaging audit in tests/legacy_1x/unit/test_packaging_metadata.py
# keeps seeing only literal-evaluable setup() kwargs.
cmdclass = {"build_py": build_py}
setuptools.setup(
name=name,
version=get_version(),
description=description,
long_description=readme(),
long_description_content_type="text/markdown",
author="Alibaba Cloud",
author_email="dashscope@alibabacloud.com",
license="Apache 2.0",
url=url,
project_urls={
"Documentation": "https://dashscope.github.io/dashscope-sdk-python/",
"Source": "https://github.com/dashscope/dashscope-sdk-python",
"Issues": "https://github.com/dashscope/dashscope-sdk-python/issues",
},
packages=setuptools.find_packages(
exclude=("tests", "tests.*"),
), # pylint: disable=superfluous-parens
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"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",
],
platforms="Posix; MacOS X; Windows",
python_requires=">=3.9",
install_requires=get_dependencies(),
include_package_data=True,
extras_require={
# Interactive AI assistant (DashScope SDK Expert); typer/rich are
# core deps. `expert` is the canonical name; the `acli*` names below
# are kept as backward-compatible aliases with identical deps.
"expert": ["dashscope-agenticx[tui]>=1.0.0,<2"],
"expert-anthropic": ["anthropic>=0.40,<2"],
"expert-openai": ["openai>=1.30,<4"],
"expert-voice": ["sounddevice>=0.4", "numpy>=1.20"],
"expert-camera": ["opencv-python-headless>=4.5"],
"expert-all": [
"dashscope-agenticx[tui]>=1.0.0,<2",
"anthropic>=0.40,<2",
"openai>=1.30,<4",
"sounddevice>=0.4",
"numpy>=1.20",
"opencv-python-headless>=4.5",
],
# Backward-compatible aliases for the original `acli` extra name.
"acli": ["dashscope-agenticx[tui]>=1.0.0,<2"],
"acli-anthropic": ["anthropic>=0.40,<2"],
"acli-openai": ["openai>=1.30,<4"],
"acli-voice": ["sounddevice>=0.4", "numpy>=1.20"],
"acli-camera": ["opencv-python-headless>=4.5"],
"acli-all": [
"dashscope-agenticx[tui]>=1.0.0,<2",
"anthropic>=0.40,<2",
"openai>=1.30,<4",
"sounddevice>=0.4",
"numpy>=1.20",
"opencv-python-headless>=4.5",
],
},
zip_safe=False,
cmdclass=cmdclass,
entry_points={
"console_scripts": [
"dashscope = dashscope.cli.main:main",
"dashscope1 = dashscope.legacy_1x.cli:main",
],
},
)