-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
46 lines (37 loc) · 1.29 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
from os import getcwd, path, environ
from setuptools import setup
import subprocess
# Change accordingly ----------------------------
PACKAGE_DIR_NAME = "frigga"
GITHUB_OWNER = "unfor19"
GITHUB_REPOSITORY = "frigga"
# -----------------------------------------------
# Keep the same structure, should NOT be changed
def get_short_commit():
"""Assumes git is installed"""
return subprocess.check_output(
['git', 'rev-parse', '--short', 'HEAD']
).decode().strip()
# Keep the same structure, should NOT be changed
with open("version", "r") as fh:
version = fh.read()
with open(path.join(getcwd(), 'src', PACKAGE_DIR_NAME, '__init__.py'), "w") as fh: # noqa: E501
short_commit = ""
try:
short_commit = get_short_commit()
except Exception:
try:
if "GITHUB_SHA" in environ and environ["GITHUB_SHA"]:
short_commit = environ["GITHUB_SHA"]
except Exception:
short_commit = "abcd123"
finally:
short_commit = short_commit[0:7]
fh.write(
f"__version__ = '{version}'\n__short_commit__ = '{short_commit}'"
)
setup(
version=version,
download_url=f'https://github.com/{GITHUB_OWNER}/{GITHUB_REPOSITORY}/archive/{version}.tar.gz', # noqa: E501
)
# -----------------------------------------------