OpenBackdoor
/
setup.py
60 строк · 2.2 Кб
1import setuptools2import os3import importlib4
5def get_requirements(path):6ret = []7with open(os.path.join(path, "requirements.txt"), encoding="utf-8") as freq:8for line in freq.readlines():9ret.append( line.strip() )10return ret11
12
13path = os.path.dirname(os.path.abspath(__file__))14requires = get_requirements(path)15print("requirements:")16print(requires)17
18with open('README.md', 'r') as f:19setuptools.setup(20name = 'openbackdoor',21version = '1.0.0',22description = "An open-scource toolkit for textual backdoor attack and defense.",23long_description=open("README.md", "r", encoding="utf-8").read(),24long_description_content_type="text/markdown",25author = 'Ganqu Cui, Yanyi Chen, Lifan Yuan, Bingxiang He',26author_email = 'cgq19@mails.tsinghua.edu.cn',27license="Apache",28url="https://github.com/cgq15/OpenBackdoor",29keywords = ['PLM', 'AI', 'NLP'],30python_requires=">=3.6.0",31install_requires=requires,32packages=setuptools.find_packages(),33classifiers=[34"Programming Language :: Python :: 3",35"Programming Language :: Python :: 3.8",36"Programming Language :: Python :: 3.9",37"Intended Audience :: Developers",38"Intended Audience :: Education",39"Intended Audience :: Science/Research",40"License :: OSI Approved :: Apache Software License",41"Operating System :: OS Independent",42]43)44
45required_list = ["torch"]46for package in required_list:47try:48m = importlib.import_module(package)49except ModuleNotFoundError:50print("\n"+"="*30+" WARNING "+"="*30)51print(f"{package} is not found on your environment, please install it manually.")52print("We do not install it for you because the environment sometimes needs special care.")53
54optional_list = ["sklearn"]55for package in optional_list:56try:57m = importlib.import_module(package)58except ModuleNotFoundError:59print("\n"+"="*30+" WARNING "+"="*30)60print(f"{package} is not found on your environment, please install it if the specific script needs.")