cleepcli 1.49.6__tar.gz → 1.49.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cleepcli-1.49.6/cleepcli.egg-info → cleepcli-1.49.7}/PKG-INFO +1 -1
- {cleepcli-1.49.6 → cleepcli-1.49.7}/bin/ccli +22 -8
- {cleepcli-1.49.6 → cleepcli-1.49.7}/bin/cleep-cli +22 -8
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli/pico.py +217 -51
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli/version.py +1 -1
- {cleepcli-1.49.6 → cleepcli-1.49.7/cleepcli.egg-info}/PKG-INFO +1 -1
- {cleepcli-1.49.6 → cleepcli-1.49.7}/tests/test_pico.py +38 -4
- {cleepcli-1.49.6 → cleepcli-1.49.7}/LICENSE +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/MANIFEST.in +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/README.md +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli/__init__.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli/check.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli/ci.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli/cleepapi.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli/config.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli/console.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli/docs.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli/file.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli/git.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli/module.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli/package.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli/systemd/cleep-watch.service +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli/test.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli/tools.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli/watch.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli/watchsvc.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli.egg-info/SOURCES.txt +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli.egg-info/dependency_links.txt +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli.egg-info/requires.txt +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/cleepcli.egg-info/top_level.txt +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/pyproject.toml +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/requirements.txt +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/setup.cfg +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/setup.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/tests/test_check.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/tests/test_config.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/tests/test_console.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/tests/test_coverage.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/tests/test_docs_breaking.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/tests/test_file_sync_all.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/tests/test_module_scaffold.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/tests/test_watch.py +0 -0
- {cleepcli-1.49.6 → cleepcli-1.49.7}/tests/test_watchsvc.py +0 -0
|
@@ -1013,11 +1013,17 @@ def pico_sdk():
|
|
|
1013
1013
|
|
|
1014
1014
|
|
|
1015
1015
|
@pico_sdk.command('install')
|
|
1016
|
+
@click.option(
|
|
1017
|
+
'--version',
|
|
1018
|
+
'version',
|
|
1019
|
+
required=True,
|
|
1020
|
+
help='Git tag or ref to install (caller-chosen; e.g. 2.1.1).',
|
|
1021
|
+
)
|
|
1016
1022
|
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
1017
|
-
def pico_sdk_install(as_json):
|
|
1018
|
-
"""Install toolchain packages and clone the Pico SDK."""
|
|
1023
|
+
def pico_sdk_install(version, as_json):
|
|
1024
|
+
"""Install toolchain packages and clone the Pico SDK at --version."""
|
|
1019
1025
|
try:
|
|
1020
|
-
meta = Pico().sdk_install()
|
|
1026
|
+
meta = Pico().sdk_install(version)
|
|
1021
1027
|
except PicoError as error:
|
|
1022
1028
|
logging.error(str(error))
|
|
1023
1029
|
sys.exit(1)
|
|
@@ -1026,20 +1032,27 @@ def pico_sdk_install(as_json):
|
|
|
1026
1032
|
click.echo(json.dumps(meta, separators=(',', ':')))
|
|
1027
1033
|
else:
|
|
1028
1034
|
logging.info(
|
|
1029
|
-
'SDK installed=%s version=%s revision=%s toolchain_ok=%s',
|
|
1035
|
+
'SDK installed=%s version=%s revision=%s requested=%s toolchain_ok=%s',
|
|
1030
1036
|
meta.get('installed'),
|
|
1031
1037
|
meta.get('version'),
|
|
1032
1038
|
meta.get('revision'),
|
|
1039
|
+
meta.get('requested_version'),
|
|
1033
1040
|
meta.get('toolchain_ok'),
|
|
1034
1041
|
)
|
|
1035
1042
|
|
|
1036
1043
|
|
|
1037
1044
|
@pico_sdk.command('update')
|
|
1045
|
+
@click.option(
|
|
1046
|
+
'--version',
|
|
1047
|
+
'version',
|
|
1048
|
+
required=True,
|
|
1049
|
+
help='Git tag or ref to checkout (caller-chosen; e.g. 2.1.1).',
|
|
1050
|
+
)
|
|
1038
1051
|
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
1039
|
-
def pico_sdk_update(as_json):
|
|
1040
|
-
"""
|
|
1052
|
+
def pico_sdk_update(version, as_json):
|
|
1053
|
+
"""Checkout the Pico SDK at --version and refresh submodules."""
|
|
1041
1054
|
try:
|
|
1042
|
-
meta = Pico().sdk_update()
|
|
1055
|
+
meta = Pico().sdk_update(version)
|
|
1043
1056
|
except PicoError as error:
|
|
1044
1057
|
logging.error(str(error))
|
|
1045
1058
|
sys.exit(1)
|
|
@@ -1047,9 +1060,10 @@ def pico_sdk_update(as_json):
|
|
|
1047
1060
|
click.echo(json.dumps(meta, separators=(',', ':')))
|
|
1048
1061
|
else:
|
|
1049
1062
|
logging.info(
|
|
1050
|
-
'SDK updated version=%s revision=%s',
|
|
1063
|
+
'SDK updated version=%s revision=%s requested=%s',
|
|
1051
1064
|
meta.get('version'),
|
|
1052
1065
|
meta.get('revision'),
|
|
1066
|
+
meta.get('requested_version'),
|
|
1053
1067
|
)
|
|
1054
1068
|
|
|
1055
1069
|
|
|
@@ -1013,11 +1013,17 @@ def pico_sdk():
|
|
|
1013
1013
|
|
|
1014
1014
|
|
|
1015
1015
|
@pico_sdk.command('install')
|
|
1016
|
+
@click.option(
|
|
1017
|
+
'--version',
|
|
1018
|
+
'version',
|
|
1019
|
+
required=True,
|
|
1020
|
+
help='Git tag or ref to install (caller-chosen; e.g. 2.1.1).',
|
|
1021
|
+
)
|
|
1016
1022
|
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
1017
|
-
def pico_sdk_install(as_json):
|
|
1018
|
-
"""Install toolchain packages and clone the Pico SDK."""
|
|
1023
|
+
def pico_sdk_install(version, as_json):
|
|
1024
|
+
"""Install toolchain packages and clone the Pico SDK at --version."""
|
|
1019
1025
|
try:
|
|
1020
|
-
meta = Pico().sdk_install()
|
|
1026
|
+
meta = Pico().sdk_install(version)
|
|
1021
1027
|
except PicoError as error:
|
|
1022
1028
|
logging.error(str(error))
|
|
1023
1029
|
sys.exit(1)
|
|
@@ -1026,20 +1032,27 @@ def pico_sdk_install(as_json):
|
|
|
1026
1032
|
click.echo(json.dumps(meta, separators=(',', ':')))
|
|
1027
1033
|
else:
|
|
1028
1034
|
logging.info(
|
|
1029
|
-
'SDK installed=%s version=%s revision=%s toolchain_ok=%s',
|
|
1035
|
+
'SDK installed=%s version=%s revision=%s requested=%s toolchain_ok=%s',
|
|
1030
1036
|
meta.get('installed'),
|
|
1031
1037
|
meta.get('version'),
|
|
1032
1038
|
meta.get('revision'),
|
|
1039
|
+
meta.get('requested_version'),
|
|
1033
1040
|
meta.get('toolchain_ok'),
|
|
1034
1041
|
)
|
|
1035
1042
|
|
|
1036
1043
|
|
|
1037
1044
|
@pico_sdk.command('update')
|
|
1045
|
+
@click.option(
|
|
1046
|
+
'--version',
|
|
1047
|
+
'version',
|
|
1048
|
+
required=True,
|
|
1049
|
+
help='Git tag or ref to checkout (caller-chosen; e.g. 2.1.1).',
|
|
1050
|
+
)
|
|
1038
1051
|
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
1039
|
-
def pico_sdk_update(as_json):
|
|
1040
|
-
"""
|
|
1052
|
+
def pico_sdk_update(version, as_json):
|
|
1053
|
+
"""Checkout the Pico SDK at --version and refresh submodules."""
|
|
1041
1054
|
try:
|
|
1042
|
-
meta = Pico().sdk_update()
|
|
1055
|
+
meta = Pico().sdk_update(version)
|
|
1043
1056
|
except PicoError as error:
|
|
1044
1057
|
logging.error(str(error))
|
|
1045
1058
|
sys.exit(1)
|
|
@@ -1047,9 +1060,10 @@ def pico_sdk_update(as_json):
|
|
|
1047
1060
|
click.echo(json.dumps(meta, separators=(',', ':')))
|
|
1048
1061
|
else:
|
|
1049
1062
|
logging.info(
|
|
1050
|
-
'SDK updated version=%s revision=%s',
|
|
1063
|
+
'SDK updated version=%s revision=%s requested=%s',
|
|
1051
1064
|
meta.get('version'),
|
|
1052
1065
|
meta.get('revision'),
|
|
1066
|
+
meta.get('requested_version'),
|
|
1053
1067
|
)
|
|
1054
1068
|
|
|
1055
1069
|
|
|
@@ -27,6 +27,9 @@ class Pico:
|
|
|
27
27
|
|
|
28
28
|
# Machine-readable step markers for developer UI progress (stdout).
|
|
29
29
|
STEP_MARKER_PREFIX = "CLEEP_PICO_STEP:"
|
|
30
|
+
# Installed tree ~700 MiB; leave headroom for clone tmp + apt when needed.
|
|
31
|
+
DISK_FREE_TOOLCHAIN_OK_BYTES = 1024 * 1024 * 1024 # 1 GiB
|
|
32
|
+
DISK_FREE_TOOLCHAIN_MISSING_BYTES = 2 * 1024 * 1024 * 1024 # 2 GiB
|
|
30
33
|
INSTALL_STEPS = (
|
|
31
34
|
("toolchain", "Install apt toolchain (cmake, arm-none-eabi)"),
|
|
32
35
|
("clone", "Clone pico-sdk"),
|
|
@@ -35,8 +38,8 @@ class Pico:
|
|
|
35
38
|
)
|
|
36
39
|
UPDATE_STEPS = (
|
|
37
40
|
("toolchain", "Check apt toolchain"),
|
|
38
|
-
("fetch", "Fetch
|
|
39
|
-
("
|
|
41
|
+
("fetch", "Fetch requested pico-sdk ref"),
|
|
42
|
+
("checkout", "Checkout requested pico-sdk ref"),
|
|
40
43
|
("submodules", "Update pico-sdk submodules"),
|
|
41
44
|
)
|
|
42
45
|
|
|
@@ -102,8 +105,98 @@ class Pico:
|
|
|
102
105
|
detail = args if isinstance(args, str) else " ".join(args)
|
|
103
106
|
raise PicoError("%s (exit %s): %s" % (prefix, returncode, detail))
|
|
104
107
|
|
|
108
|
+
@staticmethod
|
|
109
|
+
def _arm_lib_ok(libname: str) -> bool:
|
|
110
|
+
"""
|
|
111
|
+
True when arm-none-eabi-gcc can resolve a real archive (e.g. libc.a).
|
|
112
|
+
|
|
113
|
+
Without libnewlib-arm-none-eabi, the compiler is on PATH but link fails
|
|
114
|
+
with ``cannot find -lc`` / ``-lg``.
|
|
115
|
+
"""
|
|
116
|
+
gcc = shutil.which("arm-none-eabi-gcc")
|
|
117
|
+
if not gcc:
|
|
118
|
+
return False
|
|
119
|
+
try:
|
|
120
|
+
out = subprocess.check_output(
|
|
121
|
+
[gcc, "-print-file-name=%s" % libname],
|
|
122
|
+
text=True,
|
|
123
|
+
stderr=subprocess.DEVNULL,
|
|
124
|
+
).strip()
|
|
125
|
+
except (OSError, subprocess.CalledProcessError):
|
|
126
|
+
return False
|
|
127
|
+
# Missing libs are echoed back as the bare name (not a filesystem path).
|
|
128
|
+
return bool(out) and out != libname and os.path.isfile(out)
|
|
129
|
+
|
|
105
130
|
def _toolchain_ok(self) -> bool:
|
|
106
|
-
return bool(
|
|
131
|
+
return bool(
|
|
132
|
+
shutil.which("cmake")
|
|
133
|
+
and shutil.which("arm-none-eabi-gcc")
|
|
134
|
+
and self._arm_lib_ok("libc.a")
|
|
135
|
+
and self._arm_lib_ok("libg.a")
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
@staticmethod
|
|
139
|
+
def _disk_free_bytes(path: str) -> int:
|
|
140
|
+
"""Return free bytes on the filesystem that holds ``path`` (or its parent)."""
|
|
141
|
+
probe = path
|
|
142
|
+
while probe and not os.path.exists(probe):
|
|
143
|
+
parent = os.path.dirname(probe)
|
|
144
|
+
if parent == probe:
|
|
145
|
+
break
|
|
146
|
+
probe = parent
|
|
147
|
+
if not probe or not os.path.exists(probe):
|
|
148
|
+
probe = "/"
|
|
149
|
+
try:
|
|
150
|
+
usage = os.statvfs(probe)
|
|
151
|
+
except OSError:
|
|
152
|
+
return 0
|
|
153
|
+
return int(usage.f_bavail * usage.f_frsize)
|
|
154
|
+
|
|
155
|
+
def _disk_required_bytes(self) -> int:
|
|
156
|
+
if self._toolchain_ok():
|
|
157
|
+
return self.DISK_FREE_TOOLCHAIN_OK_BYTES
|
|
158
|
+
return self.DISK_FREE_TOOLCHAIN_MISSING_BYTES
|
|
159
|
+
|
|
160
|
+
def _disk_status(self) -> dict[str, Any]:
|
|
161
|
+
free = self._disk_free_bytes(config.PICO_SDK_DIR)
|
|
162
|
+
required = self._disk_required_bytes()
|
|
163
|
+
return {
|
|
164
|
+
"disk_free_bytes": free,
|
|
165
|
+
"disk_required_bytes": required,
|
|
166
|
+
"disk_ok": free >= required,
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@staticmethod
|
|
170
|
+
def _format_bytes(num: int) -> str:
|
|
171
|
+
value = float(max(num, 0))
|
|
172
|
+
for unit in ("B", "KiB", "MiB", "GiB", "TiB"):
|
|
173
|
+
if value < 1024.0 or unit == "TiB":
|
|
174
|
+
if unit == "B":
|
|
175
|
+
return "%d %s" % (int(value), unit)
|
|
176
|
+
return "%.1f %s" % (value, unit)
|
|
177
|
+
value /= 1024.0
|
|
178
|
+
return "%d B" % num
|
|
179
|
+
|
|
180
|
+
def _ensure_disk_space(self) -> None:
|
|
181
|
+
status = self._disk_status()
|
|
182
|
+
if status["disk_ok"]:
|
|
183
|
+
self._emit(
|
|
184
|
+
"Disk space OK: %s free (need %s)."
|
|
185
|
+
% (
|
|
186
|
+
self._format_bytes(status["disk_free_bytes"]),
|
|
187
|
+
self._format_bytes(status["disk_required_bytes"]),
|
|
188
|
+
)
|
|
189
|
+
)
|
|
190
|
+
return
|
|
191
|
+
raise PicoError(
|
|
192
|
+
"Not enough free disk space to install the Pico SDK: "
|
|
193
|
+
"%s free, %s required under %s"
|
|
194
|
+
% (
|
|
195
|
+
self._format_bytes(status["disk_free_bytes"]),
|
|
196
|
+
self._format_bytes(status["disk_required_bytes"]),
|
|
197
|
+
os.path.dirname(config.PICO_SDK_DIR) or config.PICO_SDK_DIR,
|
|
198
|
+
)
|
|
199
|
+
)
|
|
107
200
|
|
|
108
201
|
def _git_revision(self, sdk_dir: str) -> str:
|
|
109
202
|
try:
|
|
@@ -152,7 +245,7 @@ class Pico:
|
|
|
152
245
|
def _load_meta(self) -> dict[str, Any]:
|
|
153
246
|
if not os.path.isfile(config.PICO_SDK_META):
|
|
154
247
|
installed = os.path.isdir(os.path.join(config.PICO_SDK_DIR, ".git"))
|
|
155
|
-
|
|
248
|
+
data = {
|
|
156
249
|
"installed": installed,
|
|
157
250
|
"path": config.PICO_SDK_DIR,
|
|
158
251
|
"revision": self._git_revision(config.PICO_SDK_DIR) if installed else "",
|
|
@@ -160,19 +253,21 @@ class Pico:
|
|
|
160
253
|
"updated_at": None,
|
|
161
254
|
"toolchain_ok": self._toolchain_ok(),
|
|
162
255
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
data
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
data
|
|
174
|
-
|
|
175
|
-
|
|
256
|
+
else:
|
|
257
|
+
try:
|
|
258
|
+
with open(config.PICO_SDK_META, "r", encoding="utf-8") as handle:
|
|
259
|
+
data = json.load(handle)
|
|
260
|
+
except (OSError, json.JSONDecodeError):
|
|
261
|
+
data = {}
|
|
262
|
+
if not isinstance(data, dict):
|
|
263
|
+
data = {}
|
|
264
|
+
data.setdefault("path", config.PICO_SDK_DIR)
|
|
265
|
+
data["toolchain_ok"] = self._toolchain_ok()
|
|
266
|
+
data["installed"] = bool(
|
|
267
|
+
data.get("installed")
|
|
268
|
+
or os.path.isdir(os.path.join(config.PICO_SDK_DIR, ".git"))
|
|
269
|
+
)
|
|
270
|
+
data.update(self._disk_status())
|
|
176
271
|
return data
|
|
177
272
|
|
|
178
273
|
def _ensure_toolchain(self, *, emit_steps: bool = False, step_index: int = 1, step_total: int = 4) -> None:
|
|
@@ -188,8 +283,16 @@ class Pico:
|
|
|
188
283
|
if emit_steps:
|
|
189
284
|
self._emit_step(step_index, step_total, "toolchain", label)
|
|
190
285
|
if self._toolchain_ok():
|
|
191
|
-
self._emit(
|
|
286
|
+
self._emit(
|
|
287
|
+
"Toolchain already present "
|
|
288
|
+
"(cmake, arm-none-eabi-gcc, newlib) — skipping apt."
|
|
289
|
+
)
|
|
192
290
|
return
|
|
291
|
+
if shutil.which("arm-none-eabi-gcc") and not self._arm_lib_ok("libc.a"):
|
|
292
|
+
self._emit(
|
|
293
|
+
"Toolchain incomplete: arm-none-eabi-gcc is installed but newlib "
|
|
294
|
+
"is missing (linker cannot find -lc/-lg). Installing apt packages…"
|
|
295
|
+
)
|
|
193
296
|
packages = " ".join(config.PICO_TOOLCHAIN_PACKAGES)
|
|
194
297
|
self._emit("Installing Pico toolchain packages via apt: %s" % packages)
|
|
195
298
|
self._emit("(This step alone can take several minutes on a Raspberry Pi.)")
|
|
@@ -201,8 +304,8 @@ class Pico:
|
|
|
201
304
|
self._run_streamed(cmd, "Failed to install toolchain packages", shell=True)
|
|
202
305
|
if not self._toolchain_ok():
|
|
203
306
|
raise PicoError(
|
|
204
|
-
"Toolchain still
|
|
205
|
-
"(need cmake
|
|
307
|
+
"Toolchain still incomplete after apt install "
|
|
308
|
+
"(need cmake, arm-none-eabi-gcc, and newlib libc/libg)"
|
|
206
309
|
)
|
|
207
310
|
self._emit("Toolchain install complete.")
|
|
208
311
|
|
|
@@ -210,35 +313,103 @@ class Pico:
|
|
|
210
313
|
"""Return SDK installation metadata."""
|
|
211
314
|
return self._load_meta()
|
|
212
315
|
|
|
213
|
-
|
|
214
|
-
|
|
316
|
+
@staticmethod
|
|
317
|
+
def _require_version(version: str) -> str:
|
|
318
|
+
"""Caller-chosen git tag/branch/ref (CLI does not pick a default)."""
|
|
319
|
+
ref = (version or "").strip()
|
|
320
|
+
if not ref:
|
|
321
|
+
raise PicoError(
|
|
322
|
+
"Pico SDK version/ref is required "
|
|
323
|
+
'(e.g. cleep-cli pico sdk install --version 2.1.1)'
|
|
324
|
+
)
|
|
325
|
+
return ref
|
|
326
|
+
|
|
327
|
+
def _fetch_ref(self, sdk_dir: str, version: str) -> None:
|
|
328
|
+
"""
|
|
329
|
+
Shallow-fetch ``version`` (tag or branch) into FETCH_HEAD.
|
|
330
|
+
|
|
331
|
+
Trusts the caller-provided ref; probes ``git fetch … tag`` quietly,
|
|
332
|
+
then falls back to a plain ref fetch for branches.
|
|
333
|
+
"""
|
|
334
|
+
self._emit("Fetching %s (quiet)…" % version)
|
|
335
|
+
tag_cmd = [
|
|
336
|
+
"git",
|
|
337
|
+
"-C",
|
|
338
|
+
sdk_dir,
|
|
339
|
+
"fetch",
|
|
340
|
+
"--depth",
|
|
341
|
+
"1",
|
|
342
|
+
"origin",
|
|
343
|
+
"tag",
|
|
344
|
+
version,
|
|
345
|
+
]
|
|
346
|
+
tag_probe = subprocess.run(
|
|
347
|
+
tag_cmd,
|
|
348
|
+
stdout=subprocess.DEVNULL,
|
|
349
|
+
stderr=subprocess.DEVNULL,
|
|
350
|
+
check=False,
|
|
351
|
+
)
|
|
352
|
+
if tag_probe.returncode == 0:
|
|
353
|
+
return
|
|
354
|
+
self._emit("Not a tag — fetching as branch/ref %s…" % version)
|
|
355
|
+
self._run_streamed(
|
|
356
|
+
[
|
|
357
|
+
"git",
|
|
358
|
+
"-C",
|
|
359
|
+
sdk_dir,
|
|
360
|
+
"fetch",
|
|
361
|
+
"--depth",
|
|
362
|
+
"1",
|
|
363
|
+
"origin",
|
|
364
|
+
version,
|
|
365
|
+
],
|
|
366
|
+
"SDK fetch failed",
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
def _checkout_fetch_head(self, sdk_dir: str) -> None:
|
|
370
|
+
self._run_streamed(
|
|
371
|
+
["git", "-C", sdk_dir, "checkout", "--force", "--detach", "FETCH_HEAD"],
|
|
372
|
+
"SDK checkout failed",
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
def sdk_install(self, version: str) -> dict[str, Any]:
|
|
376
|
+
"""Install toolchain packages + clone pico-sdk at ``version``."""
|
|
377
|
+
version = self._require_version(version)
|
|
215
378
|
total = len(self.INSTALL_STEPS)
|
|
216
379
|
self._emit(
|
|
217
|
-
"Pico SDK install started (often 10+ minutes on first run — "
|
|
218
|
-
"apt toolchain + git clone + submodules)."
|
|
380
|
+
"Pico SDK install started (ref %s — often 10+ minutes on first run — "
|
|
381
|
+
"apt toolchain + git clone + submodules)." % version
|
|
219
382
|
)
|
|
383
|
+
self._ensure_disk_space()
|
|
220
384
|
self._ensure_toolchain(emit_steps=True, step_index=1, step_total=total)
|
|
221
385
|
|
|
222
386
|
sdk_dir = config.PICO_SDK_DIR
|
|
223
387
|
if os.path.isdir(os.path.join(sdk_dir, ".git")):
|
|
224
|
-
self._emit(
|
|
225
|
-
|
|
388
|
+
self._emit(
|
|
389
|
+
"Pico SDK already installed at %s — switching to update (%s)."
|
|
390
|
+
% (sdk_dir, version)
|
|
391
|
+
)
|
|
392
|
+
return self.sdk_update(version)
|
|
226
393
|
|
|
227
394
|
os.makedirs(os.path.dirname(sdk_dir), exist_ok=True)
|
|
228
395
|
if os.path.exists(sdk_dir):
|
|
229
396
|
shutil.rmtree(sdk_dir)
|
|
230
397
|
|
|
231
398
|
self._emit_step(2, total, "clone", self.INSTALL_STEPS[1][1])
|
|
232
|
-
|
|
399
|
+
# No --progress: percent spam floods the developer RPC bus.
|
|
400
|
+
# --branch accepts tags and branch names.
|
|
401
|
+
self._emit(
|
|
402
|
+
"Cloning %s @ %s into %s (quiet — can take several minutes)…"
|
|
403
|
+
% (config.PICO_SDK_REPO, version, sdk_dir)
|
|
404
|
+
)
|
|
233
405
|
self._run_streamed(
|
|
234
406
|
[
|
|
235
407
|
"git",
|
|
236
408
|
"clone",
|
|
237
|
-
"--progress",
|
|
238
409
|
"--depth",
|
|
239
410
|
"1",
|
|
240
411
|
"--branch",
|
|
241
|
-
|
|
412
|
+
version,
|
|
242
413
|
config.PICO_SDK_REPO,
|
|
243
414
|
sdk_dir,
|
|
244
415
|
],
|
|
@@ -246,6 +417,8 @@ class Pico:
|
|
|
246
417
|
)
|
|
247
418
|
|
|
248
419
|
self._emit_step(3, total, "submodules", self.INSTALL_STEPS[2][1])
|
|
420
|
+
# No --progress: submodule file spam freezes the developer UI console.
|
|
421
|
+
self._emit("Initializing submodules (quiet — can take several minutes)…")
|
|
249
422
|
self._run_streamed(
|
|
250
423
|
[
|
|
251
424
|
"git",
|
|
@@ -254,16 +427,15 @@ class Pico:
|
|
|
254
427
|
"submodule",
|
|
255
428
|
"update",
|
|
256
429
|
"--init",
|
|
257
|
-
"--progress",
|
|
258
430
|
],
|
|
259
431
|
"git submodule update failed",
|
|
260
432
|
)
|
|
261
433
|
|
|
262
434
|
self._emit_step(4, total, "finalize", self.INSTALL_STEPS[3][1])
|
|
263
|
-
meta = self._write_meta()
|
|
435
|
+
meta = self._write_meta(requested_version=version)
|
|
264
436
|
self._emit(
|
|
265
|
-
"Pico SDK installed (%s / %s)"
|
|
266
|
-
% (meta.get("version"), meta.get("revision"))
|
|
437
|
+
"Pico SDK installed (%s / %s) [requested %s]"
|
|
438
|
+
% (meta.get("version"), meta.get("revision"), version)
|
|
267
439
|
)
|
|
268
440
|
self._emit(
|
|
269
441
|
"%s%s/%s:done:Install complete"
|
|
@@ -271,29 +443,24 @@ class Pico:
|
|
|
271
443
|
)
|
|
272
444
|
return meta
|
|
273
445
|
|
|
274
|
-
def sdk_update(self) -> dict[str, Any]:
|
|
275
|
-
"""
|
|
446
|
+
def sdk_update(self, version: str) -> dict[str, Any]:
|
|
447
|
+
"""Checkout pico-sdk ``version`` and refresh submodules."""
|
|
448
|
+
version = self._require_version(version)
|
|
276
449
|
total = len(self.UPDATE_STEPS)
|
|
277
|
-
self._emit("Pico SDK update started.")
|
|
450
|
+
self._emit("Pico SDK update started (ref %s)." % version)
|
|
278
451
|
self._ensure_toolchain(emit_steps=True, step_index=1, step_total=total)
|
|
279
452
|
|
|
280
453
|
sdk_dir = config.PICO_SDK_DIR
|
|
281
454
|
if not os.path.isdir(os.path.join(sdk_dir, ".git")):
|
|
282
|
-
return self.sdk_install()
|
|
455
|
+
return self.sdk_install(version)
|
|
283
456
|
|
|
284
457
|
self._emit_step(2, total, "fetch", self.UPDATE_STEPS[1][1])
|
|
285
|
-
self.
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
)
|
|
289
|
-
|
|
290
|
-
self._emit_step(3, total, "reset", self.UPDATE_STEPS[2][1])
|
|
291
|
-
self._run_streamed(
|
|
292
|
-
["git", "-C", sdk_dir, "reset", "--hard", "origin/master"],
|
|
293
|
-
"SDK reset failed",
|
|
294
|
-
)
|
|
458
|
+
self._fetch_ref(sdk_dir, version)
|
|
459
|
+
self._emit_step(3, total, "checkout", self.UPDATE_STEPS[2][1])
|
|
460
|
+
self._checkout_fetch_head(sdk_dir)
|
|
295
461
|
|
|
296
462
|
self._emit_step(4, total, "submodules", self.UPDATE_STEPS[3][1])
|
|
463
|
+
self._emit("Updating submodules (quiet — can take several minutes)…")
|
|
297
464
|
self._run_streamed(
|
|
298
465
|
[
|
|
299
466
|
"git",
|
|
@@ -303,15 +470,14 @@ class Pico:
|
|
|
303
470
|
"update",
|
|
304
471
|
"--init",
|
|
305
472
|
"--recursive",
|
|
306
|
-
"--progress",
|
|
307
473
|
],
|
|
308
474
|
"SDK submodule update failed",
|
|
309
475
|
)
|
|
310
476
|
|
|
311
|
-
meta = self._write_meta()
|
|
477
|
+
meta = self._write_meta(requested_version=version)
|
|
312
478
|
self._emit(
|
|
313
|
-
"Pico SDK updated (%s / %s)"
|
|
314
|
-
% (meta.get("version"), meta.get("revision"))
|
|
479
|
+
"Pico SDK updated (%s / %s) [requested %s]"
|
|
480
|
+
% (meta.get("version"), meta.get("revision"), version)
|
|
315
481
|
)
|
|
316
482
|
self._emit(
|
|
317
483
|
"%s%s/%s:done:Update complete"
|
|
@@ -31,9 +31,34 @@ class PicoSdkTests(unittest.TestCase):
|
|
|
31
31
|
|
|
32
32
|
def test_sdk_info_not_installed(self):
|
|
33
33
|
with patch.object(self.pico, "_toolchain_ok", return_value=True):
|
|
34
|
-
|
|
34
|
+
with patch.object(self.pico, "_disk_free_bytes", return_value=2 * 1024 * 1024 * 1024):
|
|
35
|
+
info = self.pico.sdk_info()
|
|
35
36
|
self.assertFalse(info["installed"])
|
|
36
37
|
self.assertTrue(info["toolchain_ok"])
|
|
38
|
+
self.assertTrue(info["disk_ok"])
|
|
39
|
+
self.assertEqual(info["disk_required_bytes"], Pico.DISK_FREE_TOOLCHAIN_OK_BYTES)
|
|
40
|
+
|
|
41
|
+
def test_ensure_disk_space_raises(self):
|
|
42
|
+
with patch.object(self.pico, "_toolchain_ok", return_value=True):
|
|
43
|
+
with patch.object(self.pico, "_disk_free_bytes", return_value=10 * 1024 * 1024):
|
|
44
|
+
with self.assertRaises(PicoError) as ctx:
|
|
45
|
+
self.pico._ensure_disk_space()
|
|
46
|
+
self.assertIn("Not enough free disk space", str(ctx.exception))
|
|
47
|
+
|
|
48
|
+
def test_arm_lib_ok_rejects_echoed_name(self):
|
|
49
|
+
with patch("cleepcli.pico.shutil.which", return_value="/usr/bin/arm-none-eabi-gcc"):
|
|
50
|
+
with patch("cleepcli.pico.subprocess.check_output", return_value="libc.a\n"):
|
|
51
|
+
with patch("cleepcli.pico.os.path.isfile", return_value=False):
|
|
52
|
+
self.assertFalse(self.pico._arm_lib_ok("libc.a"))
|
|
53
|
+
|
|
54
|
+
def test_arm_lib_ok_accepts_realpath(self):
|
|
55
|
+
with patch("cleepcli.pico.shutil.which", return_value="/usr/bin/arm-none-eabi-gcc"):
|
|
56
|
+
with patch(
|
|
57
|
+
"cleepcli.pico.subprocess.check_output",
|
|
58
|
+
return_value="/usr/lib/arm-none-eabi/newlib/libc.a\n",
|
|
59
|
+
):
|
|
60
|
+
with patch("cleepcli.pico.os.path.isfile", return_value=True):
|
|
61
|
+
self.assertTrue(self.pico._arm_lib_ok("libc.a"))
|
|
37
62
|
|
|
38
63
|
def test_sdk_uninstall_removes_meta(self):
|
|
39
64
|
os.makedirs(self.sdk_dir)
|
|
@@ -45,11 +70,19 @@ class PicoSdkTests(unittest.TestCase):
|
|
|
45
70
|
self.assertFalse(os.path.isfile(self.meta))
|
|
46
71
|
self.assertFalse(info["installed"])
|
|
47
72
|
|
|
73
|
+
def test_require_version_rejects_empty(self):
|
|
74
|
+
with self.assertRaises(PicoError):
|
|
75
|
+
self.pico._require_version("")
|
|
76
|
+
with self.assertRaises(PicoError):
|
|
77
|
+
self.pico._require_version(" ")
|
|
78
|
+
|
|
48
79
|
@patch.object(Pico, "_run_streamed")
|
|
49
80
|
@patch.object(Pico, "_ensure_toolchain")
|
|
50
|
-
|
|
81
|
+
@patch.object(Pico, "_ensure_disk_space")
|
|
82
|
+
def test_sdk_install_clones(self, _disk, _toolchain, streamed_mock):
|
|
51
83
|
def _streamed(args, error_prefix, shell=False):
|
|
52
84
|
if isinstance(args, list) and args[0:2] == ["git", "clone"]:
|
|
85
|
+
self.assertEqual(args[args.index("--branch") + 1], "2.1.1")
|
|
53
86
|
os.makedirs(os.path.join(self.sdk_dir, ".git"), exist_ok=True)
|
|
54
87
|
|
|
55
88
|
streamed_mock.side_effect = _streamed
|
|
@@ -59,10 +92,11 @@ class PicoSdkTests(unittest.TestCase):
|
|
|
59
92
|
shutil.rmtree(self.sdk_dir)
|
|
60
93
|
|
|
61
94
|
with patch.object(self.pico, "_git_revision", return_value="deadbee"):
|
|
62
|
-
with patch.object(self.pico, "_git_describe", return_value="2.
|
|
95
|
+
with patch.object(self.pico, "_git_describe", return_value="2.1.1"):
|
|
63
96
|
with patch.object(self.pico, "_toolchain_ok", return_value=True):
|
|
64
|
-
meta = self.pico.sdk_install()
|
|
97
|
+
meta = self.pico.sdk_install("2.1.1")
|
|
65
98
|
self.assertTrue(meta["installed"])
|
|
99
|
+
self.assertEqual(meta["requested_version"], "2.1.1")
|
|
66
100
|
self.assertTrue(os.path.isfile(self.meta))
|
|
67
101
|
self.assertGreaterEqual(streamed_mock.call_count, 2)
|
|
68
102
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|