webcompy-cli 0.0.14__py3-none-any.whl
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.
- webcompy_cli/__init__.py +20 -0
- webcompy_cli/_argparser.py +232 -0
- webcompy_cli/_browser_probes.py +648 -0
- webcompy_cli/_browser_test_harness.py +554 -0
- webcompy_cli/_build.py +425 -0
- webcompy_cli/_console_types.py +15 -0
- webcompy_cli/_dependency_resolver.py +301 -0
- webcompy_cli/_dualrun_pytest_plugin.py +130 -0
- webcompy_cli/_exception.py +9 -0
- webcompy_cli/_generate.py +224 -0
- webcompy_cli/_init_project.py +54 -0
- webcompy_cli/_inspect.py +741 -0
- webcompy_cli/_inspect_pyexec.py +244 -0
- webcompy_cli/_lock.py +82 -0
- webcompy_cli/_lockfile.py +396 -0
- webcompy_cli/_lockfile_sync.py +343 -0
- webcompy_cli/_output.py +150 -0
- webcompy_cli/_prebuild.py +661 -0
- webcompy_cli/_pwa.py +474 -0
- webcompy_cli/_pyodide_downloader.py +113 -0
- webcompy_cli/_pyodide_lock.py +74 -0
- webcompy_cli/_runtime_downloader.py +222 -0
- webcompy_cli/_server.py +568 -0
- webcompy_cli/_static_files.py +27 -0
- webcompy_cli/_utils.py +72 -0
- webcompy_cli/_version_sweep.py +213 -0
- webcompy_cli/_wheel_builder.py +509 -0
- webcompy_cli/config/__init__.py +23 -0
- webcompy_cli/config/_build_config.py +168 -0
- webcompy_cli/config/_pwa_config.py +203 -0
- webcompy_cli/config/_server_config.py +53 -0
- webcompy_cli/py.typed +0 -0
- webcompy_cli/template_data/app/__init__.py +0 -0
- webcompy_cli/template_data/app/app.py +22 -0
- webcompy_cli/template_data/app/components/__init__.py +0 -0
- webcompy_cli/template_data/app/components/fizzbuzz.py +117 -0
- webcompy_cli/template_data/app/components/home.py +15 -0
- webcompy_cli/template_data/app/components/input.py +34 -0
- webcompy_cli/template_data/app/components/navigation.py +36 -0
- webcompy_cli/template_data/app/components/not_found.py +22 -0
- webcompy_cli/template_data/app/components/root.py +16 -0
- webcompy_cli/template_data/app/router.py +17 -0
- webcompy_cli/template_data/webcompy_config.py +12 -0
- webcompy_cli-0.0.14.dist-info/METADATA +53 -0
- webcompy_cli-0.0.14.dist-info/RECORD +47 -0
- webcompy_cli-0.0.14.dist-info/WHEEL +4 -0
- webcompy_cli-0.0.14.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
"""Lock file schema and helpers for reproducible browser dependencies."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import pathlib
|
|
7
|
+
from dataclasses import dataclass, field
|
|
8
|
+
|
|
9
|
+
from webcompy_cli._pyodide_lock import (
|
|
10
|
+
PyodideLockFetchError,
|
|
11
|
+
fetch_pyodide_lock,
|
|
12
|
+
get_pyodide_version,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
LOCKFILE_VERSION = 2
|
|
16
|
+
LOCKFILE_NAME = "webcompy-lock.json"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class WasmPackageEntry:
|
|
21
|
+
version: str
|
|
22
|
+
file_name: str
|
|
23
|
+
sha256: str | None = None
|
|
24
|
+
source: str = "explicit"
|
|
25
|
+
|
|
26
|
+
def to_dict(self) -> dict:
|
|
27
|
+
d: dict = {
|
|
28
|
+
"version": self.version,
|
|
29
|
+
"file_name": self.file_name,
|
|
30
|
+
"source": self.source,
|
|
31
|
+
}
|
|
32
|
+
if self.sha256 is not None:
|
|
33
|
+
d["sha256"] = self.sha256
|
|
34
|
+
return d
|
|
35
|
+
|
|
36
|
+
@classmethod
|
|
37
|
+
def from_dict(cls, data: dict) -> WasmPackageEntry:
|
|
38
|
+
return cls(
|
|
39
|
+
version=data["version"],
|
|
40
|
+
file_name=data["file_name"],
|
|
41
|
+
sha256=data.get("sha256"),
|
|
42
|
+
source=data.get("source", "explicit"),
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@dataclass
|
|
47
|
+
class PurePythonPackageEntry:
|
|
48
|
+
version: str
|
|
49
|
+
source: str
|
|
50
|
+
in_pyodide_cdn: bool
|
|
51
|
+
pyodide_file_name: str | None = None
|
|
52
|
+
pyodide_sha256: str | None = None
|
|
53
|
+
|
|
54
|
+
def to_dict(self) -> dict:
|
|
55
|
+
d: dict = {
|
|
56
|
+
"version": self.version,
|
|
57
|
+
"source": self.source,
|
|
58
|
+
"in_pyodide_cdn": self.in_pyodide_cdn,
|
|
59
|
+
}
|
|
60
|
+
if self.in_pyodide_cdn and self.pyodide_file_name is not None:
|
|
61
|
+
d["pyodide_file_name"] = self.pyodide_file_name
|
|
62
|
+
if self.in_pyodide_cdn and self.pyodide_sha256 is not None:
|
|
63
|
+
d["pyodide_sha256"] = self.pyodide_sha256
|
|
64
|
+
return d
|
|
65
|
+
|
|
66
|
+
@classmethod
|
|
67
|
+
def from_dict(cls, data: dict) -> PurePythonPackageEntry:
|
|
68
|
+
return cls(
|
|
69
|
+
version=data["version"],
|
|
70
|
+
source=data["source"],
|
|
71
|
+
in_pyodide_cdn=data["in_pyodide_cdn"],
|
|
72
|
+
pyodide_file_name=data.get("pyodide_file_name"),
|
|
73
|
+
pyodide_sha256=data.get("pyodide_sha256"),
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@dataclass
|
|
78
|
+
class RuntimeAssetEntry:
|
|
79
|
+
url: str
|
|
80
|
+
sha256: str | None = None
|
|
81
|
+
|
|
82
|
+
def to_dict(self) -> dict:
|
|
83
|
+
return {"url": self.url, "sha256": self.sha256}
|
|
84
|
+
|
|
85
|
+
@classmethod
|
|
86
|
+
def from_dict(cls, data: dict) -> RuntimeAssetEntry:
|
|
87
|
+
return cls(
|
|
88
|
+
url=data["url"],
|
|
89
|
+
sha256=data.get("sha256"),
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@dataclass
|
|
94
|
+
class Lockfile:
|
|
95
|
+
pyodide_version: str
|
|
96
|
+
pyscript_version: str
|
|
97
|
+
wasm_packages: dict[str, WasmPackageEntry] = field(default_factory=dict)
|
|
98
|
+
pure_python_packages: dict[str, PurePythonPackageEntry] = field(default_factory=dict)
|
|
99
|
+
wasm_serving: str = "cdn"
|
|
100
|
+
runtime_serving: str = "cdn"
|
|
101
|
+
runtime_assets: dict[str, RuntimeAssetEntry] = field(default_factory=dict)
|
|
102
|
+
standalone: bool = False
|
|
103
|
+
|
|
104
|
+
def to_dict(self) -> dict:
|
|
105
|
+
d: dict = {
|
|
106
|
+
"version": LOCKFILE_VERSION,
|
|
107
|
+
"pyodide_version": self.pyodide_version,
|
|
108
|
+
"pyscript_version": self.pyscript_version,
|
|
109
|
+
"wasm_serving": self.wasm_serving,
|
|
110
|
+
"runtime_serving": self.runtime_serving,
|
|
111
|
+
"standalone": self.standalone,
|
|
112
|
+
"wasm_packages": {name: entry.to_dict() for name, entry in self.wasm_packages.items()},
|
|
113
|
+
"pure_python_packages": {name: entry.to_dict() for name, entry in self.pure_python_packages.items()},
|
|
114
|
+
}
|
|
115
|
+
if self.runtime_serving == "local":
|
|
116
|
+
d["runtime_assets"] = {name: entry.to_dict() for name, entry in self.runtime_assets.items()}
|
|
117
|
+
return d
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def load_lockfile(path: pathlib.Path) -> Lockfile | None:
|
|
121
|
+
if not path.is_file():
|
|
122
|
+
return None
|
|
123
|
+
try:
|
|
124
|
+
data = json.loads(path.read_text(encoding="utf-8"))
|
|
125
|
+
except (json.JSONDecodeError, OSError):
|
|
126
|
+
return None
|
|
127
|
+
if data.get("version") != LOCKFILE_VERSION:
|
|
128
|
+
return None
|
|
129
|
+
wasm_packages = {name: WasmPackageEntry.from_dict(entry) for name, entry in data.get("wasm_packages", {}).items()}
|
|
130
|
+
pure_python_packages = {
|
|
131
|
+
name: PurePythonPackageEntry.from_dict(entry) for name, entry in data.get("pure_python_packages", {}).items()
|
|
132
|
+
}
|
|
133
|
+
runtime_assets_data = data.get("runtime_assets") or data.get("standalone_assets")
|
|
134
|
+
runtime_assets: dict[str, RuntimeAssetEntry] = {}
|
|
135
|
+
if runtime_assets_data:
|
|
136
|
+
runtime_assets = {name: RuntimeAssetEntry.from_dict(entry) for name, entry in runtime_assets_data.items()}
|
|
137
|
+
return Lockfile(
|
|
138
|
+
pyodide_version=data["pyodide_version"],
|
|
139
|
+
pyscript_version=data["pyscript_version"],
|
|
140
|
+
wasm_packages=wasm_packages,
|
|
141
|
+
pure_python_packages=pure_python_packages,
|
|
142
|
+
wasm_serving=data.get("wasm_serving", "cdn"),
|
|
143
|
+
runtime_serving=data.get("runtime_serving", "cdn"),
|
|
144
|
+
runtime_assets=runtime_assets,
|
|
145
|
+
standalone=data.get("standalone", False),
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def save_lockfile(lockfile: Lockfile, path: pathlib.Path) -> None:
|
|
150
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
151
|
+
path.write_text(
|
|
152
|
+
json.dumps(lockfile.to_dict(), indent=2) + "\n",
|
|
153
|
+
encoding="utf-8",
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def generate_lockfile(
|
|
158
|
+
dependencies: list[str],
|
|
159
|
+
pyscript_version: str,
|
|
160
|
+
modules_dir: pathlib.Path,
|
|
161
|
+
pyodide_version: str | None = None,
|
|
162
|
+
wasm_serving: str = "cdn",
|
|
163
|
+
runtime_serving: str = "cdn",
|
|
164
|
+
standalone: bool = False,
|
|
165
|
+
) -> tuple[Lockfile, list[str], list[str]]:
|
|
166
|
+
if pyodide_version is None:
|
|
167
|
+
pyodide_version = get_pyodide_version(pyscript_version)
|
|
168
|
+
|
|
169
|
+
pyodide_lock = fetch_pyodide_lock(pyodide_version, modules_dir)
|
|
170
|
+
|
|
171
|
+
from webcompy_cli._dependency_resolver import PackageKind, classify_dependencies
|
|
172
|
+
|
|
173
|
+
classified, errors, warnings = classify_dependencies(dependencies, pyodide_lock)
|
|
174
|
+
|
|
175
|
+
wasm_packages: dict[str, WasmPackageEntry] = {}
|
|
176
|
+
pure_python_packages: dict[str, PurePythonPackageEntry] = {}
|
|
177
|
+
|
|
178
|
+
for dep in classified:
|
|
179
|
+
lock_source = dep.source
|
|
180
|
+
if dep.kind == PackageKind.WASM:
|
|
181
|
+
pkg_info = pyodide_lock.get("packages", {}).get(dep.name, {})
|
|
182
|
+
file_name = pkg_info.get("file_name", "")
|
|
183
|
+
sha256 = dep.pyodide_sha256
|
|
184
|
+
wasm_packages[dep.name] = WasmPackageEntry(
|
|
185
|
+
version=dep.version,
|
|
186
|
+
file_name=file_name,
|
|
187
|
+
sha256=sha256,
|
|
188
|
+
source=lock_source,
|
|
189
|
+
)
|
|
190
|
+
elif dep.kind in (PackageKind.CDN_PURE_PYTHON, PackageKind.LOCAL_PURE_PYTHON):
|
|
191
|
+
is_cdn = dep.kind == PackageKind.CDN_PURE_PYTHON
|
|
192
|
+
entry = PurePythonPackageEntry(
|
|
193
|
+
version=dep.version,
|
|
194
|
+
source=lock_source,
|
|
195
|
+
in_pyodide_cdn=is_cdn,
|
|
196
|
+
pyodide_file_name=dep.pyodide_file_name if is_cdn else None,
|
|
197
|
+
pyodide_sha256=dep.pyodide_sha256 if is_cdn else None,
|
|
198
|
+
)
|
|
199
|
+
pure_python_packages[dep.name] = entry
|
|
200
|
+
|
|
201
|
+
runtime_assets: dict[str, RuntimeAssetEntry] = {}
|
|
202
|
+
if runtime_serving == "local":
|
|
203
|
+
from webcompy_cli._pyodide_lock import PYODIDE_RUNTIME_URL_TEMPLATE
|
|
204
|
+
from webcompy_cli._runtime_downloader import PYSCRIPT_OFFLINE_URL_TEMPLATE, get_pyodide_runtime_assets
|
|
205
|
+
|
|
206
|
+
offline_url = PYSCRIPT_OFFLINE_URL_TEMPLATE.format(pyscript_version=pyscript_version)
|
|
207
|
+
for asset_key in ("core.js", "core.css"):
|
|
208
|
+
runtime_assets[asset_key] = RuntimeAssetEntry(url=offline_url)
|
|
209
|
+
for asset_key in get_pyodide_runtime_assets(pyodide_version):
|
|
210
|
+
url = PYODIDE_RUNTIME_URL_TEMPLATE.format(pyodide_version=pyodide_version, filename=asset_key)
|
|
211
|
+
runtime_assets[asset_key] = RuntimeAssetEntry(url=url)
|
|
212
|
+
|
|
213
|
+
lockfile = Lockfile(
|
|
214
|
+
pyodide_version=pyodide_version,
|
|
215
|
+
pyscript_version=pyscript_version,
|
|
216
|
+
wasm_packages=wasm_packages,
|
|
217
|
+
pure_python_packages=pure_python_packages,
|
|
218
|
+
wasm_serving=wasm_serving,
|
|
219
|
+
runtime_serving=runtime_serving,
|
|
220
|
+
runtime_assets=runtime_assets,
|
|
221
|
+
standalone=standalone,
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
return lockfile, errors, warnings
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def validate_lockfile(
|
|
228
|
+
lockfile: Lockfile,
|
|
229
|
+
dependencies: list[str],
|
|
230
|
+
) -> list[str]:
|
|
231
|
+
issues: list[str] = []
|
|
232
|
+
explicit_pp = {name for name, entry in lockfile.pure_python_packages.items() if entry.source == "explicit"}
|
|
233
|
+
explicit_wasm = {name for name, entry in lockfile.wasm_packages.items() if entry.source == "explicit"}
|
|
234
|
+
all_explicit_in_lock = explicit_pp | explicit_wasm
|
|
235
|
+
dep_set = {d.replace("-", "_") for d in dependencies}
|
|
236
|
+
lock_set = {n.replace("-", "_") for n in all_explicit_in_lock}
|
|
237
|
+
missing = dep_set - lock_set
|
|
238
|
+
if missing:
|
|
239
|
+
issues.append(f"Dependencies missing from lock file: {', '.join(sorted(missing))}")
|
|
240
|
+
return issues
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def validate_local_environment(
|
|
244
|
+
lockfile: Lockfile,
|
|
245
|
+
serve_all_deps: bool = True,
|
|
246
|
+
) -> tuple[list[str], list[str]]:
|
|
247
|
+
errors: list[str] = []
|
|
248
|
+
warnings: list[str] = []
|
|
249
|
+
from webcompy_cli._dependency_resolver import _find_package_dir, _get_package_version
|
|
250
|
+
|
|
251
|
+
for name, entry in lockfile.pure_python_packages.items():
|
|
252
|
+
if entry.in_pyodide_cdn:
|
|
253
|
+
local_version = _get_package_version(name)
|
|
254
|
+
if local_version is not None and local_version != entry.version:
|
|
255
|
+
warnings.append(
|
|
256
|
+
f"Package '{name}' version mismatch: lock file has {entry.version}, "
|
|
257
|
+
f"local has {local_version}. "
|
|
258
|
+
f"The local version will be used for SSR/SSG, "
|
|
259
|
+
f"while the CDN version will be used in the browser."
|
|
260
|
+
)
|
|
261
|
+
elif local_version is None:
|
|
262
|
+
warnings.append(
|
|
263
|
+
f"Package '{name}' (version {entry.version}) is available in the Pyodide CDN "
|
|
264
|
+
f"and will be {'downloaded and bundled' if serve_all_deps else 'loaded from CDN'}. "
|
|
265
|
+
f"It is not installed locally, which may affect SSR/SSG."
|
|
266
|
+
)
|
|
267
|
+
else:
|
|
268
|
+
pkg_dir = _find_package_dir(name)
|
|
269
|
+
if pkg_dir is None:
|
|
270
|
+
errors.append(
|
|
271
|
+
f"Package '{name}' (version {entry.version}) listed in lock file "
|
|
272
|
+
f"is not installed locally. Install it with: pip install {name}=={entry.version}"
|
|
273
|
+
)
|
|
274
|
+
continue
|
|
275
|
+
local_version = _get_package_version(name)
|
|
276
|
+
if local_version is None or local_version != entry.version:
|
|
277
|
+
if local_version is None:
|
|
278
|
+
errors.append(
|
|
279
|
+
f"Package '{name}' version could not be determined locally, "
|
|
280
|
+
f"but lock file requires {entry.version}. "
|
|
281
|
+
f"Ensure the package is properly installed with: pip install {name}=={entry.version}"
|
|
282
|
+
)
|
|
283
|
+
else:
|
|
284
|
+
errors.append(
|
|
285
|
+
f"Package '{name}' version mismatch: lock file has {entry.version}, "
|
|
286
|
+
f"local has {local_version}. "
|
|
287
|
+
f"Install the correct version with: pip install {name}=={entry.version}"
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
return errors, warnings
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def get_bundled_deps(
|
|
294
|
+
lockfile: Lockfile | None,
|
|
295
|
+
serve_all_deps: bool = True,
|
|
296
|
+
) -> list[tuple[str, pathlib.Path]]:
|
|
297
|
+
if lockfile is None:
|
|
298
|
+
return []
|
|
299
|
+
from webcompy_cli._dependency_resolver import _find_package_dir
|
|
300
|
+
|
|
301
|
+
result: list[tuple[str, pathlib.Path]] = []
|
|
302
|
+
seen: set[str] = set()
|
|
303
|
+
for name, entry in lockfile.pure_python_packages.items():
|
|
304
|
+
if entry.in_pyodide_cdn:
|
|
305
|
+
continue
|
|
306
|
+
norm = name.replace("-", "_")
|
|
307
|
+
if norm in seen:
|
|
308
|
+
continue
|
|
309
|
+
seen.add(norm)
|
|
310
|
+
pkg_dir = _find_package_dir(name)
|
|
311
|
+
if pkg_dir is not None:
|
|
312
|
+
result.append((name, pkg_dir))
|
|
313
|
+
return result
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
def get_wasm_package_names(
|
|
317
|
+
lockfile: Lockfile | None,
|
|
318
|
+
) -> list[str]:
|
|
319
|
+
if lockfile is None:
|
|
320
|
+
return []
|
|
321
|
+
return list(lockfile.wasm_packages.keys())
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def get_cdn_pure_python_package_names(
|
|
325
|
+
lockfile: Lockfile | None,
|
|
326
|
+
) -> list[str]:
|
|
327
|
+
if lockfile is None:
|
|
328
|
+
return []
|
|
329
|
+
return [name for name, entry in lockfile.pure_python_packages.items() if entry.in_pyodide_cdn]
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
def verify_and_update_runtime_assets(
|
|
333
|
+
runtime_asset_results: dict[str, tuple[pathlib.Path, str]],
|
|
334
|
+
lockfile: Lockfile,
|
|
335
|
+
pyscript_version: str,
|
|
336
|
+
lockfile_path: pathlib.Path,
|
|
337
|
+
) -> None:
|
|
338
|
+
from webcompy_cli._pyodide_lock import PYODIDE_RUNTIME_URL_TEMPLATE
|
|
339
|
+
from webcompy_cli._runtime_downloader import PYSCRIPT_OFFLINE_URL_TEMPLATE, RuntimeDownloadError
|
|
340
|
+
|
|
341
|
+
expected_hashes: dict[str, str] = {}
|
|
342
|
+
if lockfile.runtime_assets:
|
|
343
|
+
for asset_key, entry in lockfile.runtime_assets.items():
|
|
344
|
+
if entry.sha256 is not None:
|
|
345
|
+
expected_hashes[asset_key] = entry.sha256
|
|
346
|
+
for rel_path, (_asset_path, computed_sha256) in runtime_asset_results.items():
|
|
347
|
+
filename = rel_path.rsplit("/", 1)[-1]
|
|
348
|
+
if filename in expected_hashes and computed_sha256 != expected_hashes[filename]:
|
|
349
|
+
raise RuntimeDownloadError(
|
|
350
|
+
f"SHA256 mismatch for runtime asset {filename}. "
|
|
351
|
+
f"Expected: {expected_hashes[filename]}, got: {computed_sha256}."
|
|
352
|
+
)
|
|
353
|
+
lockfile.runtime_assets = {}
|
|
354
|
+
for rel_path, (_asset_path, computed_sha256) in runtime_asset_results.items():
|
|
355
|
+
filename = rel_path.rsplit("/", 1)[-1]
|
|
356
|
+
if rel_path.startswith("pyodide/"):
|
|
357
|
+
url = PYODIDE_RUNTIME_URL_TEMPLATE.format(pyodide_version=lockfile.pyodide_version, filename=filename)
|
|
358
|
+
else:
|
|
359
|
+
url = PYSCRIPT_OFFLINE_URL_TEMPLATE.format(pyscript_version=pyscript_version)
|
|
360
|
+
lockfile.runtime_assets[filename] = RuntimeAssetEntry(url=url, sha256=computed_sha256)
|
|
361
|
+
save_lockfile(lockfile, lockfile_path)
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
def resolve_lockfile(
|
|
365
|
+
dependencies: list[str],
|
|
366
|
+
pyscript_version: str,
|
|
367
|
+
lockfile_path: pathlib.Path,
|
|
368
|
+
modules_dir: pathlib.Path,
|
|
369
|
+
wasm_serving: str = "cdn",
|
|
370
|
+
runtime_serving: str = "cdn",
|
|
371
|
+
standalone: bool = False,
|
|
372
|
+
) -> tuple[Lockfile | None, list[str], list[str]]:
|
|
373
|
+
existing = load_lockfile(lockfile_path)
|
|
374
|
+
if existing is not None:
|
|
375
|
+
expected_pyodide_version = get_pyodide_version(pyscript_version)
|
|
376
|
+
version_matches = (
|
|
377
|
+
existing.pyscript_version == pyscript_version and existing.pyodide_version == expected_pyodide_version
|
|
378
|
+
)
|
|
379
|
+
issues = validate_lockfile(existing, dependencies)
|
|
380
|
+
if version_matches and not issues:
|
|
381
|
+
return existing, [], []
|
|
382
|
+
try:
|
|
383
|
+
lockfile, errors, warnings = generate_lockfile(
|
|
384
|
+
dependencies,
|
|
385
|
+
pyscript_version,
|
|
386
|
+
modules_dir,
|
|
387
|
+
wasm_serving=wasm_serving,
|
|
388
|
+
runtime_serving=runtime_serving,
|
|
389
|
+
standalone=standalone,
|
|
390
|
+
)
|
|
391
|
+
except PyodideLockFetchError as e:
|
|
392
|
+
if existing is not None:
|
|
393
|
+
return existing, [str(e)], []
|
|
394
|
+
return None, [str(e)], []
|
|
395
|
+
save_lockfile(lockfile, lockfile_path)
|
|
396
|
+
return lockfile, errors, warnings
|