-
-
Notifications
You must be signed in to change notification settings - Fork 675
/
setup.py
executable file
·149 lines (131 loc) · 4.27 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
141
142
143
144
145
146
147
148
149
import os
import subprocess
import sys
from datetime import datetime
from pathlib import Path
from time import time
from setuptools import find_packages, setup
assert sys.version_info >= (3, 7, 0), "KivyMD requires Python 3.7+"
try:
# __version__ is defined in _version.py, imported by exec() below
# this is just so linter doesn't complain
__version__ = ""
with open(
Path(__file__).parent / "kivymd" / "_version.py", encoding="utf-8"
) as f:
exec(f.read())
except FileNotFoundError:
raise
def get_version() -> str:
"""Return version string."""
# keeping this for compatibility with previous versions of KivyMD
return __version__
def update_version_info():
"""Create _version.py file with git revision and date."""
filename = os.path.join(os.path.dirname(__file__), "kivymd", "_version.py")
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 = (
"\n".join(
[
"release = False",
f'__version__ = "{__version__}"',
f'__hash__ = "{git_revision}"',
f'__short_hash__ = "{git_revision[:7]}"',
f'__date__ = "{date}"',
]
)
+ "\n"
)
open(filename, "wt", encoding="utf-8").write(version_info)
def glob_paths(pattern):
out_files = []
src_path = os.path.join(os.path.dirname(__file__), "kivymd")
for root, dirs, files in os.walk(src_path):
for file in files:
if file.endswith(pattern):
filepath = os.path.join(str(Path(*Path(root).parts[1:])), file)
try:
out_files.append(filepath.split(f"kivymd{os.sep}")[1])
except IndexError:
out_files.append(filepath)
return out_files
if __name__ == "__main__":
# Static strings are in setup.cfg
update_version_info()
setup(
version=__version__,
packages=find_packages(
include=["kivymd", "kivymd.*"], exclude=["kivymd.tools.release"]
),
package_dir={"kivymd": "kivymd"},
package_data={
"kivymd": [
"images/*.png",
"images/logo/*.png",
"fonts/*.ttf",
*glob_paths(".kv"),
*glob_paths(".pot"),
*glob_paths(".po"),
]
},
extras_require={
"dev": [
"pre-commit",
"black",
"isort[pyproject]",
"flake8",
"pytest",
"pytest-cov",
"pytest_asyncio",
"pytest-timeout",
"coveralls",
"pyinstaller[hook_testing]",
],
"docs": [
"sphinx==7.3.7",
"sphinx-autoapi==3.0.0",
# "furo",
"sphinx-book-theme",
"sphinx-notfound-page",
"sphinx-copybutton",
"sphinx-tabs",
],
},
install_requires=[
"kivy>=2.3.0",
"pillow",
"materialyoucolor>=2.0.7",
"asynckivy>=0.6,<0.7",
],
setup_requires=[],
python_requires=">=3.7",
entry_points={
"pyinstaller40": [
"hook-dirs = kivymd.tools.packaging.pyinstaller:get_hook_dirs",
"tests = kivymd.tools.packaging.pyinstaller:get_pyinstaller_tests",
],
"console_scripts": [
"kivymd.add_view = kivymd.tools.patterns.add_view:main",
"kivymd.create_project = kivymd.tools.patterns.create_project:main",
"kivymd.make_release = kivymd.tools.release.make_release:main",
],
},
)