-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
140 lines (108 loc) · 3.58 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import os
import shlex
import sys
if sys.version_info >= (3, 9):
List = list
else:
from typing import List
from pathlib import Path
from setuptools import setup
from subprocess import check_output
from typing import Optional
__here__ = Path(__file__).absolute().parent
version_file_path = __here__ / "il2fb" / "ds" / "events" / "definitions" / "version.py"
exec(compile(version_file_path.read_text(), version_file_path, "exec"))
def maybe_get_shell_output(command: str) -> str:
try:
args = shlex.split(command)
with open(os.devnull, "w") as devnull:
return check_output(args, stderr=devnull).strip().decode()
except Exception:
pass
def maybe_get_current_branch_name() -> Optional[str]:
return maybe_get_shell_output("git rev-parse --abbrev-ref HEAD")
def maybe_get_current_commit_hash() -> Optional[str]:
return maybe_get_shell_output("git rev-parse --short HEAD")
def parse_requirements(file_path: Path) -> List[str]:
requirements = list()
if not file_path.exists():
return requirements
with file_path.open("rt") as f:
for line in f:
line = line.strip()
# check if comment or empty
if not line or line.startswith("#"):
continue
# check if is inclusion of other requirements file
elif line.startswith("-r"):
name = Path(line.split(" ", 1)[1])
path = file_path.parent / name
subrequirements = parse_requirements(path)
requirements.extend(subrequirements)
# assume standard requirement
else:
requirements.append(line)
return requirements
README = (__here__ / "README.rst").read_text()
STABLE_BRANCH_NAME = "main"
CURRENT_COMMIT_HASH = maybe_get_current_commit_hash()
CURRENT_BRANCH_NAME = maybe_get_current_branch_name()
IS_CURRENT_BRANCH_STABLE = (CURRENT_BRANCH_NAME == STABLE_BRANCH_NAME)
BUILD_TAG = (
f".{CURRENT_BRANCH_NAME}.{CURRENT_COMMIT_HASH}"
if not IS_CURRENT_BRANCH_STABLE and CURRENT_COMMIT_HASH
else ""
)
REQUIREMENTS_DIR_PATH = __here__ / "requirements"
INSTALL_REQUIREMENTS = parse_requirements(REQUIREMENTS_DIR_PATH / "dist.txt")
SETUP_REQUIREMENTS = parse_requirements(REQUIREMENTS_DIR_PATH / "setup.txt")
TEST_REQUIREMENTS = parse_requirements(REQUIREMENTS_DIR_PATH / "test.txt")
setup(
name="il2fb-ds-events",
version=VERSION,
description=(
"Definitions of events of the dedicated server of "
"«IL-2 Sturmovik: Forgotten Battles» flight simulator"
),
long_description=README,
long_description_content_type="text/x-rst",
keywords=[
"il2", "il-2", "fb", "forgotten battles", "server", "dedicated server",
"ds", "event", "events", "structure", "structures",
],
license="MIT",
url=f"https://github.com/IL2HorusTeam/il2fb-ds-events/tree/v{VERSION}",
author="Oleksandr Oblovatnyi",
author_email="oblovatniy@gmail.com",
packages=[
"il2fb.ds.events.definitions",
],
namespace_packages=[
"il2fb",
"il2fb.ds",
"il2fb.ds.events",
],
python_requires=">=3.8",
install_requires=INSTALL_REQUIREMENTS,
setup_requires=SETUP_REQUIREMENTS,
tests_require=TEST_REQUIREMENTS,
test_suite="tests",
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Programming Language :: Python :: 3",
"Topic :: Software Development :: Libraries",
],
options={
'egg_info': {
'tag_build': BUILD_TAG,
'tag_date': False,
},
},
zip_safe=False,
)