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.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # -*- coding: utf-8 -*-
  2. # MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  3. #
  4. # Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
  5. #
  6. # Unless required by applicable law or agreed to in writing,
  7. # software distributed under the License is distributed on an
  8. # "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. import os
  10. import re
  11. import pathlib
  12. from distutils.file_util import copy_file
  13. from setuptools import setup, find_packages, Extension
  14. from setuptools.command.build_ext import build_ext as _build_ext
  15. class PrecompiledExtesion(Extension):
  16. def __init__(self, name):
  17. super().__init__(name, sources=[])
  18. class build_ext(_build_ext):
  19. def build_extension(self, ext):
  20. if not isinstance(ext, PrecompiledExtesion):
  21. return super().build_extension(ext)
  22. if not self.inplace:
  23. fullpath = self.get_ext_fullpath(ext.name)
  24. extdir = pathlib.Path(fullpath)
  25. extdir.parent.mkdir(parents=True, exist_ok=True)
  26. modpath = self.get_ext_fullname(ext.name).split('.')
  27. modpath[-1] += '.so'
  28. modpath = str(pathlib.Path(*modpath).resolve())
  29. copy_file(modpath, fullpath, verbose=self.verbose, dry_run=self.dry_run)
  30. package_name = 'MegEngine'
  31. v = {}
  32. with open("megengine/version.py") as fp:
  33. exec(fp.read(), v)
  34. __version__ = v['__version__']
  35. email = 'megengine@megvii.com'
  36. local_version = os.environ.get('LOCAL_VERSION')
  37. if local_version:
  38. __version__ = '{}+{}'.format(__version__, local_version)
  39. packages = find_packages(exclude=['test'])
  40. with open('requires.txt') as f:
  41. requires = f.read().splitlines()
  42. with open('requires-style.txt') as f:
  43. requires_style = f.read().splitlines()
  44. with open('requires-test.txt') as f:
  45. requires_test = f.read().splitlines()
  46. setup_kwargs = dict(
  47. name=package_name,
  48. version=__version__,
  49. description='Framework for numerical evaluation with '
  50. 'auto-differentiation',
  51. author='Megvii Engine Team',
  52. author_email=email,
  53. packages=packages,
  54. ext_modules=[PrecompiledExtesion('megengine.core._imperative_rt')],
  55. install_requires=requires,
  56. extras_require={
  57. 'dev': requires_style + requires_test,
  58. 'ci': requires_test,
  59. },
  60. cmdclass={'build_ext': build_ext},
  61. )
  62. setup_kwargs.update(dict(
  63. classifiers=[
  64. 'Development Status :: 3 - Alpha',
  65. 'Intended Audience :: Developers',
  66. 'Intended Audience :: Education',
  67. 'Intended Audience :: Science/Research',
  68. 'License :: OSI Approved :: Apache Software License',
  69. 'Programming Language :: C++',
  70. 'Programming Language :: Python :: 3',
  71. 'Programming Language :: Python :: 3.5',
  72. 'Programming Language :: Python :: 3.6',
  73. 'Programming Language :: Python :: 3.7',
  74. 'Programming Language :: Python :: 3.8',
  75. 'Topic :: Scientific/Engineering',
  76. 'Topic :: Scientific/Engineering :: Mathematics',
  77. 'Topic :: Scientific/Engineering :: Artificial Intelligence',
  78. 'Topic :: Software Development',
  79. 'Topic :: Software Development :: Libraries',
  80. 'Topic :: Software Development :: Libraries :: Python Modules',
  81. ],
  82. license='Apache 2.0',
  83. keywords='megengine deep learning',
  84. data_files = [("megengine", [
  85. "../LICENSE",
  86. "../ACKNOWLEDGMENTS",
  87. ])]
  88. ))
  89. setup(**setup_kwargs)

MegEngine 安装包中集成了使用 GPU 运行代码所需的 CUDA 环境,不用区分 CPU 和 GPU 版。 如果想要运行 GPU 程序,请确保机器本身配有 GPU 硬件设备并安装好驱动。 如果你想体验在云端 GPU 算力平台进行深度学习开发的感觉,欢迎访问 MegStudio 平台