Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

setup.py 2.6 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
  1. #!/usr/bin/env python
  2. # Copyright (c) Megvii, Inc. and its affiliates. All Rights Reserved
  3. import re
  4. import setuptools
  5. import sys
  6. TORCH_AVAILABLE = True
  7. try:
  8. import torch
  9. from torch.utils import cpp_extension
  10. except ImportError:
  11. TORCH_AVAILABLE = False
  12. print("[WARNING] Unable to import torch, pre-compiling ops will be disabled.")
  13. def get_package_dir():
  14. pkg_dir = {
  15. "yolox.tools": "tools",
  16. "yolox.exp.default": "exps/default",
  17. }
  18. return pkg_dir
  19. def get_install_requirements():
  20. with open("requirements.txt", "r", encoding="utf-8") as f:
  21. reqs = [x.strip() for x in f.read().splitlines()]
  22. reqs = [x for x in reqs if not x.startswith("#")]
  23. return reqs
  24. def get_yolox_version():
  25. with open("yolox/__init__.py", "r") as f:
  26. version = re.search(
  27. r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
  28. f.read(), re.MULTILINE
  29. ).group(1)
  30. return version
  31. def get_long_description():
  32. with open("README.md", "r", encoding="utf-8") as f:
  33. long_description = f.read()
  34. return long_description
  35. def get_ext_modules():
  36. ext_module = []
  37. if sys.platform != "win32": # pre-compile ops on linux
  38. assert TORCH_AVAILABLE, "torch is required for pre-compiling ops, please install it first."
  39. # if any other op is added, please also add it here
  40. from yolox.layers import FastCOCOEvalOp
  41. ext_module.append(FastCOCOEvalOp().build_op())
  42. return ext_module
  43. def get_cmd_class():
  44. cmdclass = {}
  45. if TORCH_AVAILABLE:
  46. cmdclass["build_ext"] = cpp_extension.BuildExtension
  47. return cmdclass
  48. setuptools.setup(
  49. name="yolox",
  50. version=get_yolox_version(),
  51. author="megvii basedet team",
  52. url="https://github.com/Megvii-BaseDetection/YOLOX",
  53. package_dir=get_package_dir(),
  54. packages=setuptools.find_packages(exclude=("tests", "tools")) + list(get_package_dir().keys()),
  55. python_requires=">=3.6",
  56. install_requires=get_install_requirements(),
  57. setup_requires=["wheel"], # avoid building error when pip is not updated
  58. long_description=get_long_description(),
  59. long_description_content_type="text/markdown",
  60. include_package_data=True, # include files in MANIFEST.in
  61. ext_modules=get_ext_modules(),
  62. cmdclass=get_cmd_class(),
  63. classifiers=[
  64. "Programming Language :: Python :: 3", "Operating System :: OS Independent",
  65. "License :: OSI Approved :: Apache Software License",
  66. ],
  67. project_urls={
  68. "Documentation": "https://yolox.readthedocs.io",
  69. "Source": "https://github.com/Megvii-BaseDetection/YOLOX",
  70. "Tracker": "https://github.com/Megvii-BaseDetection/YOLOX/issues",
  71. },
  72. )
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...