pyfig 0.4.0 → 0.6.0
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/README.md +19 -16
- package/SECURITY.md +2 -2
- package/dist/cjs/index.js +282 -97
- package/dist/cjs/index.js.map +8 -7
- package/dist/cjs/sync-resolver.js +279 -93
- package/dist/cjs/sync-resolver.js.map +8 -7
- package/dist/cli.js +4 -6
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +2 -2
- package/dist/config.d.ts +10 -14
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +18 -29
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pep440.d.ts +12 -0
- package/dist/pep440.d.ts.map +1 -0
- package/dist/pep440.js +21 -0
- package/dist/pep440.js.map +1 -0
- package/dist/probes.d.ts +1 -1
- package/dist/probes.d.ts.map +1 -1
- package/dist/probes.js +15 -7
- package/dist/probes.js.map +1 -1
- package/dist/provision.d.ts +2 -2
- package/dist/provision.d.ts.map +1 -1
- package/dist/provision.js +254 -58
- package/dist/provision.js.map +1 -1
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -16,7 +16,8 @@ bun add pyfig
|
|
|
16
16
|
import { createPyfig } from 'pyfig';
|
|
17
17
|
|
|
18
18
|
const pyfig = createPyfig({
|
|
19
|
-
|
|
19
|
+
requiresPython: '>=3.11,<4',
|
|
20
|
+
requiresUv: '>=0.10,<1',
|
|
20
21
|
requireEmbedding: true,
|
|
21
22
|
requireGil: true,
|
|
22
23
|
});
|
|
@@ -36,7 +37,7 @@ await pyfig.uv(
|
|
|
36
37
|
);
|
|
37
38
|
```
|
|
38
39
|
|
|
39
|
-
`prepare()` accepts
|
|
40
|
+
`prepare()` accepts PEP 508 dependency specifiers plus optional `extras`, `groups`, or `allExtras`. If the project has a `pyproject.toml`, uv resolves that read-only input together with a temporary dependency file. Pyfig installs the resolved result with `uv pip install -r`, which preserves unrelated packages. Temporary inputs are created outside the repository and removed afterward.
|
|
40
41
|
|
|
41
42
|
The same uv-only surface handles direct commands:
|
|
42
43
|
|
|
@@ -89,19 +90,19 @@ await pyfig.prepare(
|
|
|
89
90
|
Resolution follows the equivalent of:
|
|
90
91
|
|
|
91
92
|
```sh
|
|
92
|
-
uv pip compile pyproject.toml /temporary/runtime-
|
|
93
|
+
uv pip compile pyproject.toml /temporary/runtime-dependencies.txt \
|
|
93
94
|
--extra postgres --group runtime \
|
|
94
95
|
--python /selected/venv/python \
|
|
95
|
-
--output-file /temporary/resolved-
|
|
96
|
+
--output-file /temporary/resolved-dependencies.txt
|
|
96
97
|
|
|
97
98
|
uv pip install \
|
|
98
99
|
--python /selected/venv/python \
|
|
99
|
-
-r /temporary/resolved-
|
|
100
|
+
-r /temporary/resolved-dependencies.txt
|
|
100
101
|
```
|
|
101
102
|
|
|
102
|
-
When no `pyproject.toml` exists, only the temporary
|
|
103
|
+
When no `pyproject.toml` exists, only the temporary dependency input is compiled. Extras and dependency groups require an existing `pyproject.toml`. Pyfig does not use `uv add` or `uv pip sync`: the former would edit project metadata, while the latter could remove unrelated packages from the venv.
|
|
103
104
|
|
|
104
|
-

|
|
105
106
|
|
|
106
107
|
[Mermaid source](docs/diagrams/runtime-dependencies.mmd)
|
|
107
108
|
|
|
@@ -121,11 +122,11 @@ Set `projectRoot` explicitly in reusable libraries and unusual workspace layouts
|
|
|
121
122
|
| Export | Responsibility |
|
|
122
123
|
| --- | --- |
|
|
123
124
|
| `createPyfig(options)` | Create a scoped client with memoized base preparation. |
|
|
124
|
-
| `client.prepare(
|
|
125
|
+
| `client.prepare(dependencies?, options?)` | Select a venv and optionally resolve/install runtime dependencies. |
|
|
125
126
|
| `client.pythonInfo()` | Return the selected interpreter and embedding metadata. |
|
|
126
127
|
| `client.uvInfo()` | Return the selected uv executable and version. |
|
|
127
128
|
| `client.uv()` / `client.uvSync()` | Spawn uv and pin pip/run commands to the selected venv. |
|
|
128
|
-
| `ensureEnvironment(options?,
|
|
129
|
+
| `ensureEnvironment(options?, dependencies?, dependencyOptions?)` | Standalone preparation API. |
|
|
129
130
|
| `ensureUv(options?)` | Prefer existing uv, otherwise bootstrap verified uv when allowed. |
|
|
130
131
|
| `uvSpawn()` / `uvSpawnSync()` | Standalone uv spawn API. |
|
|
131
132
|
| `resolveProjectRoot(start?)` | Resolve the nearest Git root without reading manifests. |
|
|
@@ -136,13 +137,14 @@ The package exposes matching ESM and CommonJS entry points. Probe, download, loc
|
|
|
136
137
|
|
|
137
138
|
Precedence is API or CLI option, environment variable, then default.
|
|
138
139
|
|
|
140
|
+
`requiresPython` and `requiresUv` use PEP 440 specifiers. Comma-separated clauses, compatible releases (`~=`), exclusions (`!=`), wildcard equality, arbitrary equality (`===`), and pre-release versions are supported. For example: `requiresPython: '>=3.10,!=3.12.*,<4'` and `requiresUv: '==0.13.*'`. Pyfig reuses a compatible installed or cached uv first. When installation is necessary, it resolves the greatest published uv release satisfying `requiresUv` and containing the required platform assets.
|
|
141
|
+
|
|
139
142
|
| API option | Environment variable | Default |
|
|
140
143
|
| --- | --- | --- |
|
|
141
144
|
| `python` | `PYFIG_PYTHON` | uv discovery |
|
|
142
|
-
| `
|
|
145
|
+
| `requiresPython` | `PYFIG_REQUIRES_PYTHON` | `>=3.10,<4` |
|
|
143
146
|
| `managedPython` | `PYFIG_MANAGED_PYTHON` | `3.12` |
|
|
144
|
-
| `
|
|
145
|
-
| `uvRange` | `PYFIG_UV_RANGE` | `>=0.10.0 <1.0.0` |
|
|
147
|
+
| `requiresUv` | `PYFIG_REQUIRES_UV` | `>=0.10,<1` |
|
|
146
148
|
| `cacheDir` | `PYFIG_HOME` | OS cache directory |
|
|
147
149
|
| `projectRoot` | `PYFIG_PROJECT_ROOT` | `INIT_CWD`, Git root, or current directory |
|
|
148
150
|
| `requireEmbedding` | `PYFIG_REQUIRE_EMBEDDING` | `false` |
|
|
@@ -163,7 +165,8 @@ Set `PYFIG_UV` to choose an explicit uv executable. Set `PYFIG_AUTO_INSTALL=0` o
|
|
|
163
165
|
```sh
|
|
164
166
|
bunx --bun pyfig
|
|
165
167
|
bunx --bun pyfig --check
|
|
166
|
-
bunx --bun pyfig --python
|
|
168
|
+
bunx --bun pyfig --requires-python '>=3.12,<3.14'
|
|
169
|
+
bunx --bun pyfig --requires-uv '>=0.12,<1'
|
|
167
170
|
bunx --bun pyfig --require-embedding --require-gil
|
|
168
171
|
bunx --bun pyfig --project-root /path/to/repository
|
|
169
172
|
bunx --bun pyfig --json
|
|
@@ -173,13 +176,13 @@ bunx --bun pyfig --json
|
|
|
173
176
|
|
|
174
177
|
## Concurrency and installation safety
|
|
175
178
|
|
|
176
|
-
Pyfig
|
|
179
|
+
Pyfig resolves a compatible uv release from Astral's GitHub releases, downloads that exact archive over HTTPS, verifies its adjacent SHA-256 checksum, validates the staged executable version, and atomically publishes it in Pyfig's cache. A compatible cached executable is probed locally without a network request. Release metadata is cached on disk for 24 hours; stale metadata is refreshed under a Loqkit lock and remains available as a fallback when GitHub's API is temporarily unavailable. Pyfig does not execute installer scripts or modify shell profiles.
|
|
177
180
|
|
|
178
|
-
Provisioning mutations use Loqkit's layered in-memory, worker, native-file-lock-when-available, and portable-file coordination with capability checks before and after acquisition. uv supplies its own target-environment lock for installs. Base client preparation is memoized; dependency preparation is intentionally rerun so uv can cheaply verify current inputs through its shared cache.
|
|
181
|
+
Provisioning mutations use Loqkit's layered in-memory, worker, native-file-lock-when-available, and portable-file coordination with capability checks before and after acquisition. Compatible managed uv executables are cached by resolved version; Loqkit coordinates both the `requiresUv` policy lookup and exact release publication. uv supplies its own target-environment lock for installs. Base client preparation is memoized; dependency preparation is intentionally rerun so uv can cheaply verify current inputs through its shared cache.
|
|
179
182
|
|
|
180
183
|
## Platform support
|
|
181
184
|
|
|
182
|
-
Pyfig bootstraps uv on x64 and arm64 Windows, macOS, and Linux. Linux uses Astral's static musl artifact, which also runs on glibc. Node.js 22 through 26 and Bun 1.2+ are supported. Other JavaScript runtimes may work when they provide compatible Node built-ins and process semantics.
|
|
185
|
+
Pyfig bootstraps uv on x64 and arm64 Windows, macOS, and Linux. Linux uses Astral's static musl artifact, which also runs on glibc. Node.js 22.11+ on the 22.x line, Node.js 24.10 through 26.x, and Bun 1.2+ are supported. Other JavaScript runtimes may work when they provide compatible Node built-ins and process semantics.
|
|
183
186
|
|
|
184
187
|
## Publishing
|
|
185
188
|
|
package/SECURITY.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Pyfig can download Astral uv release archives and can ask uv to download Python distributions. Automatic installation is enabled by default; set `autoInstall: false`, pass `--check`, or set `PYFIG_AUTO_INSTALL=0` when downloads are not allowed.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Pyfig resolves a uv release allowed by `requiresUv`, then fetches that exact release URL over HTTPS with bounded redirects and timeouts. GitHub release metadata is cached for 24 hours under Loqkit coordination, with validated stale metadata available if refresh fails. Pyfig verifies the adjacent SHA-256 checksum, validates the staged executable's reported version, and atomically publishes it into its cache. It never executes an installer script or modifies shell profiles or the host `PATH`. Proxy variables are honored through a per-request dispatcher without logging proxy credentials.
|
|
6
6
|
|
|
7
7
|
Provisioning uses in-process, worker, optional native advisory, and portable filesystem coordination followed by a post-lock capability check. Runtime dependency mutation uses uv's target-environment lock. Pyfig pins uv commands to the selected venv and removes configuration values that could redirect them. It reads an existing `pyproject.toml` only as a resolver input and never writes project manifests or requirements files.
|
|
8
8
|
|
|
9
|
-
Executable paths, project roots, version
|
|
9
|
+
Executable paths, project roots, version specifiers, package specifications, indexes, and proxy settings remain trusted configuration. Do not let an untrusted user choose `python`, `PYFIG_UV`, `cacheDir`, package arguments, or related environment variables in a privileged process. A checksum fetched from the same release protects transfer integrity, not a compromised upstream publisher.
|