-
Notifications
You must be signed in to change notification settings - Fork 67
/
setup.py
76 lines (67 loc) · 2.26 KB
/
setup.py
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
import os
import setuptools
import sys
import struct
CONFIG = {
"package_name": "bminf",
"author": "a710128",
"author_email": "[email protected]",
"description": "A toolkit for big model inference",
"version": None
}
def get_readme(path):
ret = ""
with open(os.path.join(path, "README.md"), encoding="utf-8") as frd:
ret = frd.read()
return ret
def get_requirements(path):
ret = []
with open(os.path.join(path, "requirements.txt"), encoding="utf-8") as freq:
for line in freq.readlines():
ret.append( line.strip() )
return ret
def get_version(path):
if "version" in CONFIG and CONFIG["version"] is not None:
return CONFIG["version"]
if "BM_VERSION" in os.environ:
return os.environ["BM_VERSION"]
if "CI_COMMIT_TAG" in os.environ:
return os.environ["CI_COMMIT_TAG"]
if "CI_COMMIT_SHA" in os.environ:
return os.environ["CI_COMMIT_SHA"]
version_path = os.path.join( path, CONFIG["package_name"], "version.py" )
if os.path.exists(version_path):
tmp = {}
exec(open(version_path, "r", encoding="utf-8").read(), tmp)
if "__version__" in tmp:
return tmp["__version__"]
return "test"
def main():
path = os.path.dirname(os.path.abspath(__file__))
version = get_version(path)
open( os.path.join(path, CONFIG["package_name"], "version.py"), "w", encoding="utf-8" ).write('__version__ = "%s"' % version)
requires = get_requirements(path)
setuptools.setup(
name=CONFIG["package_name"],
version=version,
author=CONFIG["author"],
author_email=CONFIG["author_email"],
description=CONFIG["description"],
long_description=get_readme(path),
long_description_content_type="text/markdown",
packages=setuptools.find_packages(exclude=("tools",)),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Programming Language :: C++"
],
python_requires=">=3.6",
setup_requires=["wheel"],
install_requires= requires,
include_package_data=True,
package_data={
'bminf.kernels': ['*.fatbin']
}
)
if __name__ == "__main__":
main()