You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

setup.py 3.6 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. # Copyright 2019 Huawei Technologies Co., Ltd
  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. import os
  15. import stat
  16. import shlex
  17. import subprocess
  18. from setuptools import find_packages
  19. from setuptools import setup
  20. from setuptools.command.egg_info import egg_info
  21. from setuptools.command.build_py import build_py
  22. version = '1.2.0'
  23. cur_dir = os.path.dirname(os.path.realpath(__file__))
  24. pkg_dir = os.path.join(cur_dir, 'build')
  25. def write_version(file):
  26. file.write("__version__ = '{}'\n".format(version))
  27. def build_depends():
  28. """generate python file"""
  29. version_file = os.path.join(cur_dir, 'mindarmour/', 'version.py')
  30. with open(version_file, 'w') as f:
  31. write_version(f)
  32. build_depends()
  33. def update_permissions(path):
  34. """
  35. Update permissions.
  36. Args:
  37. path (str): Target directory path.
  38. """
  39. for dirpath, dirnames, filenames in os.walk(path):
  40. for dirname in dirnames:
  41. dir_fullpath = os.path.join(dirpath, dirname)
  42. os.chmod(dir_fullpath, stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC | stat.S_IRGRP | stat.S_IXGRP)
  43. for filename in filenames:
  44. file_fullpath = os.path.join(dirpath, filename)
  45. os.chmod(file_fullpath, stat.S_IREAD)
  46. def get_description():
  47. """
  48. Get description.
  49. Returns:
  50. str, wheel package description.
  51. """
  52. cmd = "git log --format='[sha1]:%h, [branch]:%d' -1"
  53. process = subprocess.Popen(
  54. shlex.split(cmd),
  55. shell=False,
  56. stdin=subprocess.PIPE,
  57. stdout=subprocess.PIPE,
  58. stderr=subprocess.PIPE
  59. )
  60. stdout, _ = process.communicate()
  61. if not process.returncode:
  62. git_version = stdout.decode().strip()
  63. return "A smart AI security and trustworthy tool box. Git version: %s" % (git_version)
  64. return "A smart AI security and trustworthy tool box."
  65. class EggInfo(egg_info):
  66. """Egg info."""
  67. def run(self):
  68. super().run()
  69. egg_info_dir = os.path.join(cur_dir, 'mindarmour.egg-info')
  70. update_permissions(egg_info_dir)
  71. class BuildPy(build_py):
  72. """BuildPy."""
  73. def run(self):
  74. super().run()
  75. mindarmour_dir = os.path.join(pkg_dir, 'lib', 'mindarmour')
  76. update_permissions(mindarmour_dir)
  77. setup(
  78. name='mindarmour',
  79. version=version,
  80. author='The MindSpore Authors',
  81. author_email='contact@mindspore.cn',
  82. url='https://www.mindspore.cn/',
  83. download_url='https://gitee.com/mindspore/mindarmour/tags',
  84. project_urls={
  85. 'Sources': 'https://gitee.com/mindspore/mindarmour',
  86. 'Issue Tracker': 'https://gitee.com/mindspore/mindarmour/issues',
  87. },
  88. description=get_description(),
  89. license='Apache 2.0',
  90. packages=find_packages(),
  91. include_package_data=True,
  92. cmdclass={
  93. 'egg_info': EggInfo,
  94. 'build_py': BuildPy,
  95. },
  96. install_requires=[
  97. 'scipy >= 1.5.2',
  98. 'numpy >= 1.17.0',
  99. 'matplotlib >= 3.2.1',
  100. 'Pillow >= 2.0.0',
  101. 'scikit-learn >= 0.23.1'
  102. ],
  103. classifiers=[
  104. 'License :: OSI Approved :: Apache Software License'
  105. ]
  106. )
  107. print(find_packages())

MindArmour关注AI的安全和隐私问题。致力于增强模型的安全可信、保护用户的数据隐私。主要包含3个模块:对抗样本鲁棒性模块、Fuzz Testing模块、隐私保护与评估模块。 对抗样本鲁棒性模块 对抗样本鲁棒性模块用于评估模型对于对抗样本的鲁棒性,并提供模型增强方法用于增强模型抗对抗样本攻击的能力,提升模型鲁棒性。对抗样本鲁棒性模块包含了4个子模块:对抗样本的生成、对抗样本的检测、模型防御、攻防评估。