-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.toml
172 lines (144 loc) · 4.11 KB
/
Makefile.toml
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
[config]
default_to_workspace = false
skip_core_tasks = true
[tasks.format]
command = "uv"
args = ["run", "ruff", "format", "."]
[tasks.clean]
dependencies = ["clean-pycache"]
ignore_errors = true
script_runner = "@shell"
script = '''
rm ./setup.cfg
rm ./.coverage
rm LICENSE
rm ThirdPartyNotice.txt
rm VERSION
rm -rf dist
rm -rf pyautd3_emulator.egg-info
rm -rf pyautd3_emulator/bin
rm pyautd3_emulator/LICENSE.txt
rm pyautd3_emulator/ThirdPartyNotice.txt
rm -rf htmlcov
rm -rf .ruff_cache
rm -rf .mypy_cache
rm -rf .pytest_cache
rm uv.lock
'''
[tasks.clean-pycache]
ignore_errors = true
script_runner = "python"
script_extension = "py"
script = '''
from pathlib import Path
for p in Path('.').rglob('*.py[co]'):
p.unlink()
for p in Path('.').rglob('__pycache__'):
p.rmdir()
'''
[tasks.sync]
command = "uv"
args = ["sync", "--all-extras", "--dev"]
[tasks.mypy]
command = "uv"
args = ["run", "mypy", ".", "--check-untyped-defs"]
[tasks.ruff]
command = "uv"
args = ["run", "ruff", "check", "."]
[tasks.check]
dependencies = ["sync", "format", "mypy", "ruff", "test", "build"]
[tasks.test]
dependencies = ["update-bin"]
command = "uv"
args = ["run", "pytest", "-n", "auto"]
[tasks.build]
dependencies = ["sync", "build-setup", "update-bin", "build-wheel"]
[tasks.build-wheel]
command = "uv"
args = ["build"]
[tasks.build-setup]
run_task = [
{ name = "build-setup-win-x64", condition = { platforms = [
"windows",
] } },
{ name = "build-setup-linux-x64", condition = { platforms = [
"linux",
] } },
{ name = "build-setup-macos-arm64", condition = { platforms = [
"mac",
] } },
]
[tasks.build-setup-win-x64]
script_runner = "python"
script_extension = "py"
script = '''
import re
from pathlib import Path
src = Path("setup.cfg.template")
content = src.read_text(encoding="utf-8")
content = re.sub("PLATNAME", "win-amd64", content, flags=re.MULTILINE)
dst = Path("setup.cfg")
dst.write_text(content, encoding="utf-8")
'''
[tasks.build-setup-linux-x64]
script_runner = "python"
script_extension = "py"
script = '''
import re
from pathlib import Path
src = Path("setup.cfg.template")
content = src.read_text(encoding="utf-8")
content = re.sub("PLATNAME", "manylinux1_x86_64", content, flags=re.MULTILINE)
dst = Path("setup.cfg")
dst.write_text(content, encoding="utf-8")
'''
[tasks.build-setup-macos-arm64]
script_runner = "python"
script_extension = "py"
script = '''
import re
from pathlib import Path
src = Path("setup.cfg.template")
content = src.read_text(encoding="utf-8")
content = re.sub("PLATNAME", "macosx-11-0-arm64", content, flags=re.MULTILINE)
dst = Path("setup.cfg")
dst.write_text(content, encoding="utf-8")
'''
[tasks.cov]
command = "uv"
args = ["run", "pytest", "-n", "auto", "--cov-config=.coveragerc", "--cov=pyautd3_emulator", "--cov-branch", "--cov-report=${@}"]
dependencies = ["sync", "update-bin"]
[tasks.generate-wrapper]
dependencies = ["generate-wrapper-pre", "generate-wrapper-main", "format", "generate-wrapper-post"]
[tasks.generate-wrapper-pre]
command = "git"
args = ["submodule", "update", "--init"]
[tasks.generate-wrapper-main]
cwd = "./tools/wrapper-generator"
command = "cargo"
args = ["r", "--release"]
[tasks.generate-wrapper-post]
command = "uv"
args = ["run", "ruff", "check", "pyautd3_emulator/native_methods", "--fix"]
[tasks.update-bin]
script_runner = "python"
script_extension = "py"
script = { file = "tools/update_bin.py" }
[tasks.update-version]
script_runner = "python"
script_extension = "py"
script = '''
import sys
import re
from pathlib import Path
version = sys.argv[1]
def substitute_in_file(file: str, pattern: str, repl: str) -> None:
file = Path(file)
content = file.read_text(encoding="utf-8")
content = re.sub(pattern, repl, content, flags=re.MULTILINE)
file.write_text(content, encoding="utf-8")
substitute_in_file("pyautd3_emulator/__init__.py", r'__version__ = "(.*)"', f'__version__ = "{version}"')
substitute_in_file("setup.cfg.template", r"version = (.*)", f"version = {version}")
substitute_in_file("pyproject.toml", r'^version = "(.*)"', f'version = "{version}"')
substitute_in_file("pyproject.toml", r'"pyautd3==(.*)"', f'"pyautd3=={version}"')
'''