@pylair/cli 0.0.0-stage → 0.1.0-rc.10
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.
- package/LICENSE-APACHE +202 -0
- package/LICENSE-MIT +21 -0
- package/README.md +24 -2
- package/dist/build.d.ts +22 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +411 -0
- package/dist/build.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +150 -0
- package/dist/cli.js.map +1 -0
- package/dist/codegen.d.ts +39 -0
- package/dist/codegen.d.ts.map +1 -0
- package/dist/codegen.js +159 -0
- package/dist/codegen.js.map +1 -0
- package/dist/config.d.ts +41 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +75 -0
- package/dist/config.js.map +1 -0
- package/dist/dev.d.ts +10 -0
- package/dist/dev.d.ts.map +1 -0
- package/dist/dev.js +109 -0
- package/dist/dev.js.map +1 -0
- package/dist/doctor.d.ts +3 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +75 -0
- package/dist/doctor.js.map +1 -0
- package/dist/glob.d.ts +5 -0
- package/dist/glob.d.ts.map +1 -0
- package/dist/glob.js +36 -0
- package/dist/glob.js.map +1 -0
- package/dist/manifest.d.ts +14 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +37 -0
- package/dist/manifest.js.map +1 -0
- package/dist/prune.d.ts +16 -0
- package/dist/prune.d.ts.map +1 -0
- package/dist/prune.js +69 -0
- package/dist/prune.js.map +1 -0
- package/package.json +35 -4
package/dist/build.js
ADDED
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
/** `pylair build` — the M0 recipe, generalized:
|
|
2
|
+
* fetch standalone CPython → stage site-packages via the bundled
|
|
3
|
+
* interpreter (native wheels only — no cross-compile) → stage app
|
|
4
|
+
* source → prune → tauri build → unsigned warning.
|
|
5
|
+
*/
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
7
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
8
|
+
import { closeSync, cpSync, createWriteStream, existsSync, mkdirSync, mkdtempSync, openSync, readdirSync, readFileSync, readSync, rmSync, writeFileSync, } from "node:fs";
|
|
9
|
+
import { get } from "node:https";
|
|
10
|
+
import { arch, platform, tmpdir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
13
|
+
import { importRoot, loadConfig, loadTauriConfig, tauriCliEntry } from "./config.js";
|
|
14
|
+
import { DEFAULT_PRUNE, prune } from "./prune.js";
|
|
15
|
+
import { x as untar } from "tar";
|
|
16
|
+
const PBS_TAG = "20251120";
|
|
17
|
+
const PBS_VERSIONS = { "3.12": "3.12.12", "3.13": "3.13.9" };
|
|
18
|
+
const HOST_TRIPLES = {
|
|
19
|
+
"darwin:arm64": "aarch64-apple-darwin",
|
|
20
|
+
"darwin:x64": "x86_64-apple-darwin",
|
|
21
|
+
"win32:x64": "x86_64-pc-windows-msvc",
|
|
22
|
+
"linux:x64": "x86_64-unknown-linux-gnu",
|
|
23
|
+
"linux:arm64": "aarch64-unknown-linux-gnu",
|
|
24
|
+
};
|
|
25
|
+
const isWin = platform() === "win32";
|
|
26
|
+
/** Expected SHA256 per asset, committed in-repo — a hash fetched from the
|
|
27
|
+
* same release as the tarball catches corruption but not a tampered
|
|
28
|
+
* release. Bump together with PBS_TAG/PBS_VERSIONS; verify each value
|
|
29
|
+
* against upstream SHA256SUMS before committing.
|
|
30
|
+
*/
|
|
31
|
+
const PBS_SHA256 = {
|
|
32
|
+
"3.12.12-aarch64-apple-darwin": "9955ac87eff0d561e64920dc46fd8625912d2c2be4a53c66ad80125d6d9fbdb7",
|
|
33
|
+
"3.12.12-aarch64-unknown-linux-gnu": "4c4594cb38ddf6769f11f86818a4c6617652f4994e5a962eb4f8cf0ec977a1be",
|
|
34
|
+
"3.12.12-x86_64-apple-darwin": "1b4d8eec597ff69a3b67946f30622a6c25c6612e6d15aa431b864ebff66ac8a1",
|
|
35
|
+
"3.12.12-x86_64-pc-windows-msvc": "70ecfaf0bfc58298db11d6389be92c29ec4ef8cd93ebb6a7e54b41d9fc056b10",
|
|
36
|
+
"3.12.12-x86_64-unknown-linux-gnu": "8d2cd1393c1aec9d701cebeccb83d1519951f71d3ecb42d5e70c70af4db9be34",
|
|
37
|
+
"3.13.9-aarch64-apple-darwin": "29d38bd5fbe267b37cecac990015c662796edcf51c2f5e321d59ec06a1850816",
|
|
38
|
+
"3.13.9-aarch64-unknown-linux-gnu": "fdc5d80488b64fcef3b99f297618f68e5374c13d89e888a66abeff4967afd308",
|
|
39
|
+
"3.13.9-x86_64-apple-darwin": "9da51afb00480a8ccd4909bd302c80d9c104d633c5e865cf37dd5e587185e125",
|
|
40
|
+
"3.13.9-x86_64-pc-windows-msvc": "f4c22b31ddbf8d7824cbcba2d8707621c2c8fab1fb6d2c1810c2bb0304d8e9a8",
|
|
41
|
+
"3.13.9-x86_64-unknown-linux-gnu": "1bc9a94ab2425fb6ae58e45f69cab61647759b57895649701390822d976fa923",
|
|
42
|
+
};
|
|
43
|
+
export function hostTriple() {
|
|
44
|
+
const t = HOST_TRIPLES[`${platform()}:${arch()}`];
|
|
45
|
+
if (!t)
|
|
46
|
+
throw new Error(`no standalone CPython build for ${platform()}/${arch()}`);
|
|
47
|
+
return t;
|
|
48
|
+
}
|
|
49
|
+
function download(url, to) {
|
|
50
|
+
return new Promise((res, rej) => {
|
|
51
|
+
const follow = (u) => get(u, (r) => {
|
|
52
|
+
if (r.statusCode >= 300 && r.statusCode < 400 && r.headers.location)
|
|
53
|
+
return follow(r.headers.location);
|
|
54
|
+
if (r.statusCode !== 200)
|
|
55
|
+
return rej(new Error(`GET ${u} -> ${r.statusCode}`));
|
|
56
|
+
const out = createWriteStream(to);
|
|
57
|
+
r.pipe(out);
|
|
58
|
+
out.on("finish", () => out.close(() => res()));
|
|
59
|
+
out.on("error", rej);
|
|
60
|
+
}).on("error", rej);
|
|
61
|
+
follow(url);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async function fetchPython(resources, cacheDir, versionClass) {
|
|
65
|
+
const ver = PBS_VERSIONS[versionClass];
|
|
66
|
+
if (!ver)
|
|
67
|
+
throw new Error(`python-version "${versionClass}" not available — supported: ${Object.keys(PBS_VERSIONS).join(", ")}`);
|
|
68
|
+
const triple = hostTriple();
|
|
69
|
+
const asset = `cpython-${ver}+${PBS_TAG}-${triple}-install_only_stripped.tar.gz`;
|
|
70
|
+
const base = `https://github.com/astral-sh/python-build-standalone/releases/download/${PBS_TAG}`;
|
|
71
|
+
mkdirSync(resources, { recursive: true });
|
|
72
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
73
|
+
const tarball = join(cacheDir, asset);
|
|
74
|
+
if (!existsSync(tarball)) {
|
|
75
|
+
console.log(`fetching ${asset}`);
|
|
76
|
+
await download(`${base}/${asset}`, tarball);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
console.log(`using cached ${asset}`);
|
|
80
|
+
}
|
|
81
|
+
// The interpreter ships to end users — verify against hashes committed
|
|
82
|
+
// in-repo (see PBS_SHA256), not a checksum file from the same release.
|
|
83
|
+
const want = PBS_SHA256[`${ver}-${triple}`];
|
|
84
|
+
if (!want)
|
|
85
|
+
throw new Error(`no committed SHA256 for ${ver}/${triple}`);
|
|
86
|
+
const got = createHash("sha256").update(readFileSync(tarball)).digest("hex");
|
|
87
|
+
if (got !== want)
|
|
88
|
+
throw new Error(`SHA256 mismatch for ${asset}: got ${got}, want ${want} — refusing to bundle`);
|
|
89
|
+
const dest = join(resources, "python");
|
|
90
|
+
rmSync(dest, { recursive: true, force: true });
|
|
91
|
+
mkdirSync(dest, { recursive: true });
|
|
92
|
+
// Extract in-process — same lesson as the tomllib probe: whichever
|
|
93
|
+
// `tar` PATH resolves to can differ (System32 bsdtar vs Git Bash GNU
|
|
94
|
+
// tar, which dies on drive-letter paths). The `tar` package handles
|
|
95
|
+
// pax long names (>100 chars) and the bin/python3 -> python3.12
|
|
96
|
+
// symlinks the POSIX builds carry.
|
|
97
|
+
await untar({ file: tarball, cwd: dest, strip: 1 });
|
|
98
|
+
const py = join(dest, isWin ? "python.exe" : "bin/python3");
|
|
99
|
+
if (!existsSync(py))
|
|
100
|
+
throw new Error(`expected interpreter at ${py}`);
|
|
101
|
+
return py;
|
|
102
|
+
}
|
|
103
|
+
function stageEnv(resources, python, appDir, reqs, cacheDir) {
|
|
104
|
+
const target = join(resources, "site-packages");
|
|
105
|
+
rmSync(target, { recursive: true, force: true });
|
|
106
|
+
// dev uses `uv sync` (uv.lock) — build must install the SAME locked set,
|
|
107
|
+
// hashed, or dev/prod parity is a fiction. requirements.txt is the
|
|
108
|
+
// fallback for projects that don't lock.
|
|
109
|
+
const lock = join(appDir, "uv.lock");
|
|
110
|
+
let reqsFile = reqs;
|
|
111
|
+
let exported;
|
|
112
|
+
if (existsSync(lock)) {
|
|
113
|
+
exported = join(cacheDir, "requirements.exported.txt");
|
|
114
|
+
execFileSync("uv", ["export", "--frozen", "--format", "requirements-txt", "-o", exported], { cwd: appDir, stdio: "inherit" });
|
|
115
|
+
reqsFile = exported;
|
|
116
|
+
}
|
|
117
|
+
else if (!existsSync(reqs)) {
|
|
118
|
+
console.log(`no uv.lock and no ${reqs} — bundling stdlib only`);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
console.warn("warning: no uv.lock — building from requirements.txt; " +
|
|
123
|
+
"the bundled env may drift from `pylair dev`'s env");
|
|
124
|
+
}
|
|
125
|
+
execFileSync("uv", ["pip", "install", "--python", python, "--target", target, "-r", reqsFile], { cwd: appDir, stdio: "inherit" });
|
|
126
|
+
}
|
|
127
|
+
function run(cmd, args, cwd) {
|
|
128
|
+
const r = spawnSync(cmd, args, { cwd, stdio: "inherit" });
|
|
129
|
+
if (r.error)
|
|
130
|
+
throw new Error(`${cmd} ${args.join(" ")} failed to start: ${r.error.message}`);
|
|
131
|
+
if (r.status !== 0)
|
|
132
|
+
throw new Error(`${cmd} ${args.join(" ")} exited ${r.status}`);
|
|
133
|
+
}
|
|
134
|
+
// ── macOS ad-hoc signing ──────────────────────────────────────────────
|
|
135
|
+
// Mach-O magic numbers, read as the first BE u32 — includes the
|
|
136
|
+
// byte-swapped forms and both fat headers.
|
|
137
|
+
const MACHO_MAGIC = new Set([
|
|
138
|
+
0xfeedface, 0xfeedfacf, 0xcefaedfe, 0xcffaedfe,
|
|
139
|
+
0xcafebabe, 0xbebafeca, 0xcafebabf, 0xbfbafeca,
|
|
140
|
+
]);
|
|
141
|
+
function isMachO(p) {
|
|
142
|
+
const fd = openSync(p, "r");
|
|
143
|
+
try {
|
|
144
|
+
const b = Buffer.alloc(4);
|
|
145
|
+
return readSync(fd, b, 0, 4, 0) === 4 && MACHO_MAGIC.has(b.readUInt32BE(0));
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
closeSync(fd);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/** Re-sign a built .app ad-hoc and REQUIRE it to verify. With no signing
|
|
152
|
+
* identity Tauri ships only the linker's ad-hoc stub on the main binary —
|
|
153
|
+
* a signature that doesn't cover the bundle is the worst state for
|
|
154
|
+
* Gatekeeper ("is damaged"), worse than none at all. Signs every Mach-O
|
|
155
|
+
* nested-first rather than `codesign --deep`, which is documented to miss
|
|
156
|
+
* binaries in layouts it doesn't model — a vendored CPython tree is
|
|
157
|
+
* exactly that. Verify with --deep --strict; if it fails, the build
|
|
158
|
+
* fails — a broken signature must not ship silently.
|
|
159
|
+
*/
|
|
160
|
+
function codesignVerify(path) {
|
|
161
|
+
const v = spawnSync("codesign", ["--verify", "--deep", "--strict", path], {
|
|
162
|
+
encoding: "utf-8",
|
|
163
|
+
});
|
|
164
|
+
return v.status === 0 ? null : (v.stderr ?? "").trim();
|
|
165
|
+
}
|
|
166
|
+
function adHocSign(tauriDir, productName) {
|
|
167
|
+
const bundleDir = join(tauriDir, "target", "release", "bundle", "macos");
|
|
168
|
+
if (!existsSync(bundleDir))
|
|
169
|
+
return; // --bundles skipped app — nothing to sign
|
|
170
|
+
const app = readdirSync(bundleDir).find((n) => n.endsWith(".app"));
|
|
171
|
+
if (!app)
|
|
172
|
+
return;
|
|
173
|
+
const appPath = join(bundleDir, app);
|
|
174
|
+
const machos = [];
|
|
175
|
+
const walk = (dir) => {
|
|
176
|
+
for (const e of readdirSync(dir, { withFileTypes: true })) {
|
|
177
|
+
const p = join(dir, e.name);
|
|
178
|
+
// Dirent types describe the link, not the target — symlinked files
|
|
179
|
+
// and dirs are skipped; the real binary is signed in place.
|
|
180
|
+
if (e.isDirectory())
|
|
181
|
+
walk(p);
|
|
182
|
+
else if (e.isFile() && isMachO(p))
|
|
183
|
+
machos.push(p);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
walk(appPath);
|
|
187
|
+
// Deepest first — a parent's signature seals its children, so children
|
|
188
|
+
// must be final when the parent is written.
|
|
189
|
+
machos.sort((a, b) => b.split("/").length - a.split("/").length);
|
|
190
|
+
for (const p of machos)
|
|
191
|
+
run("codesign", ["--force", "--sign", "-", p], appPath);
|
|
192
|
+
run("codesign", ["--force", "--sign", "-", appPath], bundleDir);
|
|
193
|
+
const err = codesignVerify(appPath);
|
|
194
|
+
if (err)
|
|
195
|
+
throw new Error(`ad-hoc signing produced an invalid bundle:\n${err}`);
|
|
196
|
+
console.log(`ad-hoc signed ${app} — ${machos.length} nested binaries, codesign --verify clean`);
|
|
197
|
+
// A dmg built in the same `tauri build` already captured the
|
|
198
|
+
// PRE-signing .app — signing after bundling can't reach inside a
|
|
199
|
+
// compressed image. Repackage each dmg from the signed app and verify
|
|
200
|
+
// the shipped artifact itself, not just the staged copy. The rebuilt
|
|
201
|
+
// image is plain (app + /Applications link) — Tauri's cosmetic layout
|
|
202
|
+
// returns once real signing is configured and repackaging stops.
|
|
203
|
+
const dmgDir = join(tauriDir, "target", "release", "bundle", "dmg");
|
|
204
|
+
if (!existsSync(dmgDir))
|
|
205
|
+
return;
|
|
206
|
+
for (const dmg of readdirSync(dmgDir).filter((n) => n.endsWith(".dmg"))) {
|
|
207
|
+
const dmgPath = join(dmgDir, dmg);
|
|
208
|
+
const staging = mkdtempSync(join(tmpdir(), "pylair-dmg-"));
|
|
209
|
+
try {
|
|
210
|
+
run("ditto", [appPath, join(staging, app)], tauriDir);
|
|
211
|
+
run("ln", ["-s", "/Applications", join(staging, "Applications")], tauriDir);
|
|
212
|
+
run("hdiutil", ["create", "-volname", productName, "-srcfolder", staging, "-ov", "-format", "UDZO", dmgPath], tauriDir);
|
|
213
|
+
}
|
|
214
|
+
finally {
|
|
215
|
+
rmSync(staging, { recursive: true, force: true });
|
|
216
|
+
}
|
|
217
|
+
// Verify the app INSIDE the shipped dmg — mount read-only at a fixed
|
|
218
|
+
// point, verify, always detach, then judge.
|
|
219
|
+
const mount = mkdtempSync(join(tmpdir(), "pylair-mnt-"));
|
|
220
|
+
run("hdiutil", ["attach", "-nobrowse", "-readonly", "-mountpoint", mount, dmgPath], tauriDir);
|
|
221
|
+
let inDmg = null;
|
|
222
|
+
try {
|
|
223
|
+
inDmg = codesignVerify(join(mount, app));
|
|
224
|
+
}
|
|
225
|
+
finally {
|
|
226
|
+
spawnSync("hdiutil", ["detach", mount, "-quiet"], { stdio: "inherit" });
|
|
227
|
+
rmSync(mount, { recursive: true, force: true });
|
|
228
|
+
}
|
|
229
|
+
if (inDmg)
|
|
230
|
+
throw new Error(`${dmg} contains an invalidly-signed app:\n${inDmg}`);
|
|
231
|
+
console.log(`repackaged ${dmg} with the signed app — verified inside the image`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/** Shipped bundles must carry the licenses of what they embed. Collects:
|
|
235
|
+
* pylair's own dual license, the interpreter's license tree (PSF license
|
|
236
|
+
* requires LICENSE text with redistributed CPython), and each wheel's
|
|
237
|
+
* dist-info license files. Runs before prune so nothing collected is
|
|
238
|
+
* deleted afterwards. Returns the notice dir.
|
|
239
|
+
*/
|
|
240
|
+
export function stageNotices(resources, pylairDir) {
|
|
241
|
+
const out = join(resources, "THIRD-PARTY-NOTICES");
|
|
242
|
+
rmSync(out, { recursive: true, force: true });
|
|
243
|
+
mkdirSync(out, { recursive: true });
|
|
244
|
+
const index = [];
|
|
245
|
+
const copyInto = (subdir, src, dest) => {
|
|
246
|
+
mkdirSync(join(out, subdir), { recursive: true });
|
|
247
|
+
cpSync(src, join(out, subdir, dest));
|
|
248
|
+
};
|
|
249
|
+
const LICENSEISH = /^(licen[cs]e|copying|notice|authors|copyright)/i;
|
|
250
|
+
for (const f of ["LICENSE-MIT", "LICENSE-APACHE"]) {
|
|
251
|
+
const src = join(pylairDir, f);
|
|
252
|
+
if (existsSync(src))
|
|
253
|
+
copyInto("pylair", src, f);
|
|
254
|
+
}
|
|
255
|
+
index.push("pylair/ — pylair itself (MIT OR Apache-2.0)");
|
|
256
|
+
// The interpreter: python-build-standalone ships a licenses/ dir holding
|
|
257
|
+
// CPython's license plus every statically-linked dep (OpenSSL, libffi…).
|
|
258
|
+
const pyRoot = join(resources, "python");
|
|
259
|
+
let found = 0;
|
|
260
|
+
const walkPy = (dir) => {
|
|
261
|
+
for (const e of readdirSync(dir, { withFileTypes: true })) {
|
|
262
|
+
const p = join(dir, e.name);
|
|
263
|
+
if (e.isDirectory()) {
|
|
264
|
+
if (e.name.toLowerCase() === "licenses") {
|
|
265
|
+
cpSync(p, join(out, "python", "licenses"), { recursive: true });
|
|
266
|
+
found++;
|
|
267
|
+
}
|
|
268
|
+
else
|
|
269
|
+
walkPy(p);
|
|
270
|
+
}
|
|
271
|
+
else if (LICENSEISH.test(e.name)) {
|
|
272
|
+
copyInto("python", p, e.name);
|
|
273
|
+
found++;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
if (existsSync(pyRoot))
|
|
278
|
+
walkPy(pyRoot);
|
|
279
|
+
if (!found) {
|
|
280
|
+
mkdirSync(join(out, "python"), { recursive: true });
|
|
281
|
+
writeFileSync(join(out, "python", "NOTICE.txt"), "This app bundles CPython (PSF-2.0 license) via python-build-standalone.\n" +
|
|
282
|
+
"License texts were not located in the interpreter tree at build time;\n" +
|
|
283
|
+
"they ship upstream in the python/licenses directory of each\n" +
|
|
284
|
+
"python-build-standalone release.\n");
|
|
285
|
+
console.warn("warning: no license files found under resources/python — wrote placeholder NOTICE");
|
|
286
|
+
}
|
|
287
|
+
index.push("python/ — bundled CPython interpreter (PSF-2.0) and its vendored deps");
|
|
288
|
+
// Wheels: every installed dist-info/egg-info carries license files or
|
|
289
|
+
// license metadata. Copy whichever exists.
|
|
290
|
+
const sp = join(resources, "site-packages");
|
|
291
|
+
let wheels = 0;
|
|
292
|
+
if (existsSync(sp)) {
|
|
293
|
+
for (const e of readdirSync(sp, { withFileTypes: true })) {
|
|
294
|
+
if (!e.isDirectory())
|
|
295
|
+
continue;
|
|
296
|
+
const m = /^(.*?)-[\d.]+.*\.(dist-info|egg-info)$/.exec(e.name);
|
|
297
|
+
if (!m)
|
|
298
|
+
continue;
|
|
299
|
+
const pkg = m[1].replace(/[^\w.-]/g, "_");
|
|
300
|
+
const d = join(sp, e.name);
|
|
301
|
+
let kept = false;
|
|
302
|
+
for (const f of readdirSync(d, { withFileTypes: true })) {
|
|
303
|
+
if (f.isDirectory() && f.name.toLowerCase() === "licenses") {
|
|
304
|
+
cpSync(join(d, f.name), join(out, pkg, "licenses"), { recursive: true });
|
|
305
|
+
kept = true;
|
|
306
|
+
}
|
|
307
|
+
else if (f.isFile() && LICENSEISH.test(f.name)) {
|
|
308
|
+
copyInto(pkg, join(d, f.name), f.name);
|
|
309
|
+
kept = true;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
const meta = join(d, "METADATA");
|
|
313
|
+
if (existsSync(meta)) {
|
|
314
|
+
const lines = readFileSync(meta, "utf-8")
|
|
315
|
+
.split("\n")
|
|
316
|
+
.filter((l) => /^(License|Classifier: License)/i.test(l));
|
|
317
|
+
// Copyleft is legal to ship but app authors deserve to know they
|
|
318
|
+
// bundled it — warn, never block.
|
|
319
|
+
if (/\b(a?lgpl|gpl)[ -]?v?\d/i.test(lines.join(" ")))
|
|
320
|
+
console.warn(`warning: bundled wheel ${e.name} declares a copyleft license`);
|
|
321
|
+
if (lines.length) {
|
|
322
|
+
mkdirSync(join(out, pkg), { recursive: true });
|
|
323
|
+
writeFileSync(join(out, pkg, "METADATA-LICENSE.txt"), lines.join("\n") + "\n");
|
|
324
|
+
kept = true;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (kept) {
|
|
328
|
+
wheels++;
|
|
329
|
+
index.push(`${pkg}/ — from ${e.name}`);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
writeFileSync(join(out, "INDEX.txt"), index.join("\n") + "\n");
|
|
334
|
+
console.log(`third-party notices: pylair, python interpreter, ${wheels} wheel(s)`);
|
|
335
|
+
return out;
|
|
336
|
+
}
|
|
337
|
+
export async function build(opts) {
|
|
338
|
+
const { appDir } = opts;
|
|
339
|
+
const tauriDir = join(appDir, "src-tauri");
|
|
340
|
+
const resources = join(tauriDir, "resources");
|
|
341
|
+
const tconf = loadTauriConfig(appDir);
|
|
342
|
+
const cfg = loadConfig(appDir);
|
|
343
|
+
const targetTriple = hostTriple(); // cross-compile refused by construction
|
|
344
|
+
console.log(`building ${tconf.productName} ${tconf.version} for ${platform()}/${arch()} (${targetTriple})`);
|
|
345
|
+
console.log("note: pylair builds native bundles only — run this on each target OS");
|
|
346
|
+
const cacheDir = join(appDir, ".pylair", "cache");
|
|
347
|
+
const bundled = opts.skipFetch
|
|
348
|
+
? join(resources, "python", isWin ? "python.exe" : "bin/python3")
|
|
349
|
+
: await fetchPython(resources, cacheDir, cfg.pythonVersion);
|
|
350
|
+
stageEnv(resources, bundled, appDir, join(appDir, cfg.requirements), cacheDir);
|
|
351
|
+
// Licenses ship with the bundle — collect before prune can remove sources.
|
|
352
|
+
stageNotices(resources, fileURLToPath(new URL("..", import.meta.url)));
|
|
353
|
+
// Stage app source so resources/ mirrors the installed layout.
|
|
354
|
+
const srcDir = join(appDir, cfg.source);
|
|
355
|
+
if (!existsSync(srcDir))
|
|
356
|
+
throw new Error(`source dir ${srcDir} missing`);
|
|
357
|
+
rmSync(join(resources, cfg.source), { recursive: true, force: true });
|
|
358
|
+
cpSync(srcDir, join(resources, cfg.source), { recursive: true });
|
|
359
|
+
const res = prune(resources, [...DEFAULT_PRUNE, ...cfg.prune]);
|
|
360
|
+
const mib = (res.bytesFreed / 2 ** 20).toFixed(1);
|
|
361
|
+
console.log(`pruned ${res.removed} paths (${mib} MiB) from staged resources`);
|
|
362
|
+
// Over-pruning must fail at build time, not on the user's machine:
|
|
363
|
+
// import the app module with the staged tree exactly as the bundle sees it.
|
|
364
|
+
const sep = isWin ? ";" : ":";
|
|
365
|
+
// The import root is the PARENT of the staged source dir ("backend.app"
|
|
366
|
+
// resolves from resources/, not resources/backend/). Run from an unrelated
|
|
367
|
+
// cwd so the project checkout can't satisfy the import by accident.
|
|
368
|
+
const check = spawnSync(bundled, ["-c", `import ${cfg.appModule}; print("staged import ok")`], {
|
|
369
|
+
encoding: "utf-8",
|
|
370
|
+
cwd: tmpdir(),
|
|
371
|
+
env: {
|
|
372
|
+
...process.env,
|
|
373
|
+
PYTHONPATH: `${importRoot(resources, cfg.source)}${sep}${join(resources, "site-packages")}`,
|
|
374
|
+
PYTHONNOUSERSITE: "1",
|
|
375
|
+
},
|
|
376
|
+
});
|
|
377
|
+
if (check.status !== 0)
|
|
378
|
+
throw new Error(`staged bundle failed the import check (${cfg.appModule}) — ` +
|
|
379
|
+
`pruning or missing deps? ${check.stderr?.trim()}`);
|
|
380
|
+
// ── tauri build ────────────────────────────────────────────────────
|
|
381
|
+
// Signing is per-platform: only macOS creds (env OR tauri.conf
|
|
382
|
+
// signingIdentity) mean this Mac build gets a real signature — a Windows
|
|
383
|
+
// thumbprint on its own must not suppress the ad-hoc pass.
|
|
384
|
+
// NOTE: TAURI_SIGNING_PRIVATE_KEY signs *updater* artifacts, not the app —
|
|
385
|
+
// it must NOT silence the unsigned warning.
|
|
386
|
+
const appleSigned = !!(process.env.APPLE_SIGNING_IDENTITY ||
|
|
387
|
+
process.env.APPLE_CERTIFICATE ||
|
|
388
|
+
tconf.macSigningIdentity);
|
|
389
|
+
const hasSigning = platform() === "darwin"
|
|
390
|
+
? appleSigned
|
|
391
|
+
: platform() === "win32"
|
|
392
|
+
? !!process.env.WINDOWS_CERTIFICATE_THUMBPRINT
|
|
393
|
+
: true; // no signing concept on Linux — don't warn
|
|
394
|
+
run(process.execPath, [tauriCliEntry(appDir), "build", ...(opts.tauriArgs ?? [])], appDir);
|
|
395
|
+
// Unsigned macOS builds get a full-bundle ad-hoc signature — better
|
|
396
|
+
// than the linker stub Tauri leaves on just the main binary. Skipped
|
|
397
|
+
// entirely when a real identity is configured: ad-hoc must never run
|
|
398
|
+
// over a proper signature.
|
|
399
|
+
if (platform() === "darwin" && !appleSigned)
|
|
400
|
+
adHocSign(tauriDir, tconf.productName);
|
|
401
|
+
if (!hasSigning) {
|
|
402
|
+
console.warn(`
|
|
403
|
+
╔══════════════════════════════════════════════════════════════════╗
|
|
404
|
+
║ UNSIGNED BUILD — this bundle is not code-signed or notarized. ║
|
|
405
|
+
║ macOS Gatekeeper and Windows SmartScreen will warn users. ║
|
|
406
|
+
║ To sign: set APPLE_SIGNING_IDENTITY / TAURI_SIGNING_PRIVATE_KEY / ║
|
|
407
|
+
║ WINDOWS_CERTIFICATE_THUMBPRINT (see docs/build.md). ║
|
|
408
|
+
╚══════════════════════════════════════════════════════════════════╝`);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CA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{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;GAGG"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* pylair CLI. `codegen` is implemented (M2, docs/codegen.md);
|
|
4
|
+
* dev/build/doctor arrive in M4.
|
|
5
|
+
*/
|
|
6
|
+
import { spawnSync } from "node:child_process";
|
|
7
|
+
import { writeFileSync, readFileSync, existsSync } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { build } from "./build.js";
|
|
10
|
+
import { emit } from "./codegen.js";
|
|
11
|
+
import { dev } from "./dev.js";
|
|
12
|
+
import { doctor } from "./doctor.js";
|
|
13
|
+
import { loadManifest } from "./manifest.js";
|
|
14
|
+
const COMMANDS = ["dev", "build", "doctor", "codegen"];
|
|
15
|
+
function usage() {
|
|
16
|
+
console.log(`pylair — Pylair CLI
|
|
17
|
+
|
|
18
|
+
Usage: pylair <command> [options]
|
|
19
|
+
|
|
20
|
+
Commands:
|
|
21
|
+
dev Run the app with supervised Python + hot reload
|
|
22
|
+
build Produce a native installer with bundled Python
|
|
23
|
+
doctor Diagnose environment and app config
|
|
24
|
+
codegen Generate typed TypeScript stubs from @expose signatures
|
|
25
|
+
|
|
26
|
+
codegen options:
|
|
27
|
+
--module, -m <name> Python module exposing @expose functions (required)
|
|
28
|
+
--out, -o <file> Output file (default: src/api.generated.ts)
|
|
29
|
+
--python <path> Interpreter to inspect the module
|
|
30
|
+
(default: $PYTHON, then python3)
|
|
31
|
+
--check Exit 1 if the output is stale; don't write
|
|
32
|
+
|
|
33
|
+
build options:
|
|
34
|
+
--dir <path> App directory (default: cwd)
|
|
35
|
+
--bundles <list> Comma-separated bundle kinds passed to tauri build
|
|
36
|
+
--skip-fetch Reuse already-staged resources/python
|
|
37
|
+
Any other flags are forwarded to tauri build.
|
|
38
|
+
|
|
39
|
+
Builds are native-only: run on each target OS (no cross-compile).
|
|
40
|
+
Unsigned by default — set signing env vars for distribution builds.
|
|
41
|
+
`);
|
|
42
|
+
}
|
|
43
|
+
function argValue(argv, ...flags) {
|
|
44
|
+
for (const f of flags) {
|
|
45
|
+
const i = argv.indexOf(f);
|
|
46
|
+
if (i !== -1)
|
|
47
|
+
return argv[i + 1];
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
function findPython() {
|
|
52
|
+
if (process.env.PYTHON)
|
|
53
|
+
return process.env.PYTHON;
|
|
54
|
+
// Prefer the app venv (uv sync guarantees >=3.12) — system python3 may
|
|
55
|
+
// be older than tomllib needs, or absent entirely on Windows.
|
|
56
|
+
const venv = join(process.cwd(), ".venv", process.platform === "win32" ? "Scripts/python.exe" : "bin/python");
|
|
57
|
+
if (existsSync(venv))
|
|
58
|
+
return venv;
|
|
59
|
+
for (const cand of ["python3", "python"]) {
|
|
60
|
+
const res = spawnProbe(cand);
|
|
61
|
+
if (res)
|
|
62
|
+
return cand;
|
|
63
|
+
}
|
|
64
|
+
return "python3"; // loadManifest will produce the friendly ENOENT error
|
|
65
|
+
}
|
|
66
|
+
function spawnProbe(cmd) {
|
|
67
|
+
const { status, error } = spawnSync(cmd, ["-c", "import sys;sys.exit(0)"]);
|
|
68
|
+
return !error && status === 0;
|
|
69
|
+
}
|
|
70
|
+
function codegen(argv) {
|
|
71
|
+
const module = argValue(argv, "--module", "-m");
|
|
72
|
+
if (!module) {
|
|
73
|
+
console.error("pylair codegen: --module is required");
|
|
74
|
+
return 2;
|
|
75
|
+
}
|
|
76
|
+
const out = argValue(argv, "--out", "-o") ?? "src/api.generated.ts";
|
|
77
|
+
const python = argValue(argv, "--python") ?? findPython();
|
|
78
|
+
const check = argv.includes("--check");
|
|
79
|
+
const manifest = loadManifest({ python, module });
|
|
80
|
+
const ts = emit(manifest, module);
|
|
81
|
+
if (check) {
|
|
82
|
+
const stale = !existsSync(out) || readFileSync(out, "utf-8") !== ts;
|
|
83
|
+
if (stale) {
|
|
84
|
+
console.error(`pylair codegen: ${out} is stale — re-run codegen`);
|
|
85
|
+
return 1;
|
|
86
|
+
}
|
|
87
|
+
return 0;
|
|
88
|
+
}
|
|
89
|
+
writeFileSync(out, ts);
|
|
90
|
+
const n = manifest.functions?.length ?? 0;
|
|
91
|
+
console.log(`pylair codegen: wrote ${out} (${n} functions)`);
|
|
92
|
+
return 0;
|
|
93
|
+
}
|
|
94
|
+
function main(argv) {
|
|
95
|
+
const [command, ...rest] = argv;
|
|
96
|
+
if (!command || command === "--help" || command === "-h") {
|
|
97
|
+
usage();
|
|
98
|
+
return command ? 0 : 1;
|
|
99
|
+
}
|
|
100
|
+
if (command === "--version" || command === "-v") {
|
|
101
|
+
console.log("0.0.0");
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
if (command === "codegen") {
|
|
105
|
+
try {
|
|
106
|
+
return codegen(rest);
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
console.error(`pylair codegen: ${e.message}`);
|
|
110
|
+
return 1;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (command === "build") {
|
|
114
|
+
const dir = argValue(rest, "--dir") ?? process.cwd();
|
|
115
|
+
const bundles = argValue(rest, "--bundles");
|
|
116
|
+
const own = new Set(["--dir", "--bundles", "--skip-fetch"]);
|
|
117
|
+
const tauriArgs = [];
|
|
118
|
+
for (let i = 0; i < rest.length; i++) {
|
|
119
|
+
if (own.has(rest[i]))
|
|
120
|
+
i += rest[i] === "--skip-fetch" ? 0 : 1;
|
|
121
|
+
else if (rest[i].startsWith("--"))
|
|
122
|
+
tauriArgs.push(rest[i]);
|
|
123
|
+
}
|
|
124
|
+
if (bundles)
|
|
125
|
+
tauriArgs.push("--bundles", bundles);
|
|
126
|
+
return build({
|
|
127
|
+
appDir: dir,
|
|
128
|
+
tauriArgs,
|
|
129
|
+
skipFetch: rest.includes("--skip-fetch"),
|
|
130
|
+
}).then(() => 0, (e) => {
|
|
131
|
+
console.error(`pylair build: ${e.message}`);
|
|
132
|
+
return 1;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
if (command === "dev") {
|
|
136
|
+
const dir = argValue(rest, "--dir") ?? process.cwd();
|
|
137
|
+
return dev({ appDir: dir }).then((code) => code, (e) => {
|
|
138
|
+
console.error(`pylair dev: ${e.message}`);
|
|
139
|
+
return 1;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
if (command === "doctor") {
|
|
143
|
+
const dir = argValue(rest, "--dir") ?? process.cwd();
|
|
144
|
+
return doctor(dir).then((code) => code);
|
|
145
|
+
}
|
|
146
|
+
console.error(`pylair: unknown command '${command}'. Run 'pylair --help'.`);
|
|
147
|
+
return 1;
|
|
148
|
+
}
|
|
149
|
+
Promise.resolve(main(process.argv.slice(2))).then(process.exit);
|
|
150
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAC;AAEhE,SAAS,KAAK;IACZ,OAAO,CAAC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O,yBAAyB,CAAC,CAAC;IAC5E,OAAO,CAAC,CAAC;AACX,CAAC;AAED,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type codegen: manifest (python -m pylair.codegen) -> api.generated.ts.
|
|
3
|
+
* Spec: docs/codegen.md.
|
|
4
|
+
*/
|
|
5
|
+
export interface Schema {
|
|
6
|
+
type: string;
|
|
7
|
+
items?: Schema | Schema[];
|
|
8
|
+
opts?: Schema[];
|
|
9
|
+
keys?: Schema;
|
|
10
|
+
/** dict: value schema; literal/enum: raw values */
|
|
11
|
+
values?: Schema | unknown[];
|
|
12
|
+
name?: string;
|
|
13
|
+
fields?: {
|
|
14
|
+
name: string;
|
|
15
|
+
required: boolean;
|
|
16
|
+
schema: Schema;
|
|
17
|
+
}[];
|
|
18
|
+
}
|
|
19
|
+
export interface Param {
|
|
20
|
+
name: string;
|
|
21
|
+
kind: string;
|
|
22
|
+
required: boolean;
|
|
23
|
+
schema: Schema;
|
|
24
|
+
}
|
|
25
|
+
export interface Fn {
|
|
26
|
+
name: string;
|
|
27
|
+
kind: "sync" | "async" | "generator" | "isolated";
|
|
28
|
+
doc: string | null;
|
|
29
|
+
params: Param[];
|
|
30
|
+
returns: Schema;
|
|
31
|
+
}
|
|
32
|
+
export interface Manifest {
|
|
33
|
+
version: number;
|
|
34
|
+
functions?: Fn[];
|
|
35
|
+
error?: string;
|
|
36
|
+
}
|
|
37
|
+
/** Render the manifest as a TypeScript module. */
|
|
38
|
+
export declare function emit(m: Manifest, source: string): string;
|
|
39
|
+
//# sourceMappingURL=codegen.d.ts.map
|