pynect 0.2.9 → 0.2.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.
Files changed (86) hide show
  1. package/README.md +29 -34
  2. package/SECURITY.md +6 -6
  3. package/dist/cli/codegen.js +3 -3
  4. package/dist/cli/codegen.js.map +1 -1
  5. package/dist/cli/sync.d.ts.map +1 -1
  6. package/dist/cli/sync.js +38 -19
  7. package/dist/cli/sync.js.map +1 -1
  8. package/dist/config/project.d.ts +4 -54
  9. package/dist/config/project.d.ts.map +1 -1
  10. package/dist/config/project.js +56 -123
  11. package/dist/config/project.js.map +1 -1
  12. package/dist/core/isolated-worker.js +4 -4
  13. package/dist/core/isolated-worker.js.map +1 -1
  14. package/dist/core/py-proxy.d.ts +2 -1
  15. package/dist/core/py-proxy.d.ts.map +1 -1
  16. package/dist/core/py-proxy.js +24 -9
  17. package/dist/core/py-proxy.js.map +1 -1
  18. package/dist/core/py-runtime.d.ts +1 -9
  19. package/dist/core/py-runtime.d.ts.map +1 -1
  20. package/dist/core/py-runtime.js +34 -128
  21. package/dist/core/py-runtime.js.map +1 -1
  22. package/dist/core/pynect-callback.d.ts +5 -14
  23. package/dist/core/pynect-callback.d.ts.map +1 -1
  24. package/dist/core/pynect-callback.js +33 -80
  25. package/dist/core/pynect-callback.js.map +1 -1
  26. package/dist/env/project-environment.d.ts +9 -30
  27. package/dist/env/project-environment.d.ts.map +1 -1
  28. package/dist/env/project-environment.js +32 -217
  29. package/dist/env/project-environment.js.map +1 -1
  30. package/dist/env/python.d.ts +16 -0
  31. package/dist/env/python.d.ts.map +1 -0
  32. package/dist/env/python.js +9 -0
  33. package/dist/env/python.js.map +1 -0
  34. package/dist/index.d.ts +8 -29
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +5 -39
  37. package/dist/index.js.map +1 -1
  38. package/dist/types/config.d.ts +8 -85
  39. package/dist/types/config.d.ts.map +1 -1
  40. package/dist/types/config.js +11 -15
  41. package/dist/types/config.js.map +1 -1
  42. package/dist/types/index.d.ts +1 -1
  43. package/dist/types/index.d.ts.map +1 -1
  44. package/dist/types/index.js.map +1 -1
  45. package/package.json +3 -4
  46. package/prebuilds/darwin-arm64/pynect-prebuild.json +1 -1
  47. package/prebuilds/darwin-arm64/pynect_addon.node +0 -0
  48. package/prebuilds/darwin-x64/pynect-prebuild.json +1 -1
  49. package/prebuilds/darwin-x64/pynect_addon.node +0 -0
  50. package/prebuilds/linux-arm64/pynect-prebuild.json +1 -1
  51. package/prebuilds/linux-x64/pynect-prebuild.json +1 -1
  52. package/prebuilds/win32-arm64/pynect-prebuild.json +1 -1
  53. package/prebuilds/win32-arm64/pynect_addon.node +0 -0
  54. package/prebuilds/win32-x64/pynect-prebuild.json +1 -1
  55. package/prebuilds/win32-x64/pynect_addon.node +0 -0
  56. package/python/pynect_runtime.py +1 -1
  57. package/scripts/build-native.js +4 -3
  58. package/scripts/postinstall.js +2 -2
  59. package/scripts/python.js +33 -0
  60. package/scripts/smoke-python-boundary.js +38 -57
  61. package/dist/env/executables.d.ts +0 -3
  62. package/dist/env/executables.d.ts.map +0 -1
  63. package/dist/env/executables.js +0 -14
  64. package/dist/env/executables.js.map +0 -1
  65. package/dist/env/package-installer.d.ts +0 -232
  66. package/dist/env/package-installer.d.ts.map +0 -1
  67. package/dist/env/package-installer.js +0 -615
  68. package/dist/env/package-installer.js.map +0 -1
  69. package/dist/env/pyfig-adapter.d.ts +0 -38
  70. package/dist/env/pyfig-adapter.d.ts.map +0 -1
  71. package/dist/env/pyfig-adapter.js +0 -10
  72. package/dist/env/pyfig-adapter.js.map +0 -1
  73. package/dist/env/python-detector.d.ts +0 -48
  74. package/dist/env/python-detector.d.ts.map +0 -1
  75. package/dist/env/python-detector.js +0 -182
  76. package/dist/env/python-detector.js.map +0 -1
  77. package/dist/env/python-provisioner.d.ts +0 -16
  78. package/dist/env/python-provisioner.d.ts.map +0 -1
  79. package/dist/env/python-provisioner.js +0 -42
  80. package/dist/env/python-provisioner.js.map +0 -1
  81. package/dist/env/venv-manager.d.ts +0 -56
  82. package/dist/env/venv-manager.d.ts.map +0 -1
  83. package/dist/env/venv-manager.js +0 -160
  84. package/dist/env/venv-manager.js.map +0 -1
  85. package/scripts/pyfig.js +0 -142
  86. package/scripts/python-provisioner.js +0 -23
@@ -6,5 +6,5 @@
6
6
  "pythonAbi": "cp310-abi3",
7
7
  "pythonLibraryName": "python3.dll",
8
8
  "napi": 8,
9
- "nativeFingerprint": "sha256:5013f340cf0381386cc99a1837107a2c057d26417de63c5f1690639b2547e5a8"
9
+ "nativeFingerprint": "sha256:9cfa5f1c9ffc2988456c3560130f8e2a4bc8df0755003cea0645ccc4f13a1d37"
10
10
  }
@@ -433,7 +433,7 @@ def _make_error(exc_type: str, message: str, tb: str) -> Dict[str, Any]:
433
433
  # Diagnostic helpers
434
434
 
435
435
  def get_python_info() -> Dict[str, Any]:
436
- """Return basic Python interpreter information (used by PythonDetector)."""
436
+ """Return basic information about the embedded Python interpreter."""
437
437
  import platform
438
438
  return {
439
439
  "version": sys.version,
@@ -3,16 +3,17 @@
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
5
  const { spawnSync } = require('child_process');
6
- const { ensurePynectPython } = require('./pyfig');
6
+ const { preparePython } = require('./python');
7
7
 
8
8
  const ROOT = path.resolve(__dirname, '..');
9
9
 
10
10
  async function main() {
11
11
  const projectRoot = process.env.PYNECT_PROJECT_ROOT || process.env.INIT_CWD || ROOT;
12
- const { python } = await ensurePynectPython({
12
+ const { environment } = await preparePython({
13
13
  projectRoot,
14
- pythonPath: process.env.PYNECT_PYTHON,
14
+ python: process.env.PYNECT_PYTHON,
15
15
  });
16
+ const { python } = environment;
16
17
  const embedding = python.embedding;
17
18
  const stableAbiLibrary = process.platform === 'win32'
18
19
  ? embedding.stableAbiLibraryPath || path.join(embedding.libraryDirectory, 'python3.lib')
@@ -29,8 +29,8 @@ async function main() {
29
29
 
30
30
  const result = await syncProject({ projectRoot });
31
31
  console.log(
32
- `[pynect] Synchronized ${result.plan.requirements.length} Python requirement(s) ` +
33
- `with uv in ${path.dirname(result.plan.stateFile)}.`,
32
+ `[pynect] Prepared ${result.plan.dependencies.length} Python dependency constraint(s) ` +
33
+ `with Pyfig in ${result.environment.python.virtualEnvironment}.`,
34
34
  );
35
35
  }
36
36
 
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const { Python, resolveProjectRoot } = require('pyfig');
5
+
6
+ function projectRoot(explicit) {
7
+ const hint = explicit || process.env.PYNECT_PROJECT_ROOT || process.env.INIT_CWD;
8
+ return hint ? path.resolve(hint) : resolveProjectRoot(process.cwd());
9
+ }
10
+
11
+ function createPython(options = {}) {
12
+ return new Python({
13
+ ...options,
14
+ projectRoot: projectRoot(options.projectRoot),
15
+ requireEmbedding: true,
16
+ requireGil: true,
17
+ env: options.env ? { ...process.env, ...options.env } : process.env,
18
+ });
19
+ }
20
+
21
+ async function preparePython(options = {}) {
22
+ const runtime = createPython(options);
23
+ const environment = await runtime.prepare();
24
+ if (!environment.python.embedding) {
25
+ throw new Error(
26
+ `Python ${environment.python.version} at ${environment.python.executable} is missing ` +
27
+ 'Python.h or its CPython embedding library.',
28
+ );
29
+ }
30
+ return { runtime, environment };
31
+ }
32
+
33
+ module.exports = { createPython, preparePython, projectRoot };
@@ -3,47 +3,37 @@
3
3
  process.env.PYNECT_PREFER_LOCAL ??= '1';
4
4
 
5
5
  const path = require('path');
6
- const { ensurePynectEnvironment } = require('./pyfig');
6
+ const { preparePython } = require('./python');
7
7
 
8
8
  const ROOT = path.resolve(__dirname, '..');
9
9
 
10
10
  async function main() {
11
- const { client, environment } = await ensurePynectEnvironment({ projectRoot: ROOT });
11
+ const { runtime, environment } = await preparePython({ projectRoot: ROOT });
12
12
  const { python } = environment;
13
13
  const expected = normalize(python.executable);
14
14
  const pynect = require('../dist');
15
15
 
16
- const detector = new pynect.PythonDetector({ projectRoot: ROOT });
17
- const detected = await detector.detect();
18
- assertSamePython(detected.executable, expected, 'PythonDetector');
19
- const probed = detector.probe(detected.executable);
20
- if (!probed) throw new Error('PythonDetector could not probe the selected repository Python.');
21
- assertSamePython(probed.executable, expected, 'PythonDetector.probe');
22
-
23
- const selected = client.pythonSync(
24
- ['-c', 'import sys; print(sys.executable)'],
16
+ const selected = runtime.uvSync(
17
+ ['run', '--', 'python', '-c', 'import sys; print(sys.executable)'],
25
18
  { encoding: 'utf8' },
26
19
  );
27
- assertSuccess(selected, 'PyfigClient.pythonSync');
28
- assertSamePython(selected.stdout.trim(), expected, 'PyfigClient.pythonSync');
29
-
30
- const pip = client.pipSync(['list', '--format', 'json'], { encoding: 'utf8' });
31
- assertSuccess(pip, 'PyfigClient.pipSync');
20
+ assertSuccess(selected, 'Pyfig Python uvSync run');
21
+ assertSamePython(selected.stdout.trim(), expected, 'Pyfig Python uvSync run');
32
22
 
33
- const uvPip = client.uvSync(
23
+ const uvPip = runtime.uvSync(
34
24
  ['pip', 'list', '--format', 'json'],
35
25
  { encoding: 'utf8' },
36
26
  );
37
27
  assertSuccess(uvPip, 'PyfigClient.uvSync pip');
38
28
 
39
- const inspector = client.pythonSync(
40
- [path.join(ROOT, 'python', 'type_inspector.py'), 'json'],
29
+ const inspector = runtime.uvSync(
30
+ ['run', '--', 'python', path.join(ROOT, 'python', 'type_inspector.py'), 'json'],
41
31
  { encoding: 'utf8' },
42
32
  );
43
33
  assertSuccess(inspector, 'codegen inspector');
44
34
  JSON.parse(inspector.stdout);
45
- const callbackInspection = client.pythonSync(
46
- [path.join(ROOT, 'python', 'type_inspector.py'), 'pynect_callback_fixture'],
35
+ const callbackInspection = runtime.uvSync(
36
+ ['run', '--', 'python', path.join(ROOT, 'python', 'type_inspector.py'), 'pynect_callback_fixture'],
47
37
  {
48
38
  encoding: 'utf8',
49
39
  env: {
@@ -59,8 +49,8 @@ async function main() {
59
49
  throw new Error(`Callback annotation was inspected as ${String(inspectedCallback)}.`);
60
50
  }
61
51
 
62
- const worker = client.pythonSync(
63
- [path.join(ROOT, 'python', 'isolated_worker.py')],
52
+ const worker = runtime.uvSync(
53
+ ['run', '--', 'python', path.join(ROOT, 'python', 'isolated_worker.py')],
64
54
  {
65
55
  encoding: 'utf8',
66
56
  input: `${JSON.stringify({
@@ -87,7 +77,7 @@ async function main() {
87
77
  projectRoot: ROOT,
88
78
  allowUnsafeCode: true,
89
79
  logLevel: 'error',
90
- pythonPath_extra: [path.join(ROOT, 'tests', 'fixtures')],
80
+ pythonModulePaths: [path.join(ROOT, 'tests', 'fixtures')],
91
81
  threadPool: { size: 1 },
92
82
  callbacks: { maxDepth: 2 },
93
83
  });
@@ -95,43 +85,34 @@ async function main() {
95
85
  const embedded = await pynect.py.eval('__import__("sys").executable');
96
86
  assertSamePython(embedded, expected, 'embedded CPython');
97
87
  const fixture = await pynect.importModule('pynect_callback_fixture');
88
+ const asyncCallback = async value => {
89
+ await Promise.resolve();
90
+ return value * 3;
91
+ };
92
+ if (await fixture.invoke(asyncCallback, 4) !== 12) {
93
+ throw new Error('Async JavaScript callback returned the wrong value.');
94
+ }
95
+ await fixture.retain(asyncCallback);
98
96
  await assertRejects(
99
- () => fixture.invoke((value) => value, 1),
100
- /ctx\.callback\(\)/,
101
- 'unregistered callback',
97
+ () => fixture.invoke_retained(4),
98
+ /callback.*(?:disposed|registered)|(?:disposed|registered).*callback/i,
99
+ 'settled callback lifetime',
102
100
  );
103
101
 
104
- let disposedCallback;
105
- await pynect.withCallbacks(async ctx => {
106
- const asyncCallback = ctx.callback(async value => {
107
- await Promise.resolve();
108
- return value * 3;
109
- });
110
- if (await fixture.invoke(asyncCallback, 4) !== 12) {
111
- throw new Error('Async JavaScript callback returned the wrong value.');
112
- }
113
-
114
- const reentrantCallback = ctx.callback(async value => fixture.double(value));
115
- if (await fixture.invoke(reentrantCallback, 5) !== 10) {
116
- throw new Error('Reentrant JavaScript callback returned the wrong value.');
117
- }
118
-
119
- let recursiveCallback;
120
- recursiveCallback = ctx.callback(async depth => {
121
- if (depth <= 0) return 0;
122
- return fixture.invoke(recursiveCallback, depth - 1);
123
- });
124
- await assertRejects(
125
- () => fixture.invoke(recursiveCallback, 2),
126
- /recursion depth 3 exceeds the configured maximum of 2/,
127
- 'callback recursion limit',
128
- );
129
- disposedCallback = asyncCallback;
130
- });
102
+ const reentrantCallback = async value => fixture.double(value);
103
+ if (await fixture.invoke(reentrantCallback, 5) !== 10) {
104
+ throw new Error('Reentrant JavaScript callback returned the wrong value.');
105
+ }
106
+
107
+ let recursiveCallback;
108
+ recursiveCallback = async depth => {
109
+ if (depth <= 0) return 0;
110
+ return fixture.invoke(recursiveCallback, depth - 1);
111
+ };
131
112
  await assertRejects(
132
- () => fixture.invoke(disposedCallback, 1),
133
- /disposed/,
134
- 'callback context disposal',
113
+ () => fixture.invoke(recursiveCallback, 2),
114
+ /recursion depth 3 exceeds the configured maximum of 2/,
115
+ 'callback recursion limit',
135
116
  );
136
117
  } finally {
137
118
  await pynect.shutdown();
@@ -1,3 +0,0 @@
1
- export declare function isPythonModuleName(value: string): boolean;
2
- export declare function assertPythonPackageSpec(spec: string): void;
3
- //# sourceMappingURL=executables.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"executables.d.ts","sourceRoot":"","sources":["../../src/env/executables.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAI1D"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isPythonModuleName = isPythonModuleName;
4
- exports.assertPythonPackageSpec = assertPythonPackageSpec;
5
- const PYTHON_MODULE = /^[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*$/u;
6
- function isPythonModuleName(value) {
7
- return PYTHON_MODULE.test(value);
8
- }
9
- function assertPythonPackageSpec(spec) {
10
- if (!spec || spec.startsWith('-') || /[\0\r\n]/u.test(spec)) {
11
- throw new TypeError(`Unsafe Python package specifier: ${JSON.stringify(spec)}`);
12
- }
13
- }
14
- //# sourceMappingURL=executables.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"executables.js","sourceRoot":"","sources":["../../src/env/executables.ts"],"names":[],"mappings":";;AAEA,gDAEC;AAED,0DAIC;AAVD,MAAM,aAAa,GAAG,oCAAoC,CAAC;AAE3D,SAAgB,kBAAkB,CAAC,KAAa;IAC9C,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAED,SAAgB,uBAAuB,CAAC,IAAY;IAClD,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5D,MAAM,IAAI,SAAS,CAAC,oCAAoC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClF,CAAC;AACH,CAAC"}
@@ -1,232 +0,0 @@
1
- /**
2
- * pynect - PackageInstaller
3
- *
4
- * Repository-venv package installer. All Python and pip execution is routed
5
- * through Pyfig so standalone or system pip can never be selected.
6
- *
7
- * Responsibilities
8
- *
9
- * - Resolve the "import name" from the "install name" (e.g. scikit-learn -> sklearn)
10
- * - Check whether a package is already importable before trying to install it
11
- * - Run pip with the correct flags (--quiet, --no-warn-script-location, etc.)
12
- * - Support per-package version constraints ("numpy>=1.24,<2")
13
- * - Support extras ("uvicorn[standard]")
14
- * - Support index overrides (corporate PyPI mirrors, --extra-index-url)
15
- * - Upgrade existing installations when requested
16
- * - Emit structured progress events via EventEmitter
17
- * - Retry transient network failures up to N times with back-off
18
- * - Parse pip's JSON output (--report) for installed metadata when available
19
- * - Return full InstallResult objects describing what happened
20
- *
21
- * Usage
22
- *
23
- * const installer = new PackageInstaller({ pythonExecutable: '/usr/bin/python3' });
24
- *
25
- * const result = await installer.install(['pandas', 'numpy>=1.24', 'torch']);
26
- * console.log(result.installed); // ['pandas==2.2.2', 'numpy==1.26.4', ...]
27
- *
28
- * installer.on('progress', (ev) => console.log(ev.package, ev.status));
29
- */
30
- import { EventEmitter } from 'events';
31
- /** A single package specification that can be installed. */
32
- export interface PackageSpec {
33
- /** Raw pip spec: "pandas", "numpy>=1.24,<2", "torch==2.3.0+cu121" */
34
- spec: string;
35
- /**
36
- * Override the import (module) name used to test whether the package is
37
- * already importable. Defaults to the auto-detected mapping.
38
- * e.g. spec="scikit-learn" -> importName="sklearn"
39
- */
40
- importName?: string;
41
- /** Force reinstall even if already importable. */
42
- forceReinstall?: boolean;
43
- /** Install pre-release versions */
44
- preRelease?: boolean;
45
- }
46
- /** Options passed to the PackageInstaller constructor. */
47
- export interface PackageInstallerOptions {
48
- /** Python executable to use for pip invocations. Required. */
49
- pythonExecutable: string;
50
- /**
51
- * Extra --index-url override (corporate mirror etc.)
52
- * If omitted, pip uses its default index.
53
- */
54
- indexUrl?: string;
55
- /**
56
- * Additional --extra-index-url entries (e.g. CUDA wheels).
57
- * Supports multiple URLs.
58
- */
59
- extraIndexUrls?: string[];
60
- /**
61
- * Trusted hosts (--trusted-host) required when using HTTP mirrors.
62
- */
63
- trustedHosts?: string[];
64
- /**
65
- * Maximum retry attempts for transient network errors. Default: 3.
66
- */
67
- maxRetries?: number;
68
- /**
69
- * Base delay (ms) between retry attempts. Each retry doubles. Default: 1000.
70
- */
71
- retryDelayMs?: number;
72
- /**
73
- * Working directory for pip. Defaults to process.cwd().
74
- */
75
- cwd?: string;
76
- /**
77
- * Additional environment variables to inject into pip subprocess.
78
- */
79
- env?: Record<string, string>;
80
- /**
81
- * Timeout (ms) per pip invocation. Default: 300 000 (5 min).
82
- */
83
- timeoutMs?: number;
84
- /**
85
- * If true, pass --quiet to suppress pip chatter. Default: true.
86
- */
87
- quiet?: boolean;
88
- /**
89
- * If true, pass --upgrade to pip for already-installed packages. Default: false.
90
- */
91
- upgrade?: boolean;
92
- }
93
- /** Status of a single package during/after installation. */
94
- export type PackageStatus = 'already_installed' | 'installing' | 'installed' | 'upgraded' | 'failed' | 'skipped';
95
- /** Progress event emitted during installation. */
96
- export interface InstallProgressEvent {
97
- package: string;
98
- status: PackageStatus;
99
- version?: string;
100
- error?: string;
101
- }
102
- /** Aggregated result of an install() call. */
103
- export interface InstallResult {
104
- /** Packages that were successfully installed or upgraded (with versions). */
105
- installed: string[];
106
- /** Packages that were already present and did not need installation. */
107
- alreadyInstalled: string[];
108
- /** Packages that failed to install. */
109
- failed: Array<{
110
- spec: string;
111
- error: string;
112
- }>;
113
- /** Whether every requested package ended up available. */
114
- success: boolean;
115
- /** Combined stdout/stderr from pip (useful for debugging). */
116
- output: string;
117
- }
118
- /** Metadata returned by `pip show`. */
119
- export interface PackageMetadata {
120
- name: string;
121
- version: string;
122
- location: string;
123
- requires: string[];
124
- requiredBy: string[];
125
- summary: string;
126
- }
127
- declare const INSTALL_TO_IMPORT: Record<string, string>;
128
- /**
129
- * Extract the bare package name from a spec string.
130
- * "numpy>=1.24,<2" -> "numpy"
131
- * "torch==2.3.0+cu121" -> "torch"
132
- * "uvicorn[standard]" -> "uvicorn"
133
- */
134
- declare function extractPackageName(spec: string): string;
135
- /**
136
- * Determine the Python import name for a given install spec.
137
- */
138
- declare function resolveImportName(spec: string, override?: string): string;
139
- export declare class PackageInstaller extends EventEmitter {
140
- private readonly _opts;
141
- private readonly _pyfig;
142
- constructor(options: PackageInstallerOptions);
143
- /**
144
- * Install one or more packages.
145
- *
146
- * @param packages - Array of pip spec strings or PackageSpec objects.
147
- * @returns InstallResult describing what happened to each package.
148
- */
149
- install(packages: Array<string | PackageSpec>): Promise<InstallResult>;
150
- /**
151
- * Install a single package and return the installed version string.
152
- * Throws on failure.
153
- */
154
- installOne(spec: string, options?: Partial<PackageSpec>): Promise<string>;
155
- /**
156
- * Upgrade a package to the latest version.
157
- */
158
- upgrade(spec: string): Promise<string>;
159
- /**
160
- * Uninstall one or more packages.
161
- */
162
- uninstall(packages: string[]): Promise<void>;
163
- /**
164
- * Check whether a package is currently importable by Python.
165
- */
166
- isImportable(importName: string): boolean;
167
- /**
168
- * Check whether a package (by install name) is installed and return
169
- * its version string, or null if not installed.
170
- */
171
- getVersion(packageName: string): string | null;
172
- /**
173
- * Return full metadata for an installed package.
174
- */
175
- getMetadata(packageName: string): PackageMetadata | null;
176
- /**
177
- * List all packages installed in the current Python environment.
178
- */
179
- listInstalled(): Array<{
180
- name: string;
181
- version: string;
182
- }>;
183
- /**
184
- * Check which packages from the given list are missing.
185
- *
186
- * @param packages - Array of pip spec strings.
187
- * @returns Array of spec strings that are NOT currently importable.
188
- */
189
- getMissing(packages: string[]): string[];
190
- /**
191
- * Ensure pip itself is up-to-date.
192
- */
193
- upgradePip(): Promise<void>;
194
- /**
195
- * Run `python -c "import X"` to test importability.
196
- * This is faster than `pip show` for the common case.
197
- */
198
- private _isImportable;
199
- /**
200
- * Build pip install argument list.
201
- */
202
- private _buildPipArgs;
203
- /**
204
- * Execute pip install with retry logic.
205
- */
206
- private _pipInstall;
207
- /**
208
- * Spawn pip and collect output.
209
- */
210
- private _runPip;
211
- /** Merge per-package results into the aggregate InstallResult. */
212
- private _mergeResults;
213
- /** Emit a typed progress event. */
214
- private _emit;
215
- /** Parse `pip show` output into PackageMetadata. */
216
- private _parsePipShow;
217
- }
218
- /**
219
- * Create an installer seeded from a system Python, while targeting the
220
- * application environment selected by Pyfig.
221
- */
222
- export declare function createSystemInstaller(options?: Partial<Omit<PackageInstallerOptions, 'pythonExecutable'>>): PackageInstaller;
223
- /**
224
- * Create a PackageInstaller tied to a specific virtualenv directory.
225
- */
226
- export declare function createVenvInstaller(venvDir: string, options?: Partial<Omit<PackageInstallerOptions, 'pythonExecutable'>>): PackageInstaller;
227
- /**
228
- * Resolve the import name from a pip install spec using the built-in table.
229
- * Exposed for testing and introspection.
230
- */
231
- export { resolveImportName, extractPackageName, INSTALL_TO_IMPORT };
232
- //# sourceMappingURL=package-installer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package-installer.d.ts","sourceRoot":"","sources":["../../src/env/package-installer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAWtC,4DAA4D;AAC5D,MAAM,WAAW,WAAW;IAC1B,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mCAAmC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,0DAA0D;AAC1D,MAAM,WAAW,uBAAuB;IACtC,8DAA8D;IAC9D,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,4DAA4D;AAC5D,MAAM,MAAM,aAAa,GACrB,mBAAmB,GACnB,YAAY,GACZ,WAAW,GACX,UAAU,GACV,QAAQ,GACR,SAAS,CAAC;AAEd,kDAAkD;AAClD,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,M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