Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

setup.py 9.7 KB

You have to be logged in to leave a comment. Sign In
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
  1. # Copyright 2023 The HuggingFace Team. 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. """
  15. Simple check list from AllenNLP repo: https://github.com/allenai/allennlp/blob/main/setup.py
  16. To create the package for pypi.
  17. 1. Run `make pre-release` (or `make pre-patch` for a patch release) then run `make fix-copies` to fix the index of the
  18. documentation.
  19. If releasing on a special branch, copy the updated README.md on the main branch for your the commit you will make
  20. for the post-release and run `make fix-copies` on the main branch as well.
  21. 2. Run Tests for Amazon Sagemaker. The documentation is located in `./tests/sagemaker/README.md`, otherwise @philschmid.
  22. 3. Unpin specific versions from setup.py that use a git install.
  23. 4. Checkout the release branch (v<RELEASE>-release, for example v4.19-release), and commit these changes with the
  24. message: "Release: <RELEASE>" and push.
  25. 5. Wait for the tests on main to be completed and be green (otherwise revert and fix bugs)
  26. 6. Add a tag in git to mark the release: "git tag v<RELEASE> -m 'Adds tag v<RELEASE> for pypi' "
  27. Push the tag to git: git push --tags origin v<RELEASE>-release
  28. 7. Build both the sources and the wheel. Do not change anything in setup.py between
  29. creating the wheel and the source distribution (obviously).
  30. For the wheel, run: "python setup.py bdist_wheel" in the top level directory.
  31. (this will build a wheel for the python version you use to build it).
  32. For the sources, run: "python setup.py sdist"
  33. You should now have a /dist directory with both .whl and .tar.gz source versions.
  34. 8. Check that everything looks correct by uploading the package to the pypi test server:
  35. twine upload dist/* -r pypitest
  36. (pypi suggest using twine as other methods upload files via plaintext.)
  37. You may have to specify the repository url, use the following command then:
  38. twine upload dist/* -r pypitest --repository-url=https://test.pypi.org/legacy/
  39. Check that you can install it in a virtualenv by running:
  40. pip install -i https://testpypi.python.org/pypi diffusers
  41. Check you can run the following commands:
  42. python -c "from diffusers import pipeline; classifier = pipeline('text-classification'); print(classifier('What a nice release'))"
  43. python -c "from diffusers import *"
  44. 9. Upload the final version to actual pypi:
  45. twine upload dist/* -r pypi
  46. 10. Copy the release notes from RELEASE.md to the tag in github once everything is looking hunky-dory.
  47. 11. Run `make post-release` (or, for a patch release, `make post-patch`). If you were on a branch for the release,
  48. you need to go back to main before executing this.
  49. """
  50. import os
  51. import re
  52. from distutils.core import Command
  53. from setuptools import find_packages, setup
  54. # IMPORTANT:
  55. # 1. all dependencies should be listed here with their version requirements if any
  56. # 2. once modified, run: `make deps_table_update` to update src/diffusers/dependency_versions_table.py
  57. _deps = [
  58. "Pillow", # keep the PIL.Image.Resampling deprecation away
  59. "accelerate>=0.11.0",
  60. "compel==0.1.8",
  61. "black~=23.1",
  62. "datasets",
  63. "filelock",
  64. "flax>=0.4.1",
  65. "hf-doc-builder>=0.3.0",
  66. "huggingface-hub>=0.13.2",
  67. "requests-mock==1.10.0",
  68. "importlib_metadata",
  69. "isort>=5.5.4",
  70. "jax>=0.2.8,!=0.3.2",
  71. "jaxlib>=0.1.65",
  72. "Jinja2",
  73. "k-diffusion>=0.0.12",
  74. "librosa",
  75. "note-seq",
  76. "numpy",
  77. "parameterized",
  78. "protobuf>=3.20.3,<4",
  79. "pytest",
  80. "pytest-timeout",
  81. "pytest-xdist",
  82. "ruff>=0.0.241",
  83. "safetensors",
  84. "sentencepiece>=0.1.91,!=0.1.92",
  85. "scipy",
  86. "regex!=2019.12.17",
  87. "requests",
  88. "tensorboard",
  89. "torch>=1.4",
  90. "torchvision",
  91. "transformers>=4.25.1",
  92. ]
  93. # this is a lookup table with items like:
  94. #
  95. # tokenizers: "huggingface-hub==0.8.0"
  96. # packaging: "packaging"
  97. #
  98. # some of the values are versioned whereas others aren't.
  99. deps = {b: a for a, b in (re.findall(r"^(([^!=<>~]+)(?:[!=<>~].*)?$)", x)[0] for x in _deps)}
  100. # since we save this data in src/diffusers/dependency_versions_table.py it can be easily accessed from
  101. # anywhere. If you need to quickly access the data from this table in a shell, you can do so easily with:
  102. #
  103. # python -c 'import sys; from diffusers.dependency_versions_table import deps; \
  104. # print(" ".join([ deps[x] for x in sys.argv[1:]]))' tokenizers datasets
  105. #
  106. # Just pass the desired package names to that script as it's shown with 2 packages above.
  107. #
  108. # If diffusers is not yet installed and the work is done from the cloned repo remember to add `PYTHONPATH=src` to the script above
  109. #
  110. # You can then feed this for example to `pip`:
  111. #
  112. # pip install -U $(python -c 'import sys; from diffusers.dependency_versions_table import deps; \
  113. # print(" ".join([ deps[x] for x in sys.argv[1:]]))' tokenizers datasets)
  114. #
  115. def deps_list(*pkgs):
  116. return [deps[pkg] for pkg in pkgs]
  117. class DepsTableUpdateCommand(Command):
  118. """
  119. A custom distutils command that updates the dependency table.
  120. usage: python setup.py deps_table_update
  121. """
  122. description = "build runtime dependency table"
  123. user_options = [
  124. # format: (long option, short option, description).
  125. ("dep-table-update", None, "updates src/diffusers/dependency_versions_table.py"),
  126. ]
  127. def initialize_options(self):
  128. pass
  129. def finalize_options(self):
  130. pass
  131. def run(self):
  132. entries = "\n".join([f' "{k}": "{v}",' for k, v in deps.items()])
  133. content = [
  134. "# THIS FILE HAS BEEN AUTOGENERATED. To update:",
  135. "# 1. modify the `_deps` dict in setup.py",
  136. "# 2. run `make deps_table_update``",
  137. "deps = {",
  138. entries,
  139. "}",
  140. "",
  141. ]
  142. target = "src/diffusers/dependency_versions_table.py"
  143. print(f"updating {target}")
  144. with open(target, "w", encoding="utf-8", newline="\n") as f:
  145. f.write("\n".join(content))
  146. extras = {}
  147. extras = {}
  148. extras["quality"] = deps_list("black", "isort", "ruff", "hf-doc-builder")
  149. extras["docs"] = deps_list("hf-doc-builder")
  150. extras["training"] = deps_list("accelerate", "datasets", "protobuf", "tensorboard", "Jinja2")
  151. extras["test"] = deps_list(
  152. "compel",
  153. "datasets",
  154. "Jinja2",
  155. "k-diffusion",
  156. "librosa",
  157. "note-seq",
  158. "parameterized",
  159. "pytest",
  160. "pytest-timeout",
  161. "pytest-xdist",
  162. "requests-mock",
  163. "safetensors",
  164. "sentencepiece",
  165. "scipy",
  166. "torchvision",
  167. "transformers",
  168. )
  169. extras["torch"] = deps_list("torch", "accelerate")
  170. if os.name == "nt": # windows
  171. extras["flax"] = [] # jax is not supported on windows
  172. else:
  173. extras["flax"] = deps_list("jax", "jaxlib", "flax")
  174. extras["dev"] = (
  175. extras["quality"] + extras["test"] + extras["training"] + extras["docs"] + extras["torch"] + extras["flax"]
  176. )
  177. install_requires = [
  178. deps["importlib_metadata"],
  179. deps["filelock"],
  180. deps["huggingface-hub"],
  181. deps["numpy"],
  182. deps["regex"],
  183. deps["requests"],
  184. deps["Pillow"],
  185. ]
  186. setup(
  187. name="diffusers",
  188. version="0.15.0.dev0", # expected format is one of x.y.z.dev0, or x.y.z.rc1 or x.y.z (no to dashes, yes to dots)
  189. description="Diffusers",
  190. long_description=open("README.md", "r", encoding="utf-8").read(),
  191. long_description_content_type="text/markdown",
  192. keywords="deep learning",
  193. license="Apache",
  194. author="The HuggingFace team",
  195. author_email="patrick@huggingface.co",
  196. url="https://github.com/huggingface/diffusers",
  197. package_dir={"": "src"},
  198. packages=find_packages("src"),
  199. include_package_data=True,
  200. python_requires=">=3.7.0",
  201. install_requires=install_requires,
  202. extras_require=extras,
  203. entry_points={"console_scripts": ["diffusers-cli=diffusers.commands.diffusers_cli:main"]},
  204. classifiers=[
  205. "Development Status :: 5 - Production/Stable",
  206. "Intended Audience :: Developers",
  207. "Intended Audience :: Education",
  208. "Intended Audience :: Science/Research",
  209. "License :: OSI Approved :: Apache Software License",
  210. "Operating System :: OS Independent",
  211. "Programming Language :: Python :: 3",
  212. "Programming Language :: Python :: 3.7",
  213. "Programming Language :: Python :: 3.8",
  214. "Programming Language :: Python :: 3.9",
  215. "Topic :: Scientific/Engineering :: Artificial Intelligence",
  216. ],
  217. cmdclass={"deps_table_update": DepsTableUpdateCommand},
  218. )
  219. # Release checklist
  220. # 1. Change the version in __init__.py and setup.py.
  221. # 2. Commit these changes with the message: "Release: Release"
  222. # 3. Add a tag in git to mark the release: "git tag RELEASE -m 'Adds tag RELEASE for pypi' "
  223. # Push the tag to git: git push --tags origin main
  224. # 4. Run the following commands in the top-level directory:
  225. # python setup.py bdist_wheel
  226. # python setup.py sdist
  227. # 5. Upload the package to the pypi test server first:
  228. # twine upload dist/* -r pypitest
  229. # twine upload dist/* -r pypitest --repository-url=https://test.pypi.org/legacy/
  230. # 6. Check that you can install it in a virtualenv by running:
  231. # pip install -i https://testpypi.python.org/pypi diffusers
  232. # diffusers env
  233. # diffusers test
  234. # 7. Upload the final version to actual pypi:
  235. # twine upload dist/* -r pypi
  236. # 8. Add release notes to the tag in github once everything is looking hunky-dory.
  237. # 9. Update the version in __init__.py, setup.py to the new version "-dev" and push to master
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...