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

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