techguytfs/voice_clone
0
1# Copyright 2021 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 at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# 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 and13# limitations under the License.14 15"""16Simple check list from AllenNLP repo: https://github.com/allenai/allennlp/blob/main/setup.py17 18To create the package for pypi.19 201. Create the release branch named: v<RELEASE>-release, for example v4.19-release. For a patch release checkout the21 current release branch.22 23 If releasing on a special branch, copy the updated README.md on the main branch for your the commit you will make24 for the post-release and run `make fix-copies` on the main branch as well.25 262. Run `make pre-release` (or `make pre-patch` for a patch release) and commit these changes with the message:27 "Release: <VERSION>" and push.28 293. Go back to the main branch and run `make post-release` then `make fix-copies`. Commit these changes with the30 message "v<NEXT_VERSION>.dev.0" and push to main.31 32# If you were just cutting the branch in preparation for a release, you can stop here for now.33 344. Wait for the tests on the release branch to be completed and be green (otherwise revert and fix bugs)35 365. On the release branch, add a tag in git to mark the release: "git tag v<VERSION> -m 'Adds tag v<VERSION> for pypi' "37 Push the tag to git: git push --tags origin v<RELEASE>-release38 396. Build both the sources and the wheel. Do not change anything in setup.py between40 creating the wheel and the source distribution (obviously).41 42 Run `make build-release`. This will build the release and do some sanity checks for you. If this ends with an error43 message, you need to fix things before going further.44 45 You should now have a /dist directory with both .whl and .tar.gz source versions.46 477. Check that everything looks correct by uploading the package to the pypi test server:48 49 twine upload dist/* -r testpypi50 (pypi suggest using twine as other methods upload files via plaintext.)51 You may have to specify the repository url, use the following command then:52 twine upload dist/* -r testpypi --repository-url=https://test.pypi.org/legacy/53 54 Check that you can install it in a virtualenv by running:55 pip install -i https://testpypi.python.org/pypi transformers56 57 Check you can run the following commands:58 python -c "from transformers import pipeline; classifier = pipeline('text-classification'); print(classifier('What a nice release'))"59 python -c "from transformers import *"60 python utils/check_build.py --check_lib61 62 If making a patch release, double check the bug you are patching is indeed resolved.63 648. Upload the final version to actual pypi:65 twine upload dist/* -r pypi66 679. Copy the release notes from RELEASE.md to the tag in github once everything is looking hunky-dory.68"""69 70import os71import re72import shutil73from pathlib import Path74 75from setuptools import Command, find_packages, setup76 77 78# Remove stale transformers.egg-info directory to avoid https://github.com/pypa/pip/issues/546679stale_egg_info = Path(__file__).parent / "transformers.egg-info"80if stale_egg_info.exists():81 print(82 (83 "Warning: {} exists.\n\n"84 "If you recently updated transformers to 3.0 or later, this is expected,\n"85 "but it may prevent transformers from installing in editable mode.\n\n"86 "This directory is automatically generated by Python's packaging tools.\n"87 "I will remove it now.\n\n"88 "See https://github.com/pypa/pip/issues/5466 for details.\n"89 ).format(stale_egg_info)90 )91 shutil.rmtree(stale_egg_info)92 93 94# IMPORTANT:95# 1. all dependencies should be listed here with their version requirements if any96# 2. once modified, run: `make deps_table_update` to update src/transformers/dependency_versions_table.py97_deps = [98 "Pillow<10.0.0",99 "accelerate>=0.20.3",100 "av==9.2.0", # Latest version of PyAV (10.0.0) has issues with audio stream.101 "beautifulsoup4",102 "black~=23.1",103 "codecarbon==1.2.0",104 "cookiecutter==1.7.3",105 "dataclasses",106 "datasets!=2.5.0",107 "decord==0.6.0",108 "deepspeed>=0.9.3",109 "diffusers",110 "dill<0.3.5",111 "evaluate>=0.2.0",112 "fairscale>0.3",113 "faiss-cpu",114 "fastapi",115 "filelock",116 "flax>=0.4.1,<=0.7.0",117 "ftfy",118 "fugashi>=1.0",119 "GitPython<3.1.19",120 "hf-doc-builder>=0.3.0",121 "huggingface-hub>=0.15.1,<1.0",122 "importlib_metadata",123 "ipadic>=1.0.0,<2.0",124 "isort>=5.5.4",125 "jax>=0.4.1,<=0.4.13",126 "jaxlib>=0.4.1,<=0.4.13",127 "jieba",128 "kenlm",129 "keras-nlp>=0.3.1",130 "librosa",131 "nltk",132 "natten>=0.14.6",133 "numpy>=1.17",134 "onnxconverter-common",135 "onnxruntime-tools>=1.4.2",136 "onnxruntime>=1.4.0",137 "opencv-python",138 "optuna",139 "optax>=0.0.8,<=0.1.4",140 "packaging>=20.0",141 "parameterized",142 "phonemizer",143 "protobuf",144 "psutil",145 "pyyaml>=5.1",146 "pydantic<2",147 "pytest>=7.2.0",148 "pytest-timeout",149 "pytest-xdist",150 "python>=3.8.0",151 "ray[tune]",152 "regex!=2019.12.17",153 "requests",154 "rhoknp>=1.1.0,<1.3.1",155 "rjieba",156 "rouge-score!=0.0.7,!=0.0.8,!=0.1,!=0.1.1",157 "ruff>=0.0.241,<=0.0.259",158 "sacrebleu>=1.4.12,<2.0.0",159 "sacremoses",160 "safetensors>=0.3.1",161 "sagemaker>=2.31.0",162 "scikit-learn",163 "sentencepiece>=0.1.91,!=0.1.92",164 "sigopt",165 "starlette",166 "sudachipy>=0.6.6",167 "sudachidict_core>=20220729",168 # TensorFlow pin. When changing this value, update examples/tensorflow/_tests_requirements.txt accordingly169 "tensorflow-cpu>=2.6,<2.15",170 "tensorflow>=2.6,<2.15",171 "tensorflow-text<2.15",172 "tf2onnx",173 "timeout-decorator",174 "timm",175 "tokenizers>=0.11.1,!=0.11.3,<0.14",176 "torch>=1.10,!=1.12.0",177 "torchaudio",178 "torchvision",179 "pyctcdecode>=0.4.0",180 "tqdm>=4.27",181 "unidic>=1.0.2",182 "unidic_lite>=1.0.7",183 "urllib3<2.0.0",184 "uvicorn",185]186 187 188# this is a lookup table with items like:189#190# tokenizers: "tokenizers==0.9.4"191# packaging: "packaging"192#193# some of the values are versioned whereas others aren't.194deps = {b: a for a, b in (re.findall(r"^(([^!=<>~ ]+)(?:[!=<>~ ].*)?$)", x)[0] for x in _deps)}195 196# since we save this data in src/transformers/dependency_versions_table.py it can be easily accessed from197# anywhere. If you need to quickly access the data from this table in a shell, you can do so easily with:198#199# python -c 'import sys; from transformers.dependency_versions_table import deps; \200# print(" ".join([ deps[x] for x in sys.argv[1:]]))' tokenizers datasets201#202# Just pass the desired package names to that script as it's shown with 2 packages above.203#204# If transformers is not yet installed and the work is done from the cloned repo remember to add `PYTHONPATH=src` to the script above205#206# You can then feed this for example to `pip`:207#208# pip install -U $(python -c 'import sys; from transformers.dependency_versions_table import deps; \209# print(" ".join([deps[x] for x in sys.argv[1:]]))' tokenizers datasets)210#211 212 213def deps_list(*pkgs):214 return [deps[pkg] for pkg in pkgs]215 216 217class DepsTableUpdateCommand(Command):218 """219 A custom distutils command that updates the dependency table.220 usage: python setup.py deps_table_update221 """222 223 description = "build runtime dependency table"224 user_options = [225 # format: (long option, short option, description).226 ("dep-table-update", None, "updates src/transformers/dependency_versions_table.py"),227 ]228 229 def initialize_options(self):230 pass231 232 def finalize_options(self):233 pass234 235 def run(self):236 entries = "\n".join([f' "{k}": "{v}",' for k, v in deps.items()])237 content = [238 "# THIS FILE HAS BEEN AUTOGENERATED. To update:",239 "# 1. modify the `_deps` dict in setup.py",240 "# 2. run `make deps_table_update``",241 "deps = {",242 entries,243 "}",244 "",245 ]246 target = "src/transformers/dependency_versions_table.py"247 print(f"updating {target}")248 with open(target, "w", encoding="utf-8", newline="\n") as f:249 f.write("\n".join(content))250 251 252extras = {}253 254extras["ja"] = deps_list("fugashi", "ipadic", "unidic_lite", "unidic", "sudachipy", "sudachidict_core", "rhoknp")255extras["sklearn"] = deps_list("scikit-learn")256 257extras["tf"] = deps_list("tensorflow", "onnxconverter-common", "tf2onnx", "tensorflow-text", "keras-nlp")258extras["tf-cpu"] = deps_list("tensorflow-cpu", "onnxconverter-common", "tf2onnx", "tensorflow-text", "keras-nlp")259 260extras["torch"] = deps_list("torch", "accelerate")261extras["accelerate"] = deps_list("accelerate")262 263if os.name == "nt": # windows264 extras["retrieval"] = deps_list("datasets") # faiss is not supported on windows265 extras["flax"] = [] # jax is not supported on windows266else:267 extras["retrieval"] = deps_list("faiss-cpu", "datasets")268 extras["flax"] = deps_list("jax", "jaxlib", "flax", "optax")269 270extras["tokenizers"] = deps_list("tokenizers")271extras["ftfy"] = deps_list("ftfy")272extras["onnxruntime"] = deps_list("onnxruntime", "onnxruntime-tools")273extras["onnx"] = deps_list("onnxconverter-common", "tf2onnx") + extras["onnxruntime"]274extras["modelcreation"] = deps_list("cookiecutter")275 276extras["sagemaker"] = deps_list("sagemaker")277extras["deepspeed"] = deps_list("deepspeed") + extras["accelerate"]278extras["fairscale"] = deps_list("fairscale")279extras["optuna"] = deps_list("optuna")280extras["ray"] = deps_list("ray[tune]")281extras["sigopt"] = deps_list("sigopt")282 283extras["integrations"] = extras["optuna"] + extras["ray"] + extras["sigopt"]284 285extras["serving"] = deps_list("pydantic", "uvicorn", "fastapi", "starlette")286extras["audio"] = deps_list("librosa", "pyctcdecode", "phonemizer", "kenlm")287# `pip install ".[speech]"` is deprecated and `pip install ".[torch-speech]"` should be used instead288extras["speech"] = deps_list("torchaudio") + extras["audio"]289extras["torch-speech"] = deps_list("torchaudio") + extras["audio"]290extras["tf-speech"] = extras["audio"]291extras["flax-speech"] = extras["audio"]292extras["vision"] = deps_list("Pillow")293extras["timm"] = deps_list("timm")294extras["torch-vision"] = deps_list("torchvision") + extras["vision"]295extras["natten"] = deps_list("natten")296extras["codecarbon"] = deps_list("codecarbon")297extras["video"] = deps_list("decord", "av")298 299extras["sentencepiece"] = deps_list("sentencepiece", "protobuf")300extras["testing"] = (301 deps_list(302 "pytest",303 "pytest-xdist",304 "timeout-decorator",305 "parameterized",306 "psutil",307 "datasets",308 "dill",309 "evaluate",310 "pytest-timeout",311 "black",312 "sacrebleu",313 "rouge-score",314 "nltk",315 "GitPython",316 "hf-doc-builder",317 "protobuf", # Can be removed once we can unpin protobuf318 "sacremoses",319 "rjieba",320 "beautifulsoup4",321 )322 + extras["retrieval"]323 + extras["modelcreation"]324)325 326extras["deepspeed-testing"] = extras["deepspeed"] + extras["testing"] + extras["optuna"] + extras["sentencepiece"]327 328extras["quality"] = deps_list("black", "datasets", "isort", "ruff", "GitPython", "hf-doc-builder", "urllib3")329 330extras["all"] = (331 extras["tf"]332 + extras["torch"]333 + extras["flax"]334 + extras["sentencepiece"]335 + extras["tokenizers"]336 + extras["torch-speech"]337 + extras["vision"]338 + extras["integrations"]339 + extras["timm"]340 + extras["torch-vision"]341 + extras["codecarbon"]342 + extras["accelerate"]343 + extras["video"]344)345 346# Might need to add doc-builder and some specific deps in the future347extras["docs_specific"] = ["hf-doc-builder"]348 349# "docs" needs "all" to resolve all the references350extras["docs"] = extras["all"] + extras["docs_specific"]351 352extras["dev-torch"] = (353 extras["testing"]354 + extras["torch"]355 + extras["sentencepiece"]356 + extras["tokenizers"]357 + extras["torch-speech"]358 + extras["vision"]359 + extras["integrations"]360 + extras["timm"]361 + extras["torch-vision"]362 + extras["codecarbon"]363 + extras["quality"]364 + extras["ja"]365 + extras["docs_specific"]366 + extras["sklearn"]367 + extras["modelcreation"]368 + extras["onnxruntime"]369)370extras["dev-tensorflow"] = (371 extras["testing"]372 + extras["tf"]373 + extras["sentencepiece"]374 + extras["tokenizers"]375 + extras["vision"]376 + extras["quality"]377 + extras["docs_specific"]378 + extras["sklearn"]379 + extras["modelcreation"]380 + extras["onnx"]381 + extras["tf-speech"]382)383extras["dev"] = (384 extras["all"]385 + extras["testing"]386 + extras["quality"]387 + extras["ja"]388 + extras["docs_specific"]389 + extras["sklearn"]390 + extras["modelcreation"]391)392 393extras["torchhub"] = deps_list(394 "filelock",395 "huggingface-hub",396 "importlib_metadata",397 "numpy",398 "packaging",399 "protobuf",400 "regex",401 "requests",402 "sentencepiece",403 "torch",404 "tokenizers",405 "tqdm",406)407 408extras["agents"] = deps_list(409 "diffusers", "accelerate", "datasets", "torch", "sentencepiece", "opencv-python", "Pillow"410)411 412# when modifying the following list, make sure to update src/transformers/dependency_versions_check.py413install_requires = [414 deps["filelock"], # filesystem locks, e.g., to prevent parallel downloads415 deps["huggingface-hub"],416 deps["numpy"],417 deps["packaging"], # utilities from PyPA to e.g., compare versions418 deps["pyyaml"], # used for the model cards metadata419 deps["regex"], # for OpenAI GPT420 deps["requests"], # for downloading models over HTTPS421 deps["tokenizers"],422 deps["safetensors"],423 deps["tqdm"], # progress bars in model download and training scripts424]425 426setup(427 name="transformers",428 version="4.34.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)429 author="The Hugging Face team (past and future) with the help of all our contributors (https://github.com/huggingface/transformers/graphs/contributors)",430 author_email="transformers@huggingface.co",431 description="State-of-the-art Machine Learning for JAX, PyTorch and TensorFlow",432 long_description=open("README.md", "r", encoding="utf-8").read(),433 long_description_content_type="text/markdown",434 keywords="NLP vision speech deep learning transformer pytorch tensorflow jax BERT GPT-2 Wav2Vec2 ViT",435 license="Apache 2.0 License",436 url="https://github.com/huggingface/transformers",437 package_dir={"": "src"},438 packages=find_packages("src"),439 include_package_data=True,440 package_data={"": ["**/*.cu", "**/*.cpp", "**/*.cuh", "**/*.h", "**/*.pyx"]},441 zip_safe=False,442 extras_require=extras,443 entry_points={"console_scripts": ["transformers-cli=transformers.commands.transformers_cli:main"]},444 python_requires=">=3.8.0",445 install_requires=list(install_requires),446 classifiers=[447 "Development Status :: 5 - Production/Stable",448 "Intended Audience :: Developers",449 "Intended Audience :: Education",450 "Intended Audience :: Science/Research",451 "License :: OSI Approved :: Apache Software License",452 "Operating System :: OS Independent",453 "Programming Language :: Python :: 3",454 "Programming Language :: Python :: 3.8",455 "Programming Language :: Python :: 3.9",456 "Programming Language :: Python :: 3.10",457 "Topic :: Scientific/Engineering :: Artificial Intelligence",458 ],459 cmdclass={"deps_table_update": DepsTableUpdateCommand},460)461 