-
-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathsetup.py
31 lines (21 loc) · 838 Bytes
/
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
import re
from setuptools import setup # type: ignore
def get_version() -> str:
version = ""
with open("twitchio/__init__.py") as f:
match = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE)
if not match or not match.group(1):
raise RuntimeError("Version is not set")
version = match.group(1)
if version.endswith(("dev", "a", "b", "rc")):
# append version identifier based on commit count
try:
import subprocess
p = subprocess.Popen(["git", "rev-list", "--count", "HEAD"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, _ = p.communicate()
if out:
version += out.decode("utf-8").strip()
except Exception:
pass
return version
setup(version=get_version())