@elaraai/e3 1.0.109 → 1.0.111

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.
@@ -0,0 +1,588 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ /**
6
+ * What an export reads of a uv lock: the governing root of a python project,
7
+ * the packages its environment reaches, the registry distributions installed
8
+ * beside its members, and what the sync of those leaves out. Pure reads of the
9
+ * lock and of the directories it names: nothing is built here
10
+ * (`environment-capture.ts` builds and stores what these name).
11
+ */
12
+ import * as fs from 'node:fs';
13
+ import * as path from 'node:path';
14
+ import { parse as parseToml } from 'smol-toml';
15
+ import { StringType, compareFor } from '@elaraai/east';
16
+ import { STOCK_PLATFORMS_BY_RUNNER } from './runner.js';
17
+ /** Orders the names and paths a lock holds through East, by code point. */
18
+ const byCodePoint = compareFor(StringType);
19
+ /**
20
+ * Reads a lock's text.
21
+ *
22
+ * @throws {Error} When the lock is not of the version this reads
23
+ */
24
+ function readUvLock(lockText) {
25
+ const lock = parseToml(lockText);
26
+ if (lock.version !== 1)
27
+ throw new Error(`unsupported uv.lock version ${String(lock.version)}`);
28
+ return lock;
29
+ }
30
+ /** Canonicalize a path for identity comparison — realpath when it exists,
31
+ * case-folded on win32 (uv.lock stores portable forward-slash relatives).
32
+ * @internal */
33
+ export function canonicalPath(p) {
34
+ let r = p;
35
+ try {
36
+ r = fs.realpathSync(p);
37
+ }
38
+ catch { /* may not exist yet */ }
39
+ return process.platform === 'win32' ? r.toLowerCase() : r;
40
+ }
41
+ /**
42
+ * A python distribution's name as PEP 503 writes it: lowercase, runs of `-`,
43
+ * `_` and `.` as one `-`.
44
+ *
45
+ * @remarks
46
+ * uv.lock stores canonical names while a `{ custom }` platform ref uses the
47
+ * import-style name (`platform_module`), so both sides must canonicalize
48
+ * before comparison (#391 — a strict match silently derived NO environment for
49
+ * any underscore-named member, leaving its source edits out of the task hash
50
+ * and serving stale cached outputs). e3-core names a tier's distributions by
51
+ * it too, and the image's script that writes a tier's manifest
52
+ * (`tier/tier-manifest.py` in `@elaraai/e3-core`) writes the same rule in
53
+ * python: a name both sides spell otherwise is no longer told to be the
54
+ * tier's.
55
+ *
56
+ * @param name - The name, as a lock, a manifest or a directory spells it
57
+ * @returns The canonical name
58
+ * @example
59
+ * canonicalPythonName('Typing_Extensions'); // 'typing-extensions'
60
+ */
61
+ export function canonicalPythonName(name) {
62
+ return name.toLowerCase().replace(/[-_.]+/g, '-');
63
+ }
64
+ /** The sources a lock holds a workspace's own packages from: a member, the
65
+ * root, and a directory one of them names. */
66
+ const OWN_SOURCE_KINDS = ['editable', 'directory', 'virtual'];
67
+ /** The kind of source a lock holds one of a workspace's own packages from, or
68
+ * null for any other package's source. */
69
+ function ownSourceKind(source) {
70
+ return OWN_SOURCE_KINDS.find((kind) => typeof source?.[kind] === 'string') ?? null;
71
+ }
72
+ /**
73
+ * Whether a lock holds a package as one of its workspace's own: a member, the
74
+ * root, or a directory one of them names. An install takes every other
75
+ * package from an index, a repository, a URL or a local archive.
76
+ *
77
+ * @internal
78
+ * @param pkg - The package, as the lock holds it
79
+ * @returns Whether it is the workspace's own
80
+ */
81
+ export function ownPackage(pkg) {
82
+ return ownSourceKind(pkg.source) !== null;
83
+ }
84
+ /** The on-disk directory a lock `source` points at, with its kind — or null
85
+ * for registry/git/url sources (installed by uv sync, not captured), and for
86
+ * a local archive (`path`), which no environment takes.
87
+ * @internal */
88
+ export function localSource(root, source) {
89
+ const kind = ownSourceKind(source);
90
+ const dir = kind === null ? undefined : source?.[kind];
91
+ return kind === null || dir === undefined ? null : { dir: path.resolve(root, dir), kind };
92
+ }
93
+ /** The refusal of a package the lock holds as a local archive (`path`), which
94
+ * no environment takes: neither its sdist nor a registry's copy of it. */
95
+ function localArchiveRefused(owner, name) {
96
+ return new Error(`Environment for '${owner}': local archive dependency '${name}' is not supported — use a directory/workspace source or a registry`);
97
+ }
98
+ /**
99
+ * Every package of a lock that `starts` reach by what they depend on, each
100
+ * name once, in the order reached, with each of its entries: a name the lock
101
+ * locks at several versions, one for each platform it forks for, has
102
+ * several.
103
+ *
104
+ * @remarks
105
+ * A package is walked as an install takes it: through its dependencies, and
106
+ * the optional groups of the extras the dependency that reached it asked for;
107
+ * an extra another dependency asks for is walked when that one reaches it. So
108
+ * an extra of a registry package that nothing asks for is never walked, nor
109
+ * what only it names. A package `groups` names development groups of is
110
+ * walked through those too, as a sync of a project that is its own root
111
+ * takes its packages' default groups. A package `whole` says so of is walked
112
+ * through every group it names, its development groups among them, whatever
113
+ * reached it: a workspace's own package, whose walk may over-reach, since
114
+ * over-capture only over-invalidates.
115
+ *
116
+ * A registry package's dependency may be a local package: the lock resolves a
117
+ * name the workspace holds to the workspace's package.
118
+ *
119
+ * @internal
120
+ * @param lock - The lock
121
+ * @param starts - The packages to start from, with their extras
122
+ * @param whole - Whether a package is walked through every group it names;
123
+ * none is unless given
124
+ * @param groups - The development groups a package is walked through beside
125
+ * what an install takes of it, by name, or `'all'` of them; none unless
126
+ * given
127
+ * @returns Each package reached, by its PEP 503 name, with its entries; none
128
+ * for a name the lock does not hold
129
+ * @example
130
+ * for (const { name, packages } of lockWalk(lock, [{ name: 'elaraai-east-py-datascience', extras: ['torch'] }])) needed.add(name);
131
+ */
132
+ export function* lockWalk(lock, starts, whole = () => false, groups = () => []) {
133
+ const byName = new Map();
134
+ for (const pkg of lock.package ?? []) {
135
+ const name = canonicalPythonName(pkg.name);
136
+ byName.set(name, [...(byName.get(name) ?? []), pkg]);
137
+ }
138
+ const reached = new Set();
139
+ // What has been walked: a package's dependencies by its name, and an extra's by `name[extra]`
140
+ const walked = new Set();
141
+ const queue = [...starts];
142
+ while (queue.length > 0) {
143
+ const start = queue.shift();
144
+ const name = canonicalPythonName(start.name);
145
+ const packages = byName.get(name) ?? [];
146
+ if (!reached.has(name)) {
147
+ reached.add(name);
148
+ yield { name, packages };
149
+ }
150
+ const fresh = [...(walked.has(name) ? [] : ['']), ...(start.extras ?? []).filter((extra) => !walked.has(`${name}[${extra}]`))];
151
+ for (const part of fresh)
152
+ walked.add(part === '' ? name : `${name}[${part}]`);
153
+ for (const pkg of packages) {
154
+ const edges = whole(pkg)
155
+ ? (fresh.includes('') ? [...pkg.dependencies ?? [], ...Object.values(pkg['optional-dependencies'] ?? {}).flat(), ...groupDependencies(pkg, 'all')] : [])
156
+ : [...fresh.flatMap((part) => part === '' ? pkg.dependencies ?? [] : pkg['optional-dependencies']?.[part] ?? []),
157
+ ...(fresh.includes('') ? groupDependencies(pkg, groups(pkg)) : [])];
158
+ for (const edge of edges)
159
+ queue.push({ name: edge.name, extras: edge.extra ?? [] });
160
+ }
161
+ }
162
+ }
163
+ /** What a package's development groups depend on: those named, by their
164
+ * names as PEP 735 normalizes them, or all it has. */
165
+ function groupDependencies(pkg, named) {
166
+ const groups = Object.entries(pkg['dev-dependencies'] ?? {});
167
+ const wanted = named === 'all' ? null : new Set(named.map(canonicalPythonName));
168
+ return groups.filter(([group]) => wanted === null || wanted.has(canonicalPythonName(group))).flatMap(([, dependencies]) => dependencies);
169
+ }
170
+ /**
171
+ * Find the workspace/standalone root governing `project` and the lock
172
+ * package (`subject`) whose local source resolves to it.
173
+ *
174
+ * @internal
175
+ * @throws {Error} P3 (no lock in project or any ancestor), P5 (unsupported
176
+ * lock version), P4 (lock does not list a package at `project`)
177
+ */
178
+ export function discoverPythonRoot(project, owner) {
179
+ let dir = project;
180
+ let lockPath = null;
181
+ for (;;) {
182
+ const candidate = path.join(dir, 'uv.lock');
183
+ if (fs.existsSync(candidate)) {
184
+ lockPath = candidate;
185
+ break;
186
+ }
187
+ const parent = path.dirname(dir);
188
+ if (parent === dir)
189
+ break;
190
+ dir = parent;
191
+ }
192
+ if (!lockPath) {
193
+ throw new Error(`Environment for '${owner}': no uv.lock in '${project}' or any parent — run 'uv lock' in ` +
194
+ `'${project}' (standalone), or add it to [tool.uv.workspace].members of the workspace root and 'uv lock' there`);
195
+ }
196
+ const root = path.dirname(lockPath);
197
+ const lock = parseToml(fs.readFileSync(lockPath, 'utf-8'));
198
+ if (lock.version !== 1) {
199
+ throw new Error(`Environment for '${owner}': unsupported uv.lock version ${lock.version} at '${root}' — update @elaraai/e3 or re-lock with a compatible uv`);
200
+ }
201
+ const projectCanon = canonicalPath(project);
202
+ const subject = (lock.package ?? []).find((p) => {
203
+ const local = localSource(root, p.source);
204
+ return local !== null && canonicalPath(local.dir) === projectCanon;
205
+ });
206
+ if (!subject) {
207
+ throw new Error(`Environment for '${owner}': uv.lock at '${root}' does not list a package at '${project}' — ` +
208
+ `the lockfile is out of date or the project is not a workspace member; run 'uv lock' at '${root}'`);
209
+ }
210
+ return { root, lock, subject: subject.name };
211
+ }
212
+ /**
213
+ * The LOCAL packages reachable from an environment's subjects, and from the
214
+ * registry distributions it requires beside them — the set whose sdists must
215
+ * ride the environment.
216
+ *
217
+ * Walks a local package through `dependencies` plus every optional-dependency
218
+ * and dev-dependency group (over-capture is sound: it only over-invalidates),
219
+ * and a registry package as an install takes it: through its dependencies
220
+ * and the extras asked of it ({@link lockWalk}). A registry package is
221
+ * installed from the lock, and a local package it depends on rides as an
222
+ * sdist, as the installs take no local package from a registry. A
223
+ * `path=<archive>` source the walk reaches is refused — never one only an
224
+ * extra nothing asks for names — and a virtual package contributes its deps
225
+ * but no sdist.
226
+ *
227
+ * @internal
228
+ * @param subjects - The members the environment is of, by the lock's names
229
+ * @param required - The registry distributions it requires beside them, with
230
+ * the extras each is installed with
231
+ * @returns The buildable closure members, sorted by name
232
+ * @throws {Error} P6 (dangling edge), P7 (subject not packaged), P8 (source
233
+ * dir missing), P9 (local archive dependency)
234
+ */
235
+ export function pythonClosure(lock, root, subjects, owner, required = []) {
236
+ const build = new Map();
237
+ const own = new Set(subjects.map(canonicalPythonName));
238
+ for (const { name, packages } of lockWalk(lock, [...subjects.map((subject) => ({ name: subject })), ...required], ownPackage)) {
239
+ if (packages.length === 0) {
240
+ if (own.has(name))
241
+ throw new Error(`Environment for '${owner}': subject '${name}' not in uv.lock`);
242
+ throw new Error(`Environment for '${owner}': uv.lock is inconsistent — depends on unknown '${name}'; run 'uv lock'`);
243
+ }
244
+ for (const pkg of packages) {
245
+ if (typeof pkg.source?.path === 'string')
246
+ throw localArchiveRefused(owner, pkg.name);
247
+ const source = localSource(root, pkg.source);
248
+ if (!source)
249
+ continue; // registry/git/url — sync installs it, and what it depends on is walked
250
+ if (source.kind !== 'virtual') {
251
+ if (!fs.existsSync(source.dir)) {
252
+ throw new Error(`Environment for '${owner}': package '${pkg.name}' resolves to '${source.dir}' which does not exist — run 'uv lock' or fix its path`);
253
+ }
254
+ build.set(pkg.name, source.dir);
255
+ }
256
+ else if (own.has(name)) {
257
+ throw new Error(`Environment for '${owner}': '${pkg.name}' is a virtual package (no build-system) and cannot be an environment subject`);
258
+ }
259
+ }
260
+ }
261
+ return [...build.entries()].map(([name, dir]) => ({ name, dir })).sort((a, b) => byCodePoint(a.name, b.name));
262
+ }
263
+ /**
264
+ * Walk up from `start` to the nearest `uv.lock`, parse and version-check it.
265
+ * Returns the governing workspace/standalone root + parsed lock, or null when
266
+ * no lock exists in `start` or any ancestor (no uv workspace to derive from).
267
+ *
268
+ * @internal
269
+ * @throws {Error} if a lock is found but its version is unsupported
270
+ */
271
+ export function findUvLock(start, owner) {
272
+ let dir = start;
273
+ for (;;) {
274
+ const candidate = path.join(dir, 'uv.lock');
275
+ if (fs.existsSync(candidate)) {
276
+ const lock = parseToml(fs.readFileSync(candidate, 'utf-8'));
277
+ if (lock.version !== 1) {
278
+ throw new Error(`Environment for '${owner}': unsupported uv.lock version ${lock.version} at '${dir}' — update @elaraai/e3 or re-lock with a compatible uv`);
279
+ }
280
+ return { root: dir, lock };
281
+ }
282
+ const parent = path.dirname(dir);
283
+ if (parent === dir)
284
+ return null;
285
+ dir = parent;
286
+ }
287
+ }
288
+ /** The distributions every east-py task runs with: the runtime, and the
289
+ * command that is its runner. */
290
+ const PYTHON_RUNTIME_DISTRIBUTIONS = ['elaraai-east-py', 'elaraai-east-py-cli'];
291
+ /**
292
+ * The registry distributions a workspace member's environment installs beside
293
+ * the member's own dependencies: the runtime's, and those of the stock
294
+ * platform packages its task's runner names, as the lock pins them.
295
+ *
296
+ * @remarks
297
+ * A workspace commonly lists these on its root alone, which an environment
298
+ * that installs a member's dependencies would otherwise leave out. A stock
299
+ * platform package `east-py-std` is the distribution `elaraai-east-py-std`.
300
+ * One the lock does not hold, or holds as a local package, is not named: the
301
+ * first comes from wherever the task runs, the second rides as an sdist.
302
+ *
303
+ * Each is named with the extras the workspace declares it with, on its root
304
+ * or on any member (`elaraai-east-py-datascience[lightning]`): a member
305
+ * whose task names the platform, and does not list the distribution itself,
306
+ * runs with what the workspace asked of it, torch among it.
307
+ *
308
+ * One the lock holds as a local archive (`path`) is refused, as a member's
309
+ * own is: an install would otherwise take a registry's copy of it.
310
+ *
311
+ * @internal
312
+ * @param lock - The workspace's lock
313
+ * @param platforms - The platform packages the runner names
314
+ * @param owner - The declaring task or function, which a refusal names
315
+ * @returns The distributions, by PEP 503 name and with their extras, sorted
316
+ * @throws {Error} When the lock holds one of them as a local archive
317
+ */
318
+ export function pythonRequires(lock, platforms, owner) {
319
+ const stock = STOCK_PLATFORMS_BY_RUNNER.east_py;
320
+ const wanted = new Set([...PYTHON_RUNTIME_DISTRIBUTIONS, ...platforms.filter((name) => stock.includes(name)).map((name) => `elaraai-${name}`)]
321
+ .map(canonicalPythonName));
322
+ // The extras the workspace's own packages declare each with
323
+ const extras = new Map();
324
+ for (const pkg of lock.package ?? []) {
325
+ if (!ownPackage(pkg))
326
+ continue;
327
+ for (const dependency of pkg.dependencies ?? []) {
328
+ const name = canonicalPythonName(dependency.name);
329
+ if (!wanted.has(name))
330
+ continue;
331
+ const declared = extras.get(name) ?? new Set();
332
+ for (const extra of dependency.extra ?? [])
333
+ declared.add(extra);
334
+ extras.set(name, declared);
335
+ }
336
+ }
337
+ const held = (lock.package ?? []).filter((pkg) => wanted.has(canonicalPythonName(pkg.name)));
338
+ for (const pkg of held)
339
+ if (typeof pkg.source?.path === 'string')
340
+ throw localArchiveRefused(owner, pkg.name);
341
+ return held
342
+ .filter((pkg) => !ownPackage(pkg))
343
+ .map((pkg) => {
344
+ const name = canonicalPythonName(pkg.name);
345
+ const declared = [...(extras.get(name) ?? [])].sort(byCodePoint);
346
+ return declared.length === 0 ? name : `${name}[${declared.join(',')}]`;
347
+ })
348
+ .sort(byCodePoint);
349
+ }
350
+ /**
351
+ * A required distribution, as {@link pythonRequires} names one: its name, and
352
+ * the extras it is installed with.
353
+ *
354
+ * @param required - A name, or a name with its extras
355
+ * (`elaraai-east-py-datascience[lightning,torch]`)
356
+ * @returns Its name and extras; null for what is neither, which its reader
357
+ * refuses in its own words
358
+ * @example
359
+ * readRequiredDistribution('elaraai-east-py-datascience[torch]'); // { name: 'elaraai-east-py-datascience', extras: ['torch'] }
360
+ */
361
+ export function readRequiredDistribution(required) {
362
+ const parts = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(required);
363
+ return parts === null ? null : { name: parts[1], extras: parts[2]?.split(',') ?? [] };
364
+ }
365
+ /** Whether a sync installs a package of a lock from an index, a repository or
366
+ * a URL: not from this machine, as the workspace's own packages and a local
367
+ * archive are, which a sync told `--no-install-workspace` and
368
+ * `--no-install-local` installs nothing of. */
369
+ function installedFromElsewhere(pkg) {
370
+ return !ownPackage(pkg) && typeof pkg.source?.path !== 'string';
371
+ }
372
+ /**
373
+ * The packages of a workspace's lock, by the lock's names, that the sync
374
+ * installing an environment's required distributions leaves out: every one it
375
+ * installs from an index, a repository or a URL but those the required
376
+ * distributions need, with their extras, and what those depend on.
377
+ *
378
+ * @remarks
379
+ * So that sync installs the required distributions as the lock pins them and
380
+ * from where the lock pins them — an explicit index of the workspace's
381
+ * among them, which no install that resolves again from a registry reads —
382
+ * and nothing else. A local package one of them depends on rides as an sdist
383
+ * ({@link pythonClosure}), and no sync of an environment installs a local
384
+ * package: none is taken from a registry.
385
+ *
386
+ * What a distribution needs is read from the lock for every platform it was
387
+ * resolved for, its markers aside: one a platform does not need is in no
388
+ * install for that platform, which the sync decides.
389
+ *
390
+ * @internal
391
+ * @param lockText - The lock, as `uv.lock` holds it
392
+ * @param requires - The required distributions, each a name or a name with
393
+ * its extras (`elaraai-east-py-datascience[lightning,torch]`), as
394
+ * {@link pythonRequires} names them
395
+ * @returns The names, sorted
396
+ * @throws {Error} When the lock is not of the version this reads, or a
397
+ * required distribution is not a name with or without extras
398
+ * @example
399
+ * const leftOut = pythonLeftOut(await readFile('uv.lock', 'utf8'), ['elaraai-east-py-datascience[torch]']);
400
+ * // uv sync --frozen --inexact --all-packages ... --no-install-package <each>
401
+ */
402
+ export function pythonLeftOut(lockText, requires) {
403
+ const lock = readUvLock(lockText);
404
+ // Each of every version a name is locked at, one for each platform it forks for
405
+ const needed = new Set();
406
+ for (const { name } of lockWalk(lock, requires.map(requiredStart)))
407
+ needed.add(name);
408
+ return [...new Set((lock.package ?? []).filter((pkg) => installedFromElsewhere(pkg) && !needed.has(canonicalPythonName(pkg.name))).map((pkg) => pkg.name))].sort(byCodePoint);
409
+ }
410
+ /**
411
+ * The development groups a sync of a project installs unless told otherwise:
412
+ * those its `[tool.uv] default-groups` names, or all of them for `"all"`, or
413
+ * uv's own default, `dev`. No lock records them.
414
+ *
415
+ * @throws {Error} When the setting is neither `"all"` nor a list of names
416
+ */
417
+ function defaultGroups(pyprojectText) {
418
+ const project = parseToml(pyprojectText);
419
+ const groups = project.tool?.uv?.['default-groups'];
420
+ if (groups === undefined)
421
+ return ['dev'];
422
+ if (groups === 'all')
423
+ return 'all';
424
+ if (Array.isArray(groups) && groups.every((group) => typeof group === 'string'))
425
+ return groups;
426
+ throw new Error('the project\'s [tool.uv] default-groups is neither "all" nor a list of group names');
427
+ }
428
+ /**
429
+ * The distributions a python environment installs, by PEP 503 name: what its
430
+ * sync takes of its lock ({@link PythonSync}), and the workspace's own
431
+ * packages it builds from their sdists (#1654).
432
+ *
433
+ * @remarks
434
+ * A package is taken as an install takes it ({@link lockWalk}): through its
435
+ * dependencies and the extras asked of it, so no extra nothing asks for, a
436
+ * workspace's own extras among them. No development group is installed for
437
+ * members, and a project that is its own root installs its packages' default
438
+ * groups. A name counts whatever the source an install takes it from: an
439
+ * index, a repository, a URL, or the workspace, a local checkout of a
440
+ * registry's package among them. A virtual package installs nothing of its
441
+ * own.
442
+ *
443
+ * What it names decides where the environment's work runs: on a rack, an
444
+ * `east-py` task whose environment installs what only the datascience image
445
+ * holds runs over that image.
446
+ *
447
+ * @param lockText - The lock, as `uv.lock` holds it
448
+ * @param sync - How the environment's sync takes it: a project's with its
449
+ * `pyproject.toml`, or members' with what is required beside them, each a
450
+ * name or a name with its extras, as {@link pythonRequires} names them
451
+ * @returns The names, sorted
452
+ * @throws {Error} When the lock is not of the version this reads, a required
453
+ * distribution is not a name with or without extras, or a project's
454
+ * default groups are neither `"all"` nor a list of names
455
+ * @example
456
+ * pythonInstalls(lockText, { kind: 'members', subjects: ['trainer'], requires: ['elaraai-east-py'] }).includes('torch');
457
+ */
458
+ export function pythonInstalls(lockText, sync) {
459
+ const lock = readUvLock(lockText);
460
+ let walk;
461
+ if (sync.kind === 'members') {
462
+ walk = lockWalk(lock, [...sync.subjects.map((name) => ({ name })), ...sync.requires.map(requiredStart)]);
463
+ }
464
+ else {
465
+ const groups = defaultGroups(sync.pyproject);
466
+ walk = lockWalk(lock, (lock.package ?? []).filter(ownPackage).map((pkg) => ({ name: pkg.name })), () => false, (pkg) => ownPackage(pkg) ? groups : []);
467
+ }
468
+ const installed = new Set();
469
+ for (const { name, packages } of walk) {
470
+ if (packages.some((pkg) => typeof pkg.source?.virtual !== 'string'))
471
+ installed.add(name);
472
+ }
473
+ return [...installed].sort(byCodePoint);
474
+ }
475
+ /**
476
+ * A required distribution, as {@link pythonRequires} names one, as a walk of
477
+ * the lock starts from it.
478
+ *
479
+ * @internal
480
+ * @param required - A name, or a name with its extras
481
+ * @returns The distribution, with its extras
482
+ * @throws {Error} When it is neither
483
+ */
484
+ export function requiredStart(required) {
485
+ const read = readRequiredDistribution(required);
486
+ if (read === null)
487
+ throw new Error(`the required distribution '${required}' is not a package's name`);
488
+ return read;
489
+ }
490
+ /**
491
+ * The settings a workspace's lock was resolved under that resolve a
492
+ * distribution otherwise than a package depending on it asks: what its
493
+ * `override-dependencies` name, whose version may be one a dependent's
494
+ * requirement does not allow, and what its `exclude-dependencies` name, which
495
+ * nothing installs though a dependent requires it.
496
+ *
497
+ * @remarks
498
+ * The lock records both in its manifest, and a sync of it installs as they
499
+ * say. A check of what is installed against each distribution's own
500
+ * requirements, as `uv pip check` makes, knows neither, so an environment
501
+ * materialized from the lock is checked with them.
502
+ *
503
+ * @internal
504
+ * @param lockText - The lock, as `uv.lock` holds it
505
+ * @returns The distributions overridden, and those excluded, each by PEP 503
506
+ * name, sorted
507
+ * @throws {Error} When the lock is not of the version this reads
508
+ * @example
509
+ * // Under `override-dependencies = ["shap>=0.51.0"]`
510
+ * pythonLockSettings(await readFile('uv.lock', 'utf8')); // { overrides: ['shap'], excludes: [] }
511
+ */
512
+ export function pythonLockSettings(lockText) {
513
+ const { manifest } = readUvLock(lockText);
514
+ const names = (named) => [...new Set(named.map(canonicalPythonName))].sort(byCodePoint);
515
+ return { overrides: names((manifest?.overrides ?? []).map((override) => override.name)), excludes: names(manifest?.excludes ?? []) };
516
+ }
517
+ /**
518
+ * The local uv-workspace member a name refers to — the package a `{ custom }`
519
+ * platform or an `East.importFunction(pkg, …)` names (#652) — resolved the
520
+ * way `captureAutoEnvironment` resolves it: the governing `uv.lock`
521
+ * above `anchorDir`, matched by PEP 503 canonical name, local sources only.
522
+ *
523
+ * @param name - The package name as referenced (import-style or canonical)
524
+ * @param anchorDir - Directory the workspace is resolved from (the export cwd)
525
+ * @param owner - The referencing task/function name, for error messages
526
+ * @returns The member's directory and its `pyproject.toml` version, or null
527
+ * when there is no uv workspace above `anchorDir` or the name is not a
528
+ * local member (a registry package, a typo)
529
+ */
530
+ export function pythonWorkspaceMember(name, anchorDir, owner) {
531
+ const found = findUvLock(anchorDir, owner);
532
+ if (!found)
533
+ return null;
534
+ const { root, lock } = found;
535
+ const canon = canonicalPythonName(name);
536
+ const pkg = (lock.package ?? []).find((p) => canonicalPythonName(p.name) === canon);
537
+ const local = pkg === undefined ? null : localSource(root, pkg.source);
538
+ if (local === null)
539
+ return null;
540
+ let version = null;
541
+ try {
542
+ const project = parseToml(fs.readFileSync(path.join(local.dir, 'pyproject.toml'), 'utf-8'));
543
+ if (typeof project.project?.version === 'string')
544
+ version = project.project.version;
545
+ }
546
+ catch {
547
+ /* no readable pyproject: the exporter records its own default */
548
+ }
549
+ return { dir: local.dir, version };
550
+ }
551
+ /**
552
+ * Where a python workspace member's code can come from (#1459): the governing
553
+ * workspace's root — whose `uv.lock` and `pyproject.toml` pin everything else
554
+ * — and the directories of the member and of every local package it depends
555
+ * on, transitively, as `captureAutoEnvironment` walks them ({@link lockWalk}).
556
+ * What the export cache keys a member's manifests on.
557
+ *
558
+ * Unlike the environment's walk this refuses nothing: a virtual package's
559
+ * directory counts, and a registry or archive package is pinned by the lock.
560
+ *
561
+ * @param name - The package name as referenced (import-style or canonical)
562
+ * @param anchorDir - Directory the workspace is resolved from (the export cwd)
563
+ * @param owner - The referencing task/function name, for error messages
564
+ * @returns The workspace root and the closure's directories, sorted, or null
565
+ * when there is no uv workspace above `anchorDir` or the name is not a
566
+ * local member
567
+ */
568
+ export function pythonMemberSources(name, anchorDir, owner) {
569
+ const found = findUvLock(anchorDir, owner);
570
+ if (!found)
571
+ return null;
572
+ const { root, lock } = found;
573
+ const canon = canonicalPythonName(name);
574
+ const subject = (lock.package ?? []).find((p) => canonicalPythonName(p.name) === canon);
575
+ if (subject === undefined || !ownPackage(subject))
576
+ return null;
577
+ // Through registry packages too: one may depend on a local package
578
+ const dirs = new Set();
579
+ for (const { packages } of lockWalk(lock, [{ name: subject.name }], ownPackage)) {
580
+ for (const pkg of packages) {
581
+ const local = localSource(root, pkg.source);
582
+ if (local !== null)
583
+ dirs.add(local.dir);
584
+ }
585
+ }
586
+ return { root, dirs: [...dirs].sort() };
587
+ }
588
+ //# sourceMappingURL=environment-uv-lock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment-uv-lock.js","sourceRoot":"","sources":["../../src/environment-uv-lock.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAExD,2EAA2E;AAC3E,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;AAyC3C;;;;GAIG;AACH,SAAS,UAAU,CAAC,QAAgB;IAClC,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAsB,CAAC;IACtD,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC/F,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;gBAEgB;AAChB,MAAM,UAAU,aAAa,CAAC,CAAS;IACrC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,CAAC;QAAC,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAC,uBAAuB,CAAC,CAAC;IACjE,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D,CA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C"}
@@ -1 +1 @@
1
- {"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/export.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAA0K,KAAK,gBAAgB,EAAqB,MAAM,eAAe,CAAC;AAKjP,OAAO,KAAK,EAA2B,UAAU,EAAe,MAAM,YAAY,CAAC;AAGnF,OAAO,EAA8C,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACzG,OAAO,EAAqE,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAM9H;;;;;;;;;;;;;;;GAeG;AACH;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG,YAAY,CAAC,GAAG,CAAC;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GAAG,YAAY,CAAC,CAAC;AAExG,yCAAyC;AACzC,MAAM,WAAW,aAAa;IAC5B,8GAA8G;IAC9G,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAGD,wBAAsB,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAkZ/I;AAuCD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAKrE"}
1
+ {"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/export.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAA0K,KAAK,gBAAgB,EAAqB,MAAM,eAAe,CAAC;AAKjP,OAAO,KAAK,EAA2B,UAAU,EAAe,MAAM,YAAY,CAAC;AAGnF,OAAO,EAAgE,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC3H,OAAO,EAAqE,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAM9H;;;;;;;;;;;;;;;GAeG;AACH;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG,YAAY,CAAC,GAAG,CAAC;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GAAG,YAAY,CAAC,CAAC;AAExG,yCAAyC;AACzC,MAAM,WAAW,aAAa;IAC5B,8GAA8G;IAC9G,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAGD,wBAAsB,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA2Z/I;AAuCD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAKrE"}
@@ -115,6 +115,9 @@ export async function export_(pkg, outputPath, options) {
115
115
  // capture shells out to uv/npm). '' marks a key that resolved to "no
116
116
  // environment", so it is neither re-derived nor mistaken for a cache miss.
117
117
  const environmentHashes = new Map();
118
+ // Each local python package's sdist, built once in the export: environments
119
+ // of one declaration whose runners name other stock platforms share it
120
+ const builtSdists = new Map();
118
121
  const cachedEnvHash = (key, capture) => {
119
122
  let hash = environmentHashes.get(key);
120
123
  if (hash === undefined) {
@@ -125,9 +128,15 @@ export async function export_(pkg, outputPath, options) {
125
128
  return hash === '' ? null : hash;
126
129
  };
127
130
  const environmentHashFor = (decl, runner, owner) => {
131
+ // The stock platform packages an east-py runner names beside its custom
132
+ // ones: a python workspace member's environment installs them too, so
133
+ // they are part of what it is
134
+ const stock = runner === undefined || runner.runtime !== 'east-py' ? []
135
+ : (runner.platforms ?? []).flatMap((p) => (typeof p === 'string' ? [p] : [])).sort();
128
136
  // An explicit `environment` wins (and is the only path to tools/image).
129
137
  if (decl) {
130
- return cachedEnvHash(`decl:${JSON.stringify(decl)}`, () => captureEnvironment(decl, owner, (file) => addObject(zipfile, Buffer.from(encodeFile(file))), onCapture));
138
+ const key = `decl:${JSON.stringify(decl)}${'python' in decl ? `:${stock.join(',')}` : ''}`;
139
+ return cachedEnvHash(key, () => captureEnvironment(decl, owner, (file) => addObject(zipfile, Buffer.from(encodeFile(file))), onCapture, stock, builtSdists));
131
140
  }
132
141
  // Otherwise derive it from the runner's `{ custom }` platform references, so
133
142
  // a project split into workspace packages gets per-package change-detection
@@ -139,8 +148,8 @@ export async function export_(pkg, outputPath, options) {
139
148
  .map((p) => p.custom);
140
149
  if (customs.length === 0)
141
150
  return null;
142
- const key = `auto:${runner.runtime}:${[...customs].sort().join(',')}`;
143
- return cachedEnvHash(key, () => captureAutoEnvironment(runner.runtime, customs, process.cwd(), owner, (file) => addObject(zipfile, Buffer.from(encodeFile(file))), onCapture));
151
+ const key = `auto:${runner.runtime}:${[...customs].sort().join(',')}:${stock.join(',')}`;
152
+ return cachedEnvHash(key, () => captureAutoEnvironment(runner.runtime, customs, process.cwd(), owner, (file) => addObject(zipfile, Buffer.from(encodeFile(file))), onCapture, stock, builtSdists));
144
153
  };
145
154
  const resolveEnvironment = (decl, runner, owner) => {
146
155
  const hash = environmentHashFor(decl, runner, owner);