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 2.8 kB

5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. from setuptools import find_packages
  17. from setuptools import setup
  18. from setuptools.command.egg_info import egg_info
  19. from setuptools.command.build_py import build_py
  20. version = '0.1.0'
  21. cur_dir = os.path.dirname(os.path.realpath(__file__))
  22. pkg_dir = os.path.join(cur_dir, 'build')
  23. try:
  24. from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
  25. class bdist_wheel(_bdist_wheel):
  26. def finalize_options(self):
  27. _bdist_wheel.finalize_options(self)
  28. self.root_is_pure = False
  29. except ImportError:
  30. bdist_wheel = None
  31. def write_version(file):
  32. file.write("__version__ = '{}'\n".format(version))
  33. def build_depends():
  34. """generate python file"""
  35. version_file = os.path.join(cur_dir, 'mindarmour/', 'version.py')
  36. with open(version_file, 'w') as f:
  37. write_version(f)
  38. build_depends()
  39. def update_permissions(path):
  40. """
  41. Update permissions.
  42. Args:
  43. path (str): Target directory path.
  44. """
  45. for dirpath, dirnames, filenames in os.walk(path):
  46. for dirname in dirnames:
  47. dir_fullpath = os.path.join(dirpath, dirname)
  48. os.chmod(dir_fullpath, stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC | stat.S_IRGRP | stat.S_IXGRP)
  49. for filename in filenames:
  50. file_fullpath = os.path.join(dirpath, filename)
  51. os.chmod(file_fullpath, stat.S_IREAD)
  52. class EggInfo(egg_info):
  53. """Egg info."""
  54. def run(self):
  55. super().run()
  56. egg_info_dir = os.path.join(cur_dir, 'mindarmour.egg-info')
  57. update_permissions(egg_info_dir)
  58. class BuildPy(build_py):
  59. """BuildPy."""
  60. def run(self):
  61. super().run()
  62. mindarmour_dir = os.path.join(pkg_dir, 'lib', 'mindarmour')
  63. update_permissions(mindarmour_dir)
  64. setup(
  65. name='mindarmour',
  66. version='0.1.0',
  67. description="A smart AI security and trustworthy tool box.",
  68. packages=find_packages(),
  69. include_package_data=True,
  70. zip_safe=False,
  71. cmdclass={
  72. 'egg_info': EggInfo,
  73. 'build_py': BuildPy,
  74. 'bdist_wheel': bdist_wheel
  75. },
  76. install_requires=[
  77. 'scipy >= 1.3.3',
  78. 'numpy >= 1.17.0',
  79. 'matplotlib >= 3.1.3',
  80. 'mindspore'
  81. ],
  82. )
  83. print(find_packages())

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