forked from kivymd/KivyMD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·103 lines (93 loc) · 3.1 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
import os
import re
import subprocess
import sys
from datetime import datetime
from time import time
from setuptools import find_packages, setup
assert sys.version_info >= (3, 6, 0), "KivyMD requires Python 3.6+"
def get_version() -> str:
"""Get __version__ from __init__.py file."""
version_file = os.path.join(
os.path.dirname(__file__), "kivymd", "__init__.py"
)
version_file_data = open(version_file, "rt", encoding="utf-8").read()
version_regex = r"(?<=^__version__ = ['\"])[^'\"]+(?=['\"]$)"
try:
version = re.findall(version_regex, version_file_data, re.M)[0]
return version
except IndexError:
raise ValueError(f"Unable to find version string in {version_file}.")
def write_version_info():
"""Create _version.py file with git revision and date."""
filename = os.path.join(os.path.dirname(__file__), "kivymd", "_version.py")
version = get_version()
epoch = int(os.environ.get("SOURCE_DATE_EPOCH", time()))
date = datetime.utcfromtimestamp(epoch).strftime("%Y-%m-%d")
try:
git_revision = (
subprocess.check_output(["git", "rev-parse", "HEAD"])
.strip()
.decode("ascii")
)
except (
subprocess.CalledProcessError,
OSError,
IOError,
FileNotFoundError,
) as e:
# CalledProcessError has no errno
errno = getattr(e, "errno", None)
if errno != 2 and "CalledProcessError" not in repr(e):
raise
git_revision = "Unknown"
version_info = (
f"# THIS FILE IS GENERATED FROM KIVYMD SETUP.PY\n"
f'__version__ = "{version}"\n'
f'__hash__ = "{git_revision}"\n'
f'__short_hash__ = "{git_revision[:7]}"\n'
f'__date__ = "{date}"\n'
)
open(filename, "wt", encoding="utf-8").write(version_info)
if __name__ == "__main__":
# Static strings are in setup.cfg
write_version_info()
setup(
version=get_version(),
packages=find_packages(
include=["kivymd", "kivymd.*"], exclude=["kivymd.tools.release"]
),
package_dir={"kivymd": "kivymd"},
package_data={
"kivymd": ["images/*.png", "images/*.atlas", "fonts/*.ttf"]
},
extras_require={
"dev": [
"pre-commit",
"black",
"isort[pyproject]",
"flake8",
"pytest",
"pytest-cov",
"pytest_asyncio",
"pytest-timeout",
"coveralls",
"pyinstaller[hook_testing]",
],
"docs": [
"sphinx",
"sphinx-autoapi==1.4.0",
"sphinx_rtd_theme",
"sphinx-notfound-page",
],
},
install_requires=["kivy>=2.0.0"],
setup_requires=[],
python_requires=">=3.6",
entry_points={
"pyinstaller40": [
"hook-dirs = kivymd.tools.packaging.pyinstaller:get_hook_dirs",
"tests = kivymd.tools.packaging.pyinstaller:get_pyinstaller_tests",
]
},
)