@elaraai/e3 1.0.109 → 1.0.110
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/dist/src/environment-capture.d.ts +27 -57
- package/dist/src/environment-capture.d.ts.map +1 -1
- package/dist/src/environment-capture.js +86 -455
- package/dist/src/environment-capture.js.map +1 -1
- package/dist/src/environment-capture.spec.js +215 -5
- package/dist/src/environment-capture.spec.js.map +1 -1
- package/dist/src/environment-npm-lock.d.ts +77 -0
- package/dist/src/environment-npm-lock.d.ts.map +1 -0
- package/dist/src/environment-npm-lock.js +209 -0
- package/dist/src/environment-npm-lock.js.map +1 -0
- package/dist/src/environment-uv-lock.d.ts +312 -0
- package/dist/src/environment-uv-lock.d.ts.map +1 -0
- package/dist/src/environment-uv-lock.js +494 -0
- package/dist/src/environment-uv-lock.js.map +1 -0
- package/dist/src/export.d.ts.map +1 -1
- package/dist/src/export.js +12 -3
- package/dist/src/export.js.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/runner.d.ts +14 -2
- package/dist/src/runner.d.ts.map +1 -1
- package/dist/src/runner.js +16 -4
- package/dist/src/runner.js.map +1 -1
- package/dist/src/stock-platforms.spec.js +7 -1
- package/dist/src/stock-platforms.spec.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,494 @@
|
|
|
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 on-disk directory a lock `source` points at, with its kind — or null
|
|
65
|
+
* for registry/git/url sources (installed by uv sync, not captured), and for
|
|
66
|
+
* a local archive (`path`), which no environment takes.
|
|
67
|
+
* @internal */
|
|
68
|
+
export function localSource(root, source) {
|
|
69
|
+
if (!source)
|
|
70
|
+
return null;
|
|
71
|
+
for (const kind of ['editable', 'directory', 'virtual']) {
|
|
72
|
+
if (typeof source[kind] === 'string')
|
|
73
|
+
return { dir: path.resolve(root, source[kind]), kind };
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
/** The refusal of a package the lock holds as a local archive (`path`), which
|
|
78
|
+
* no environment takes: neither its sdist nor a registry's copy of it. */
|
|
79
|
+
function localArchiveRefused(owner, name) {
|
|
80
|
+
return new Error(`Environment for '${owner}': local archive dependency '${name}' is not supported — use a directory/workspace source or a registry`);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Every package of a lock that `starts` reach by what they depend on, each
|
|
84
|
+
* name once, in the order reached, with each of its entries: a name the lock
|
|
85
|
+
* locks at several versions, one for each platform it forks for, has
|
|
86
|
+
* several.
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* A package is walked as an install takes it: through its dependencies, and
|
|
90
|
+
* the optional groups of the extras the dependency that reached it asked for;
|
|
91
|
+
* an extra another dependency asks for is walked when that one reaches it. So
|
|
92
|
+
* an extra of a registry package that nothing asks for is never walked, nor
|
|
93
|
+
* what only it names. A package `whole` says so of is walked through every
|
|
94
|
+
* group it names, its development groups among them, whatever reached it: a
|
|
95
|
+
* workspace's own package, whose walk may over-reach, since over-capture only
|
|
96
|
+
* over-invalidates.
|
|
97
|
+
*
|
|
98
|
+
* A registry package's dependency may be a local package: the lock resolves a
|
|
99
|
+
* name the workspace holds to the workspace's package.
|
|
100
|
+
*
|
|
101
|
+
* @internal
|
|
102
|
+
* @param lock - The lock
|
|
103
|
+
* @param starts - The packages to start from, with their extras
|
|
104
|
+
* @param whole - Whether a package is walked through every group it names;
|
|
105
|
+
* none is unless given
|
|
106
|
+
* @returns Each package reached, by its PEP 503 name, with its entries; none
|
|
107
|
+
* for a name the lock does not hold
|
|
108
|
+
* @example
|
|
109
|
+
* for (const { name, packages } of lockWalk(lock, [{ name: 'elaraai-east-py-datascience', extras: ['torch'] }])) needed.add(name);
|
|
110
|
+
*/
|
|
111
|
+
export function* lockWalk(lock, starts, whole = () => false) {
|
|
112
|
+
const byName = new Map();
|
|
113
|
+
for (const pkg of lock.package ?? []) {
|
|
114
|
+
const name = canonicalPythonName(pkg.name);
|
|
115
|
+
byName.set(name, [...(byName.get(name) ?? []), pkg]);
|
|
116
|
+
}
|
|
117
|
+
const reached = new Set();
|
|
118
|
+
// What has been walked: a package's dependencies by its name, and an extra's by `name[extra]`
|
|
119
|
+
const walked = new Set();
|
|
120
|
+
const queue = [...starts];
|
|
121
|
+
while (queue.length > 0) {
|
|
122
|
+
const start = queue.shift();
|
|
123
|
+
const name = canonicalPythonName(start.name);
|
|
124
|
+
const packages = byName.get(name) ?? [];
|
|
125
|
+
if (!reached.has(name)) {
|
|
126
|
+
reached.add(name);
|
|
127
|
+
yield { name, packages };
|
|
128
|
+
}
|
|
129
|
+
const fresh = [...(walked.has(name) ? [] : ['']), ...(start.extras ?? []).filter((extra) => !walked.has(`${name}[${extra}]`))];
|
|
130
|
+
for (const part of fresh)
|
|
131
|
+
walked.add(part === '' ? name : `${name}[${part}]`);
|
|
132
|
+
for (const pkg of packages) {
|
|
133
|
+
const edges = !whole(pkg) ? fresh.flatMap((part) => part === '' ? pkg.dependencies ?? [] : pkg['optional-dependencies']?.[part] ?? [])
|
|
134
|
+
: !fresh.includes('') ? []
|
|
135
|
+
: [...pkg.dependencies ?? [], ...Object.values(pkg['optional-dependencies'] ?? {}).flat(), ...Object.values(pkg['dev-dependencies'] ?? {}).flat()];
|
|
136
|
+
for (const edge of edges)
|
|
137
|
+
queue.push({ name: edge.name, extras: edge.extra ?? [] });
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Find the workspace/standalone root governing `project` and the lock
|
|
143
|
+
* package (`subject`) whose local source resolves to it.
|
|
144
|
+
*
|
|
145
|
+
* @internal
|
|
146
|
+
* @throws {Error} P3 (no lock in project or any ancestor), P5 (unsupported
|
|
147
|
+
* lock version), P4 (lock does not list a package at `project`)
|
|
148
|
+
*/
|
|
149
|
+
export function discoverPythonRoot(project, owner) {
|
|
150
|
+
let dir = project;
|
|
151
|
+
let lockPath = null;
|
|
152
|
+
for (;;) {
|
|
153
|
+
const candidate = path.join(dir, 'uv.lock');
|
|
154
|
+
if (fs.existsSync(candidate)) {
|
|
155
|
+
lockPath = candidate;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
const parent = path.dirname(dir);
|
|
159
|
+
if (parent === dir)
|
|
160
|
+
break;
|
|
161
|
+
dir = parent;
|
|
162
|
+
}
|
|
163
|
+
if (!lockPath) {
|
|
164
|
+
throw new Error(`Environment for '${owner}': no uv.lock in '${project}' or any parent — run 'uv lock' in ` +
|
|
165
|
+
`'${project}' (standalone), or add it to [tool.uv.workspace].members of the workspace root and 'uv lock' there`);
|
|
166
|
+
}
|
|
167
|
+
const root = path.dirname(lockPath);
|
|
168
|
+
const lock = parseToml(fs.readFileSync(lockPath, 'utf-8'));
|
|
169
|
+
if (lock.version !== 1) {
|
|
170
|
+
throw new Error(`Environment for '${owner}': unsupported uv.lock version ${lock.version} at '${root}' — update @elaraai/e3 or re-lock with a compatible uv`);
|
|
171
|
+
}
|
|
172
|
+
const projectCanon = canonicalPath(project);
|
|
173
|
+
const subject = (lock.package ?? []).find((p) => {
|
|
174
|
+
const local = localSource(root, p.source);
|
|
175
|
+
return local !== null && canonicalPath(local.dir) === projectCanon;
|
|
176
|
+
});
|
|
177
|
+
if (!subject) {
|
|
178
|
+
throw new Error(`Environment for '${owner}': uv.lock at '${root}' does not list a package at '${project}' — ` +
|
|
179
|
+
`the lockfile is out of date or the project is not a workspace member; run 'uv lock' at '${root}'`);
|
|
180
|
+
}
|
|
181
|
+
return { root, lock, subject: subject.name };
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* The LOCAL packages reachable from an environment's subjects, and from the
|
|
185
|
+
* registry distributions it requires beside them — the set whose sdists must
|
|
186
|
+
* ride the environment.
|
|
187
|
+
*
|
|
188
|
+
* Walks a local package through `dependencies` plus every optional-dependency
|
|
189
|
+
* and dev-dependency group (over-capture is sound: it only over-invalidates),
|
|
190
|
+
* and a registry package as an install takes it: through its dependencies
|
|
191
|
+
* and the extras asked of it ({@link lockWalk}). A registry package is
|
|
192
|
+
* installed from the lock, and a local package it depends on rides as an
|
|
193
|
+
* sdist, as the installs take no local package from a registry. A
|
|
194
|
+
* `path=<archive>` source the walk reaches is refused — never one only an
|
|
195
|
+
* extra nothing asks for names — and a virtual package contributes its deps
|
|
196
|
+
* but no sdist.
|
|
197
|
+
*
|
|
198
|
+
* @internal
|
|
199
|
+
* @param subjects - The members the environment is of, by the lock's names
|
|
200
|
+
* @param required - The registry distributions it requires beside them, with
|
|
201
|
+
* the extras each is installed with
|
|
202
|
+
* @returns The buildable closure members, sorted by name
|
|
203
|
+
* @throws {Error} P6 (dangling edge), P7 (subject not packaged), P8 (source
|
|
204
|
+
* dir missing), P9 (local archive dependency)
|
|
205
|
+
*/
|
|
206
|
+
export function pythonClosure(lock, root, subjects, owner, required = []) {
|
|
207
|
+
const build = new Map();
|
|
208
|
+
const own = new Set(subjects.map(canonicalPythonName));
|
|
209
|
+
const local = (pkg) => localSource(root, pkg.source) !== null;
|
|
210
|
+
for (const { name, packages } of lockWalk(lock, [...subjects.map((subject) => ({ name: subject })), ...required], local)) {
|
|
211
|
+
if (packages.length === 0) {
|
|
212
|
+
if (own.has(name))
|
|
213
|
+
throw new Error(`Environment for '${owner}': subject '${name}' not in uv.lock`);
|
|
214
|
+
throw new Error(`Environment for '${owner}': uv.lock is inconsistent — depends on unknown '${name}'; run 'uv lock'`);
|
|
215
|
+
}
|
|
216
|
+
for (const pkg of packages) {
|
|
217
|
+
if (typeof pkg.source?.path === 'string')
|
|
218
|
+
throw localArchiveRefused(owner, pkg.name);
|
|
219
|
+
const source = localSource(root, pkg.source);
|
|
220
|
+
if (!source)
|
|
221
|
+
continue; // registry/git/url — sync installs it, and what it depends on is walked
|
|
222
|
+
if (source.kind !== 'virtual') {
|
|
223
|
+
if (!fs.existsSync(source.dir)) {
|
|
224
|
+
throw new Error(`Environment for '${owner}': package '${pkg.name}' resolves to '${source.dir}' which does not exist — run 'uv lock' or fix its path`);
|
|
225
|
+
}
|
|
226
|
+
build.set(pkg.name, source.dir);
|
|
227
|
+
}
|
|
228
|
+
else if (own.has(name)) {
|
|
229
|
+
throw new Error(`Environment for '${owner}': '${pkg.name}' is a virtual package (no build-system) and cannot be an environment subject`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return [...build.entries()].map(([name, dir]) => ({ name, dir })).sort((a, b) => byCodePoint(a.name, b.name));
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Walk up from `start` to the nearest `uv.lock`, parse and version-check it.
|
|
237
|
+
* Returns the governing workspace/standalone root + parsed lock, or null when
|
|
238
|
+
* no lock exists in `start` or any ancestor (no uv workspace to derive from).
|
|
239
|
+
*
|
|
240
|
+
* @internal
|
|
241
|
+
* @throws {Error} if a lock is found but its version is unsupported
|
|
242
|
+
*/
|
|
243
|
+
export function findUvLock(start, owner) {
|
|
244
|
+
let dir = start;
|
|
245
|
+
for (;;) {
|
|
246
|
+
const candidate = path.join(dir, 'uv.lock');
|
|
247
|
+
if (fs.existsSync(candidate)) {
|
|
248
|
+
const lock = parseToml(fs.readFileSync(candidate, 'utf-8'));
|
|
249
|
+
if (lock.version !== 1) {
|
|
250
|
+
throw new Error(`Environment for '${owner}': unsupported uv.lock version ${lock.version} at '${dir}' — update @elaraai/e3 or re-lock with a compatible uv`);
|
|
251
|
+
}
|
|
252
|
+
return { root: dir, lock };
|
|
253
|
+
}
|
|
254
|
+
const parent = path.dirname(dir);
|
|
255
|
+
if (parent === dir)
|
|
256
|
+
return null;
|
|
257
|
+
dir = parent;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
/** The distributions every east-py task runs with: the runtime, and the
|
|
261
|
+
* command that is its runner. */
|
|
262
|
+
const PYTHON_RUNTIME_DISTRIBUTIONS = ['elaraai-east-py', 'elaraai-east-py-cli'];
|
|
263
|
+
/**
|
|
264
|
+
* The registry distributions a workspace member's environment installs beside
|
|
265
|
+
* the member's own dependencies: the runtime's, and those of the stock
|
|
266
|
+
* platform packages its task's runner names, as the lock pins them.
|
|
267
|
+
*
|
|
268
|
+
* @remarks
|
|
269
|
+
* A workspace commonly lists these on its root alone, which an environment
|
|
270
|
+
* that installs a member's dependencies would otherwise leave out. A stock
|
|
271
|
+
* platform package `east-py-std` is the distribution `elaraai-east-py-std`.
|
|
272
|
+
* One the lock does not hold, or holds as a local package, is not named: the
|
|
273
|
+
* first comes from wherever the task runs, the second rides as an sdist.
|
|
274
|
+
*
|
|
275
|
+
* Each is named with the extras the workspace declares it with, on its root
|
|
276
|
+
* or on any member (`elaraai-east-py-datascience[lightning]`): a member
|
|
277
|
+
* whose task names the platform, and does not list the distribution itself,
|
|
278
|
+
* runs with what the workspace asked of it, torch among it.
|
|
279
|
+
*
|
|
280
|
+
* One the lock holds as a local archive (`path`) is refused, as a member's
|
|
281
|
+
* own is: an install would otherwise take a registry's copy of it.
|
|
282
|
+
*
|
|
283
|
+
* @internal
|
|
284
|
+
* @param root - The workspace root
|
|
285
|
+
* @param lock - Its lock
|
|
286
|
+
* @param platforms - The platform packages the runner names
|
|
287
|
+
* @param owner - The declaring task or function, which a refusal names
|
|
288
|
+
* @returns The distributions, by PEP 503 name and with their extras, sorted
|
|
289
|
+
* @throws {Error} When the lock holds one of them as a local archive
|
|
290
|
+
*/
|
|
291
|
+
export function pythonRequires(root, lock, platforms, owner) {
|
|
292
|
+
const stock = STOCK_PLATFORMS_BY_RUNNER.east_py;
|
|
293
|
+
const wanted = new Set([...PYTHON_RUNTIME_DISTRIBUTIONS, ...platforms.filter((name) => stock.includes(name)).map((name) => `elaraai-${name}`)]
|
|
294
|
+
.map(canonicalPythonName));
|
|
295
|
+
// The extras the workspace's own packages declare each with
|
|
296
|
+
const extras = new Map();
|
|
297
|
+
for (const pkg of lock.package ?? []) {
|
|
298
|
+
if (localSource(root, pkg.source) === null)
|
|
299
|
+
continue;
|
|
300
|
+
for (const dependency of pkg.dependencies ?? []) {
|
|
301
|
+
const name = canonicalPythonName(dependency.name);
|
|
302
|
+
if (!wanted.has(name))
|
|
303
|
+
continue;
|
|
304
|
+
const declared = extras.get(name) ?? new Set();
|
|
305
|
+
for (const extra of dependency.extra ?? [])
|
|
306
|
+
declared.add(extra);
|
|
307
|
+
extras.set(name, declared);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const held = (lock.package ?? []).filter((pkg) => wanted.has(canonicalPythonName(pkg.name)));
|
|
311
|
+
for (const pkg of held)
|
|
312
|
+
if (typeof pkg.source?.path === 'string')
|
|
313
|
+
throw localArchiveRefused(owner, pkg.name);
|
|
314
|
+
return held
|
|
315
|
+
.filter((pkg) => localSource(root, pkg.source) === null)
|
|
316
|
+
.map((pkg) => {
|
|
317
|
+
const name = canonicalPythonName(pkg.name);
|
|
318
|
+
const declared = [...(extras.get(name) ?? [])].sort(byCodePoint);
|
|
319
|
+
return declared.length === 0 ? name : `${name}[${declared.join(',')}]`;
|
|
320
|
+
})
|
|
321
|
+
.sort(byCodePoint);
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* A required distribution, as {@link pythonRequires} names one: its name, and
|
|
325
|
+
* the extras it is installed with.
|
|
326
|
+
*
|
|
327
|
+
* @param required - A name, or a name with its extras
|
|
328
|
+
* (`elaraai-east-py-datascience[lightning,torch]`)
|
|
329
|
+
* @returns Its name and extras; null for what is neither, which its reader
|
|
330
|
+
* refuses in its own words
|
|
331
|
+
* @example
|
|
332
|
+
* readRequiredDistribution('elaraai-east-py-datascience[torch]'); // { name: 'elaraai-east-py-datascience', extras: ['torch'] }
|
|
333
|
+
*/
|
|
334
|
+
export function readRequiredDistribution(required) {
|
|
335
|
+
const parts = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(required);
|
|
336
|
+
return parts === null ? null : { name: parts[1], extras: parts[2]?.split(',') ?? [] };
|
|
337
|
+
}
|
|
338
|
+
/** The sources a lock installs a package from that are this machine's: what
|
|
339
|
+
* a sync told `--no-install-local` and `--no-install-workspace` installs
|
|
340
|
+
* nothing of. */
|
|
341
|
+
const LOCAL_SOURCE_KINDS = ['editable', 'directory', 'virtual', 'path'];
|
|
342
|
+
/**
|
|
343
|
+
* The packages of a workspace's lock, by the lock's names, that the sync
|
|
344
|
+
* installing an environment's required distributions leaves out: every one it
|
|
345
|
+
* installs from an index, a repository or a URL but those the required
|
|
346
|
+
* distributions need, with their extras, and what those depend on.
|
|
347
|
+
*
|
|
348
|
+
* @remarks
|
|
349
|
+
* So that sync installs the required distributions as the lock pins them and
|
|
350
|
+
* from where the lock pins them — an explicit index of the workspace's
|
|
351
|
+
* among them, which no install that resolves again from a registry reads —
|
|
352
|
+
* and nothing else. A local package one of them depends on rides as an sdist
|
|
353
|
+
* ({@link pythonClosure}), and no sync of an environment installs a local
|
|
354
|
+
* package: none is taken from a registry.
|
|
355
|
+
*
|
|
356
|
+
* What a distribution needs is read from the lock for every platform it was
|
|
357
|
+
* resolved for, its markers aside: one a platform does not need is in no
|
|
358
|
+
* install for that platform, which the sync decides.
|
|
359
|
+
*
|
|
360
|
+
* @internal
|
|
361
|
+
* @param lockText - The lock, as `uv.lock` holds it
|
|
362
|
+
* @param requires - The required distributions, each a name or a name with
|
|
363
|
+
* its extras (`elaraai-east-py-datascience[lightning,torch]`), as
|
|
364
|
+
* {@link pythonRequires} names them
|
|
365
|
+
* @returns The names, sorted
|
|
366
|
+
* @throws {Error} When the lock is not of the version this reads, or a
|
|
367
|
+
* required distribution is not a name with or without extras
|
|
368
|
+
* @example
|
|
369
|
+
* const leftOut = pythonLeftOut(await readFile('uv.lock', 'utf8'), ['elaraai-east-py-datascience[torch]']);
|
|
370
|
+
* // uv sync --frozen --inexact --all-packages ... --no-install-package <each>
|
|
371
|
+
*/
|
|
372
|
+
export function pythonLeftOut(lockText, requires) {
|
|
373
|
+
const lock = readUvLock(lockText);
|
|
374
|
+
// Each of every version a name is locked at, one for each platform it forks for
|
|
375
|
+
const needed = new Set();
|
|
376
|
+
for (const { name } of lockWalk(lock, requires.map(requiredStart)))
|
|
377
|
+
needed.add(name);
|
|
378
|
+
const local = (pkg) => LOCAL_SOURCE_KINDS.some((kind) => typeof pkg.source?.[kind] === 'string');
|
|
379
|
+
return [...new Set((lock.package ?? []).filter((pkg) => !local(pkg) && !needed.has(canonicalPythonName(pkg.name))).map((pkg) => pkg.name))].sort(byCodePoint);
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* A required distribution, as {@link pythonRequires} names one, as a walk of
|
|
383
|
+
* the lock starts from it.
|
|
384
|
+
*
|
|
385
|
+
* @internal
|
|
386
|
+
* @param required - A name, or a name with its extras
|
|
387
|
+
* @returns The distribution, with its extras
|
|
388
|
+
* @throws {Error} When it is neither
|
|
389
|
+
*/
|
|
390
|
+
export function requiredStart(required) {
|
|
391
|
+
const read = readRequiredDistribution(required);
|
|
392
|
+
if (read === null)
|
|
393
|
+
throw new Error(`the required distribution '${required}' is not a package's name`);
|
|
394
|
+
return read;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* The settings a workspace's lock was resolved under that resolve a
|
|
398
|
+
* distribution otherwise than a package depending on it asks: what its
|
|
399
|
+
* `override-dependencies` name, whose version may be one a dependent's
|
|
400
|
+
* requirement does not allow, and what its `exclude-dependencies` name, which
|
|
401
|
+
* nothing installs though a dependent requires it.
|
|
402
|
+
*
|
|
403
|
+
* @remarks
|
|
404
|
+
* The lock records both in its manifest, and a sync of it installs as they
|
|
405
|
+
* say. A check of what is installed against each distribution's own
|
|
406
|
+
* requirements, as `uv pip check` makes, knows neither, so an environment
|
|
407
|
+
* materialized from the lock is checked with them.
|
|
408
|
+
*
|
|
409
|
+
* @internal
|
|
410
|
+
* @param lockText - The lock, as `uv.lock` holds it
|
|
411
|
+
* @returns The distributions overridden, and those excluded, each by PEP 503
|
|
412
|
+
* name, sorted
|
|
413
|
+
* @throws {Error} When the lock is not of the version this reads
|
|
414
|
+
* @example
|
|
415
|
+
* // Under `override-dependencies = ["shap>=0.51.0"]`
|
|
416
|
+
* pythonLockSettings(await readFile('uv.lock', 'utf8')); // { overrides: ['shap'], excludes: [] }
|
|
417
|
+
*/
|
|
418
|
+
export function pythonLockSettings(lockText) {
|
|
419
|
+
const { manifest } = readUvLock(lockText);
|
|
420
|
+
const names = (named) => [...new Set(named.map(canonicalPythonName))].sort(byCodePoint);
|
|
421
|
+
return { overrides: names((manifest?.overrides ?? []).map((override) => override.name)), excludes: names(manifest?.excludes ?? []) };
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* The local uv-workspace member a name refers to — the package a `{ custom }`
|
|
425
|
+
* platform or an `East.importFunction(pkg, …)` names (#652) — resolved the
|
|
426
|
+
* way `captureAutoEnvironment` resolves it: the governing `uv.lock`
|
|
427
|
+
* above `anchorDir`, matched by PEP 503 canonical name, local sources only.
|
|
428
|
+
*
|
|
429
|
+
* @param name - The package name as referenced (import-style or canonical)
|
|
430
|
+
* @param anchorDir - Directory the workspace is resolved from (the export cwd)
|
|
431
|
+
* @param owner - The referencing task/function name, for error messages
|
|
432
|
+
* @returns The member's directory and its `pyproject.toml` version, or null
|
|
433
|
+
* when there is no uv workspace above `anchorDir` or the name is not a
|
|
434
|
+
* local member (a registry package, a typo)
|
|
435
|
+
*/
|
|
436
|
+
export function pythonWorkspaceMember(name, anchorDir, owner) {
|
|
437
|
+
const found = findUvLock(anchorDir, owner);
|
|
438
|
+
if (!found)
|
|
439
|
+
return null;
|
|
440
|
+
const { root, lock } = found;
|
|
441
|
+
const canon = canonicalPythonName(name);
|
|
442
|
+
const pkg = (lock.package ?? []).find((p) => canonicalPythonName(p.name) === canon);
|
|
443
|
+
const local = pkg === undefined ? null : localSource(root, pkg.source);
|
|
444
|
+
if (local === null)
|
|
445
|
+
return null;
|
|
446
|
+
let version = null;
|
|
447
|
+
try {
|
|
448
|
+
const project = parseToml(fs.readFileSync(path.join(local.dir, 'pyproject.toml'), 'utf-8'));
|
|
449
|
+
if (typeof project.project?.version === 'string')
|
|
450
|
+
version = project.project.version;
|
|
451
|
+
}
|
|
452
|
+
catch {
|
|
453
|
+
/* no readable pyproject: the exporter records its own default */
|
|
454
|
+
}
|
|
455
|
+
return { dir: local.dir, version };
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Where a python workspace member's code can come from (#1459): the governing
|
|
459
|
+
* workspace's root — whose `uv.lock` and `pyproject.toml` pin everything else
|
|
460
|
+
* — and the directories of the member and of every local package it depends
|
|
461
|
+
* on, transitively, as `captureAutoEnvironment` walks them ({@link lockWalk}).
|
|
462
|
+
* What the export cache keys a member's manifests on.
|
|
463
|
+
*
|
|
464
|
+
* Unlike the environment's walk this refuses nothing: a virtual package's
|
|
465
|
+
* directory counts, and a registry or archive package is pinned by the lock.
|
|
466
|
+
*
|
|
467
|
+
* @param name - The package name as referenced (import-style or canonical)
|
|
468
|
+
* @param anchorDir - Directory the workspace is resolved from (the export cwd)
|
|
469
|
+
* @param owner - The referencing task/function name, for error messages
|
|
470
|
+
* @returns The workspace root and the closure's directories, sorted, or null
|
|
471
|
+
* when there is no uv workspace above `anchorDir` or the name is not a
|
|
472
|
+
* local member
|
|
473
|
+
*/
|
|
474
|
+
export function pythonMemberSources(name, anchorDir, owner) {
|
|
475
|
+
const found = findUvLock(anchorDir, owner);
|
|
476
|
+
if (!found)
|
|
477
|
+
return null;
|
|
478
|
+
const { root, lock } = found;
|
|
479
|
+
const canon = canonicalPythonName(name);
|
|
480
|
+
const subject = (lock.package ?? []).find((p) => canonicalPythonName(p.name) === canon);
|
|
481
|
+
if (subject === undefined || localSource(root, subject.source) === null)
|
|
482
|
+
return null;
|
|
483
|
+
// Through registry packages too: one may depend on a local package
|
|
484
|
+
const dirs = new Set();
|
|
485
|
+
for (const { packages } of lockWalk(lock, [{ name: subject.name }], (pkg) => localSource(root, pkg.source) !== null)) {
|
|
486
|
+
for (const pkg of packages) {
|
|
487
|
+
const local = localSource(root, pkg.source);
|
|
488
|
+
if (local !== null)
|
|
489
|
+
dirs.add(local.dir);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
return { root, dirs: [...dirs].sort() };
|
|
493
|
+
}
|
|
494
|
+
//# 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,EAA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AAE,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;QACrH,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;YAC5C,IAAI,KAAK,KAAK,IAAI;gBAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;AAC1C,CAAC"}
|
package/dist/src/export.d.ts.map
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/src/export.js
CHANGED
|
@@ -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
|
-
|
|
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);
|