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

setup.py 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/env python
  2. # Copyright (c) Megvii, Inc. and its affiliates. All Rights Reserved
  3. import re
  4. import setuptools
  5. import glob
  6. from os import path
  7. import torch
  8. from torch.utils.cpp_extension import CppExtension
  9. torch_ver = [int(x) for x in torch.__version__.split(".")[:2]]
  10. assert torch_ver >= [1, 3], "Requires PyTorch >= 1.3"
  11. def get_extensions():
  12. this_dir = path.dirname(path.abspath(__file__))
  13. extensions_dir = path.join(this_dir, "yolox", "layers", "csrc")
  14. main_source = path.join(extensions_dir, "vision.cpp")
  15. sources = glob.glob(path.join(extensions_dir, "**", "*.cpp"))
  16. sources = [main_source] + sources
  17. extension = CppExtension
  18. extra_compile_args = {"cxx": ["-O3"]}
  19. define_macros = []
  20. include_dirs = [extensions_dir]
  21. ext_modules = [
  22. extension(
  23. "yolox._C",
  24. sources,
  25. include_dirs=include_dirs,
  26. define_macros=define_macros,
  27. extra_compile_args=extra_compile_args,
  28. )
  29. ]
  30. return ext_modules
  31. with open("yolox/__init__.py", "r") as f:
  32. version = re.search(
  33. r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
  34. f.read(), re.MULTILINE
  35. ).group(1)
  36. with open("README.md", "r") as f:
  37. long_description = f.read()
  38. setuptools.setup(
  39. name="yolox",
  40. version=version,
  41. author="basedet team",
  42. python_requires=">=3.6",
  43. long_description=long_description,
  44. ext_modules=get_extensions(),
  45. classifiers=["Programming Language :: Python :: 3", "Operating System :: OS Independent"],
  46. cmdclass={"build_ext": torch.utils.cpp_extension.BuildExtension},
  47. packages=setuptools.find_namespace_packages(),
  48. )