-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsetup.py
More file actions
66 lines (52 loc) · 1.85 KB
/
Copy pathsetup.py
File metadata and controls
66 lines (52 loc) · 1.85 KB
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
import os
import subprocess
from datetime import datetime
from setuptools import find_packages, setup
def get_git_commit_hash():
try:
commit_hash = (
subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
.decode("ascii")
.strip()
)
return commit_hash
except subprocess.CalledProcessError:
# 如果无法获取commit号,可能是因为这不是一个git仓库,或者git不可用
return "Unknown"
def process_requirements_file(file_path):
with open(file_path, encoding="utf-8") as req_file:
lines = (line.strip() for line in req_file)
# 这里过滤掉了以`#`或`--`开头的行
lines = [line for line in lines if line and not line.startswith(("#", "--"))]
return lines
def get_version():
this_dir = os.path.dirname(os.path.abspath(__file__))
version_file_path = os.path.join(this_dir, "version")
version = open(version_file_path, "r").readlines()[0].strip()
if os.getenv("BUILD_NIGHTLY", "0") == "1":
date_str = datetime.today().strftime("%y%m%d%H%M")
git_commit = get_git_commit_hash()
version = f"{version}.dev{date_str}+{git_commit}"
return version
req_path = os.path.join(os.path.dirname(__file__), "requirements.txt")
requirements = process_requirements_file(req_path)
docs_requirements = process_requirements_file(
os.path.join(os.path.dirname(__file__), "requirements-docs.txt")
)
setup(
name="flowra",
version=get_version(),
maintainer="muse-ai",
maintainer_email="muse@alibaba-inc.com",
description="Flowra",
packages=find_packages(),
include_package_data=True,
install_requires=requirements,
extras_require={
"docs": docs_requirements,
},
entry_points="""
[console_scripts]
flowra=flowra.command.flowra:cli
""",
)