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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # -*- coding: utf-8 -*-
  2. # This file is part of MegBrain.
  3. # Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
  4. import os
  5. import re
  6. import pathlib
  7. from distutils.file_util import copy_file
  8. from setuptools import setup, find_packages, Extension
  9. from setuptools.command.build_ext import build_ext as _build_ext
  10. class PrecompiledExtesion(Extension):
  11. def __init__(self, name):
  12. super().__init__(name, sources=[])
  13. class build_ext(_build_ext):
  14. def build_extension(self, ext):
  15. if not isinstance(ext, PrecompiledExtesion):
  16. return super().build_extension(ext)
  17. if not self.inplace:
  18. fullpath = self.get_ext_fullpath(ext.name)
  19. extdir = pathlib.Path(fullpath)
  20. extdir.parent.mkdir(parents=True, exist_ok=True)
  21. modpath = self.get_ext_fullname(ext.name).split('.')
  22. modpath[-1] += '.so'
  23. modpath = str(pathlib.Path(*modpath).resolve())
  24. copy_file(modpath, fullpath, verbose=self.verbose, dry_run=self.dry_run)
  25. package_name = 'MegEngine'
  26. v = {}
  27. with open("megengine/version.py") as fp:
  28. exec(fp.read(), v)
  29. __version__ = v['__version__']
  30. email = 'megengine@megvii.com'
  31. local_version = os.environ.get('LOCAL_VERSION')
  32. if local_version:
  33. __version__ = '{}+{}'.format(__version__, local_version)
  34. packages = find_packages(exclude=['test'])
  35. package_data = [
  36. str(f.relative_to('megengine'))
  37. for f in pathlib.Path('megengine', '_internal', 'include').glob('**/*')
  38. ]
  39. package_data += [
  40. str(f.relative_to('megengine'))
  41. for f in pathlib.Path('megengine', '_internal', 'lib').glob('**/*')
  42. ]
  43. package_data += [
  44. os.path.join('module', 'pytorch', 'torch_mem_fwd.cpp')
  45. ]
  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. package_data={
  55. 'megengine': package_data,
  56. },
  57. ext_modules=[PrecompiledExtesion('megengine._internal._mgb')],
  58. install_requires=[
  59. 'numpy>=1.17',
  60. 'opencv-python',
  61. 'pyarrow',
  62. 'requests',
  63. 'tabulate',
  64. 'tqdm',
  65. ],
  66. extras_require={
  67. 'dev': [
  68. 'black==19.10b0',
  69. 'isort==4.3.21',
  70. 'pylint==2.4.3',
  71. 'mypy==0.750',
  72. 'pytest==5.3.0',
  73. 'pytest-sphinx==0.2.2',
  74. ],
  75. 'data': [
  76. 'scipy',
  77. ],
  78. },
  79. cmdclass={'build_ext': build_ext},
  80. )
  81. setup_kwargs.update(dict(
  82. classifiers=[
  83. 'Development Status :: 3 - Alpha',
  84. 'Intended Audience :: Developers',
  85. 'Intended Audience :: Education',
  86. 'Intended Audience :: Science/Research',
  87. 'License :: OSI Approved :: Apache Software License',
  88. 'Programming Language :: C++',
  89. 'Programming Language :: Python :: 3',
  90. 'Programming Language :: Python :: 3.5',
  91. 'Programming Language :: Python :: 3.6',
  92. 'Programming Language :: Python :: 3.7',
  93. 'Programming Language :: Python :: 3.8',
  94. 'Topic :: Scientific/Engineering',
  95. 'Topic :: Scientific/Engineering :: Mathematics',
  96. 'Topic :: Scientific/Engineering :: Artificial Intelligence',
  97. 'Topic :: Software Development',
  98. 'Topic :: Software Development :: Libraries',
  99. 'Topic :: Software Development :: Libraries :: Python Modules',
  100. ],
  101. license='Apache 2.0',
  102. keywords='megengine deep learning',
  103. data_files = [("", [
  104. "../LICENSE",
  105. "../ACKNOWLEDGMENTS",
  106. ])]
  107. ))
  108. setup(**setup_kwargs)

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

Contributors (1)