youssefedweqd/working
06
1# Copyright 2025 the LlamaFactory team.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 15import os16import re17 18from setuptools import find_packages, setup19 20 21def get_version() -> str:22 with open(os.path.join("src", "llamafactory", "extras", "env.py"), encoding="utf-8") as f:23 file_content = f.read()24 pattern = r"{}\W*=\W*\"([^\"]+)\"".format("VERSION")25 (version,) = re.findall(pattern, file_content)26 return version27 28 29def get_requires() -> list[str]:30 with open("requirements.txt", encoding="utf-8") as f:31 file_content = f.read()32 lines = [line.strip() for line in file_content.strip().split("\n") if not line.startswith("#")]33 return lines34 35 36def get_console_scripts() -> list[str]:37 console_scripts = ["llamafactory-cli = llamafactory.cli:main"]38 if os.getenv("ENABLE_SHORT_CONSOLE", "1").lower() in ["true", "y", "1"]:39 console_scripts.append("lmf = llamafactory.cli:main")40 41 return console_scripts42 43 44extra_require = {45 "torch": ["torch>=2.0.0", "torchvision>=0.15.0"],46 "torch-npu": ["torch==2.4.0", "torch-npu==2.4.0.post2", "decorator"],47 "metrics": ["nltk", "jieba", "rouge-chinese"],48 "deepspeed": ["deepspeed>=0.10.0,<=0.16.9"],49 "liger-kernel": ["liger-kernel>=0.5.5"],50 "bitsandbytes": ["bitsandbytes>=0.39.0"],51 "hqq": ["hqq"],52 "eetq": ["eetq"],53 "gptq": ["optimum>=1.24.0", "gptqmodel>=2.0.0"],54 "aqlm": ["aqlm[gpu]>=1.1.0"],55 "vllm": ["vllm>=0.4.3,<=0.9.1"],56 "sglang": ["sglang[srt]>=0.4.5", "transformers==4.51.1"],57 "galore": ["galore-torch"],58 "apollo": ["apollo-torch"],59 "badam": ["badam>=1.2.1"],60 "adam-mini": ["adam-mini"],61 "minicpm_v": [62 "soundfile",63 "torchvision",64 "torchaudio",65 "vector_quantize_pytorch",66 "vocos",67 "msgpack",68 "referencing",69 "jsonschema_specifications",70 ],71 "modelscope": ["modelscope"],72 "openmind": ["openmind"],73 "swanlab": ["swanlab"],74 "dev": ["pre-commit", "ruff", "pytest", "build"],75}76 77 78def main():79 setup(80 name="llamafactory",81 version=get_version(),82 author="hiyouga",83 author_email="hiyouga@buaa.edu.cn",84 description="Unified Efficient Fine-Tuning of 100+ LLMs",85 long_description=open("README.md", encoding="utf-8").read(),86 long_description_content_type="text/markdown",87 keywords=["AI", "LLM", "GPT", "ChatGPT", "Llama", "Transformer", "DeepSeek", "Pytorch"],88 license="Apache 2.0 License",89 url="https://github.com/hiyouga/LLaMA-Factory",90 package_dir={"": "src"},91 packages=find_packages("src"),92 python_requires=">=3.9.0",93 install_requires=get_requires(),94 extras_require=extra_require,95 entry_points={"console_scripts": get_console_scripts()},96 classifiers=[97 "Development Status :: 4 - Beta",98 "Intended Audience :: Developers",99 "Intended Audience :: Education",100 "Intended Audience :: Science/Research",101 "License :: OSI Approved :: Apache Software License",102 "Operating System :: OS Independent",103 "Programming Language :: Python :: 3",104 "Programming Language :: Python :: 3.9",105 "Programming Language :: Python :: 3.10",106 "Programming Language :: Python :: 3.11",107 "Programming Language :: Python :: 3.12",108 "Topic :: Scientific/Engineering :: Artificial Intelligence",109 ],110 )111 112 113if __name__ == "__main__":114 main()115 