fastws-cli 0.0.39__tar.gz → 0.0.40__tar.gz
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.
- {fastws_cli-0.0.39/fastws_cli.egg-info → fastws_cli-0.0.40}/PKG-INFO +24 -12
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/README.md +23 -11
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/fastws/__init__.py +2 -1
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/fastws/build_backend.py +9 -4
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/fastws/core.py +282 -48
- {fastws_cli-0.0.39 → fastws_cli-0.0.40/fastws_cli.egg-info}/PKG-INFO +24 -12
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/tests/test_build.py +0 -40
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/tests/test_build_backend.py +2 -15
- fastws_cli-0.0.40/tests/test_setup.py +35 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/tests/test_sync.py +25 -6
- fastws_cli-0.0.39/tests/test_setup.py +0 -15
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/LICENSE +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/fastws/_toml.py +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/fastws/cargo.py +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/fastws/integrate.py +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/fastws/news.py +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/fastws/procs.py +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/fastws/releases.py +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/fastws/store.py +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/fastws/timelock.py +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/fastws_cli.egg-info/SOURCES.txt +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/fastws_cli.egg-info/dependency_links.txt +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/fastws_cli.egg-info/entry_points.txt +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/fastws_cli.egg-info/requires.txt +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/fastws_cli.egg-info/top_level.txt +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/pyproject.toml +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/setup.cfg +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/tests/test_integrate.py +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/tests/test_news.py +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/tests/test_procs.py +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/tests/test_releases.py +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/tests/test_store.py +0 -0
- {fastws_cli-0.0.39 → fastws_cli-0.0.40}/tests/test_timelock.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastws-cli
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.40
|
|
4
4
|
Summary: Fast workspace tools for multi-repo management
|
|
5
5
|
Author: Jeremy Howard
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -103,7 +103,7 @@ Keep `repos.txt` tracked in the workspace Git repo. Put personal additions in a
|
|
|
103
103
|
|
|
104
104
|
`--repos-file myrepos.txt` uses `myrepos-local.txt` alongside it. Either list may be absent. Removing a repo from the baseline does not delete its checkout. The next sync discovers an existing root checkout as a personal addition unless `[tool.fastws].exclude` matches its path. External checkouts also remain on disk; add them to the local list to keep managing them.
|
|
105
105
|
|
|
106
|
-
The workspace `pyproject.toml` is local generated state. `ws-sync` creates it from the tracked `pyproject.tmpl` when available, or generates a minimal one, then maintains it while preserving personal settings except for the managed repo extras, workspace exclusions,
|
|
106
|
+
The workspace `pyproject.toml` is local generated state. `ws-sync` creates it from the tracked `pyproject.tmpl` when available, or generates a minimal one, then maintains it while preserving personal settings except for the managed repo extras, workspace exclusions, build-isolation list, and `metadata-only` backend config settings. The template supplies starting defaults only: later template edits do not overwrite existing configuration. Ignore these files in the workspace repo (not in its member repos):
|
|
107
107
|
|
|
108
108
|
```gitignore
|
|
109
109
|
/repos-local.txt
|
|
@@ -140,16 +140,28 @@ echo source ~/aai-ws/.venv/bin/activate >> ~/.bashrc
|
|
|
140
140
|
|
|
141
141
|
### `ws-setup`
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
Bootstrap a new workspace, or check an existing workspace and complete any missing toolchain and `sccache` setup.
|
|
144
144
|
|
|
145
145
|
```bash
|
|
146
|
-
ws-setup
|
|
147
|
-
ws-setup
|
|
148
|
-
ws-setup
|
|
146
|
+
ws-setup # check/configure the active workspace
|
|
147
|
+
ws-setup --workspace ~/aai-ws # check/configure a specific workspace
|
|
148
|
+
ws-setup AnswerDotAI/aai-ws ~/aai-ws # bootstrap a new workspace
|
|
149
149
|
ws-setup AnswerDotAI/private-ws ~/aai-ws --workers 8
|
|
150
|
+
ws-setup owner/workspace ~/my-workspace --python 3.13
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
With `repo` and `dest`, `ws-setup` clones the workspace repo into a new directory (which must not exist, including as an empty directory or symlink), creates its `.venv`, installs fastws, clones the workspace repos, installs any missing Rust/WebAssembly/JavaScript prerequisites and `sccache` config, and runs that environment's `ws-sync`. It targets the new environment even when another workspace or uv tool environment is already active, and never changes shell startup files or harness settings. A failed step leaves the checkout in place for inspection.
|
|
154
|
+
|
|
155
|
+
With no `repo`, `ws-setup` inspects the existing workspace and completes any missing steps idempotently: installing `rustup` and `wasm32-unknown-unknown` when Rust/WebAssembly packages are present, installing `sccache`, installing Vite+ (`vp`) and enabling its managed `node`/`pnpm` shims when JavaScript packages are present, and configuring `sccache` when `SCCACHE_R2` is set.
|
|
156
|
+
|
|
157
|
+
Set `SCCACHE_R2` to a single R2 URL to configure multilevel local-disk + Cloudflare R2 `sccache` caching:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
export SCCACHE_R2="https://<access_key_id>:<secret_access_key>@<account_id>.r2.cloudflarestorage.com/<bucket>"
|
|
161
|
+
ws-setup
|
|
150
162
|
```
|
|
151
163
|
|
|
152
|
-
|
|
164
|
+
`ws-setup` writes `[cache.multilevel]` (`disk` + `s3`), `[cache.disk]`, `[cache.s3]`, and the workspace root under `basedirs` into the platform `sccache` config (`~/Library/Application Support/Mozilla.sccache/config` on macOS, `~/.config/sccache/config` on Linux, or `SCCACHE_CONF`), preserving existing `basedirs` and unrelated sections. Credentials are written to an isolated `[r2-sccache]` profile in `~/.aws/credentials` (leaving `[default]` untouched), and `.cargo/rustc-lock` selects that profile for `sccache`. Append `?rw_mode=READ_ONLY` for read-only tokens, omit credentials for public read-only buckets, or add `/<prefix>` after `<bucket>` for a `key_prefix`.
|
|
153
165
|
|
|
154
166
|
### `ws-clone`
|
|
155
167
|
|
|
@@ -244,7 +256,7 @@ On Unix, cooperating `cargo develop` runs take a per-project lock through compil
|
|
|
244
256
|
|
|
245
257
|
On Unix, every rustc call holds a shared `flock` on `/tmp/aai-ws-timing.lock`, through the rustc wrapper that sync writes (see `ws-sync`). A speed test that takes that lock exclusively stays apart from participating builds and test runs. A timing also holds `/tmp/aai-ws-timing.gate` while it waits for the lock and holds it, and a shared hold passes that file first, so new rustc calls and test runs wait behind the timing. Both shared and exclusive acquisition fail after 5 minutes; work never proceeds unlocked. Python code takes the same lock with `fastws.timelock.timing_lock`: `with timing_lock(exclusive=True):` around a timing, and `with timing_lock():` around a test run. Shared-inside-shared in one thread reuses its hold; each thread otherwise takes its own hold. Any nesting involving exclusive raises `RuntimeError` immediately. An exclusive hold that has waited 30 seconds prints the processes that have the lock's file open. Windows builds and tests run without this timing coordination.
|
|
246
258
|
|
|
247
|
-
Use `fastws.build_backend` as the build backend of a mixed Rust/Python project (with `fastws-cli>=0.0.29` alongside `maturin>=1.13,<2.0` in `[build-system].requires`) or a `bindings = "bin"` Rust CLI project (`fastws-cli>=0.0.39`).
|
|
259
|
+
Use `fastws.build_backend` as the build backend of a mixed Rust/Python project (with `fastws-cli>=0.0.29` alongside `maturin>=1.13,<2.0` in `[build-system].requires`) or a `bindings = "bin"` Rust CLI project (`fastws-cli>=0.0.39`). Inside a fastws workspace, `ws-sync` writes `[tool.uv.config-settings-package]` with `metadata-only = "1"` into the workspace `pyproject.toml`, so editable builds through `uv sync` install only Python metadata (and the source path when `python-source` is set) and leave Rust compilation to `cargo develop`, which installs the extension, binaries, and wheel data files. Outside the workspace, including `pip install -e .` in CI and standalone installs, editable builds receive no `metadata-only` setting, stage any `native-binaries`, and delegate to maturin so they compile normally.
|
|
248
260
|
|
|
249
261
|
For distribution wheels containing the binaries, also set `[tool.maturin].data` to a generated wheel-data directory. With `native-binaries = true`, wheel builds through the backend replace its `scripts/` subdirectory with the current Python-free binaries, then delegate packaging to maturin. Explicit profile, target and feature arguments from maturin's build settings also apply to the binaries. Without `native-binaries`, wheel builds go straight to maturin, and `[tool.maturin].data` is optional.
|
|
250
262
|
|
|
@@ -339,7 +351,7 @@ Sync also defaults `[term] quiet = true` in that file to suppress routine Cargo
|
|
|
339
351
|
|
|
340
352
|
Do not commit a `Cargo.lock` generated under these patches. Its source-less local entries cannot be resolved on another machine.
|
|
341
353
|
|
|
342
|
-
Sync writes `.cargo/rustc-lock` and makes it Cargo's `rustc-wrapper`. The script runs each rustc call holding the timing lock shared (see `cargo develop` above). Inside the lock it runs the wrapper that the config named before sync first wrote the script, where another tool set one, and otherwise `sccache` when it's installed, so unchanged compilation units are reused across the workspace's otherwise-independent Cargo target directories. Later syncs keep that inner wrapper. The script costs about 9 ms a rustc call, mostly the Python interpreter's start. If `sccache` isn't installed
|
|
354
|
+
Sync writes `.cargo/rustc-lock` and makes it Cargo's `rustc-wrapper`. The script runs each rustc call holding the timing lock shared (see `cargo develop` above). Inside the lock it runs the wrapper that the config named before sync first wrote the script, where another tool set one, and otherwise `sccache` when it's installed, so unchanged compilation units are reused across the workspace's otherwise-independent Cargo target directories. When `ws-setup` has configured an isolated `r2-sccache` AWS credentials profile for a shared R2 cache, the script passes `AWS_PROFILE=r2-sccache` to `sccache` (clearing ambient `AWS_*` keys in that child process) so it never collides with AWS CLI or `boto3`. Later syncs keep that inner wrapper. The script costs about 9 ms a rustc call, mostly the Python interpreter's start. If `sccache` isn't installed—or `SCCACHE_R2` is set without matching `sccache` config—sync warns and tells you to run `ws-setup`. On Windows, where the lock does nothing, the config keeps another tool's wrapper, or else names `sccache`.
|
|
343
355
|
|
|
344
356
|
For an isolated build workspace, `fastws.core.cargo_setup(root)` regenerates these Cargo patches and the same compiler wrapper without pulling, syncing Python or building.
|
|
345
357
|
|
|
@@ -349,7 +361,7 @@ Each sync updates `packages` in the root `pnpm-workspace.yaml` (creating it with
|
|
|
349
361
|
|
|
350
362
|
When JavaScript workspace members are present, `ws-sync` reads `vp toolchain --json -g` and populates `devDependencies["vite-plus"]` in `package.json` plus matching `vite@*` and `vitest@*` entries under `overrides` in `pnpm-workspace.yaml`. Optional tracked `pnpm-workspace.shared.yaml` and `package.json.shared` files are merged on top on every sync. Object-valued fields merge one level deep, shared values win conflicts, and arrays replace rather than concatenate. Unrelated local settings remain; removing a shared key does not delete its local value. Use these files to declare `packageManager`, `devEngines.runtime`, shared policies such as `allowBuilds`, or explicit Vite+ overrides.
|
|
351
363
|
|
|
352
|
-
Before `uv sync`, fastws regenerates `tool.uv.no-build-isolation-package` with the sorted package names of projects using `fastws.build_backend`, including external checkouts. These builds use the shared environment's `fastws-cli` and `maturin
|
|
364
|
+
Before `uv sync`, fastws regenerates `tool.uv.no-build-isolation-package` and `[tool.uv.config-settings-package]` (`metadata-only = "1"`) with the sorted package names of projects using `fastws.build_backend`, including external checkouts. These builds use the shared environment's `fastws-cli` and `maturin`, skip Rust compilation during editable installs inside the workspace, and keep metadata-only wheels separate from compiled editable wheels in uv's cache. Leave global build isolation enabled for other projects.
|
|
353
365
|
|
|
354
366
|
After `uv sync`, fastws writes `_fastws_pytest.pth` into the workspace venv's `site-packages` to default `PYTEST_DISABLE_PLUGIN_AUTOLOAD=1`, keeping pytest plugins installed for one repo from leaking into others. Repos enable the plugins they need via `-p` in `addopts` (override for a run with `PYTEST_DISABLE_PLUGIN_AUTOLOAD=""`).
|
|
355
367
|
|
|
@@ -363,9 +375,9 @@ After installation, fastws runs `pnpm -r --if-present --workspace-concurrency=<N
|
|
|
363
375
|
|
|
364
376
|
`--build-workers` sets the maximum concurrent projects within the Python-native, WebAssembly, and JavaScript build phases, defaulting to the CPU count; `--build-workers 1` runs each phase serially. It is separate from `--workers`, which controls cloning, pulling and dependency updates. Cargo keeps its own within-project parallelism, so increasing project concurrency also increases CPU and memory demand. Cargo may serialize builds that share a target directory.
|
|
365
377
|
|
|
366
|
-
When JavaScript workspaces are present, fastws requires Vite+ (`vp`) on `PATH` with managed `node` and `pnpm` shims active
|
|
378
|
+
When JavaScript workspaces are present, fastws requires Vite+ (`vp`) on `PATH` with managed `node` and `pnpm` shims active. When WebAssembly packages (`[tool.fastws].wasm-package`) are present, fastws also requires rustup's `rustc`/`cargo` proxies and the `wasm32-unknown-unknown` target. Run `ws-setup` to install or configure any missing prerequisites.
|
|
367
379
|
|
|
368
|
-
At most once per day, sync upgrades Python dependencies with `uv sync -U
|
|
380
|
+
At most once per day, sync upgrades Python dependencies with `uv sync -U`. At most once every seven days, when Rust crates are present, it updates the stable toolchain with `rustup update stable` (if `rustup` is on `PATH` and no `rust-toolchain.toml` or `rust-toolchain` exists at the workspace root) and runs a parallel `cargo update` in every member with a `Cargo.toml`. It prints the changes and records each run in its own stamp file inside the workspace's `.git` directory (`fastws-upgraded` and `fastws-cargo-upgraded`). Pass `--upgrade` to force both upgrades regardless of the last run time.
|
|
369
381
|
|
|
370
382
|
```bash
|
|
371
383
|
ws-sync
|
|
@@ -74,7 +74,7 @@ Keep `repos.txt` tracked in the workspace Git repo. Put personal additions in a
|
|
|
74
74
|
|
|
75
75
|
`--repos-file myrepos.txt` uses `myrepos-local.txt` alongside it. Either list may be absent. Removing a repo from the baseline does not delete its checkout. The next sync discovers an existing root checkout as a personal addition unless `[tool.fastws].exclude` matches its path. External checkouts also remain on disk; add them to the local list to keep managing them.
|
|
76
76
|
|
|
77
|
-
The workspace `pyproject.toml` is local generated state. `ws-sync` creates it from the tracked `pyproject.tmpl` when available, or generates a minimal one, then maintains it while preserving personal settings except for the managed repo extras, workspace exclusions,
|
|
77
|
+
The workspace `pyproject.toml` is local generated state. `ws-sync` creates it from the tracked `pyproject.tmpl` when available, or generates a minimal one, then maintains it while preserving personal settings except for the managed repo extras, workspace exclusions, build-isolation list, and `metadata-only` backend config settings. The template supplies starting defaults only: later template edits do not overwrite existing configuration. Ignore these files in the workspace repo (not in its member repos):
|
|
78
78
|
|
|
79
79
|
```gitignore
|
|
80
80
|
/repos-local.txt
|
|
@@ -111,16 +111,28 @@ echo source ~/aai-ws/.venv/bin/activate >> ~/.bashrc
|
|
|
111
111
|
|
|
112
112
|
### `ws-setup`
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
Bootstrap a new workspace, or check an existing workspace and complete any missing toolchain and `sccache` setup.
|
|
115
115
|
|
|
116
116
|
```bash
|
|
117
|
-
ws-setup
|
|
118
|
-
ws-setup
|
|
119
|
-
ws-setup
|
|
117
|
+
ws-setup # check/configure the active workspace
|
|
118
|
+
ws-setup --workspace ~/aai-ws # check/configure a specific workspace
|
|
119
|
+
ws-setup AnswerDotAI/aai-ws ~/aai-ws # bootstrap a new workspace
|
|
120
120
|
ws-setup AnswerDotAI/private-ws ~/aai-ws --workers 8
|
|
121
|
+
ws-setup owner/workspace ~/my-workspace --python 3.13
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
With `repo` and `dest`, `ws-setup` clones the workspace repo into a new directory (which must not exist, including as an empty directory or symlink), creates its `.venv`, installs fastws, clones the workspace repos, installs any missing Rust/WebAssembly/JavaScript prerequisites and `sccache` config, and runs that environment's `ws-sync`. It targets the new environment even when another workspace or uv tool environment is already active, and never changes shell startup files or harness settings. A failed step leaves the checkout in place for inspection.
|
|
125
|
+
|
|
126
|
+
With no `repo`, `ws-setup` inspects the existing workspace and completes any missing steps idempotently: installing `rustup` and `wasm32-unknown-unknown` when Rust/WebAssembly packages are present, installing `sccache`, installing Vite+ (`vp`) and enabling its managed `node`/`pnpm` shims when JavaScript packages are present, and configuring `sccache` when `SCCACHE_R2` is set.
|
|
127
|
+
|
|
128
|
+
Set `SCCACHE_R2` to a single R2 URL to configure multilevel local-disk + Cloudflare R2 `sccache` caching:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
export SCCACHE_R2="https://<access_key_id>:<secret_access_key>@<account_id>.r2.cloudflarestorage.com/<bucket>"
|
|
132
|
+
ws-setup
|
|
121
133
|
```
|
|
122
134
|
|
|
123
|
-
|
|
135
|
+
`ws-setup` writes `[cache.multilevel]` (`disk` + `s3`), `[cache.disk]`, `[cache.s3]`, and the workspace root under `basedirs` into the platform `sccache` config (`~/Library/Application Support/Mozilla.sccache/config` on macOS, `~/.config/sccache/config` on Linux, or `SCCACHE_CONF`), preserving existing `basedirs` and unrelated sections. Credentials are written to an isolated `[r2-sccache]` profile in `~/.aws/credentials` (leaving `[default]` untouched), and `.cargo/rustc-lock` selects that profile for `sccache`. Append `?rw_mode=READ_ONLY` for read-only tokens, omit credentials for public read-only buckets, or add `/<prefix>` after `<bucket>` for a `key_prefix`.
|
|
124
136
|
|
|
125
137
|
### `ws-clone`
|
|
126
138
|
|
|
@@ -215,7 +227,7 @@ On Unix, cooperating `cargo develop` runs take a per-project lock through compil
|
|
|
215
227
|
|
|
216
228
|
On Unix, every rustc call holds a shared `flock` on `/tmp/aai-ws-timing.lock`, through the rustc wrapper that sync writes (see `ws-sync`). A speed test that takes that lock exclusively stays apart from participating builds and test runs. A timing also holds `/tmp/aai-ws-timing.gate` while it waits for the lock and holds it, and a shared hold passes that file first, so new rustc calls and test runs wait behind the timing. Both shared and exclusive acquisition fail after 5 minutes; work never proceeds unlocked. Python code takes the same lock with `fastws.timelock.timing_lock`: `with timing_lock(exclusive=True):` around a timing, and `with timing_lock():` around a test run. Shared-inside-shared in one thread reuses its hold; each thread otherwise takes its own hold. Any nesting involving exclusive raises `RuntimeError` immediately. An exclusive hold that has waited 30 seconds prints the processes that have the lock's file open. Windows builds and tests run without this timing coordination.
|
|
217
229
|
|
|
218
|
-
Use `fastws.build_backend` as the build backend of a mixed Rust/Python project (with `fastws-cli>=0.0.29` alongside `maturin>=1.13,<2.0` in `[build-system].requires`) or a `bindings = "bin"` Rust CLI project (`fastws-cli>=0.0.39`).
|
|
230
|
+
Use `fastws.build_backend` as the build backend of a mixed Rust/Python project (with `fastws-cli>=0.0.29` alongside `maturin>=1.13,<2.0` in `[build-system].requires`) or a `bindings = "bin"` Rust CLI project (`fastws-cli>=0.0.39`). Inside a fastws workspace, `ws-sync` writes `[tool.uv.config-settings-package]` with `metadata-only = "1"` into the workspace `pyproject.toml`, so editable builds through `uv sync` install only Python metadata (and the source path when `python-source` is set) and leave Rust compilation to `cargo develop`, which installs the extension, binaries, and wheel data files. Outside the workspace, including `pip install -e .` in CI and standalone installs, editable builds receive no `metadata-only` setting, stage any `native-binaries`, and delegate to maturin so they compile normally.
|
|
219
231
|
|
|
220
232
|
For distribution wheels containing the binaries, also set `[tool.maturin].data` to a generated wheel-data directory. With `native-binaries = true`, wheel builds through the backend replace its `scripts/` subdirectory with the current Python-free binaries, then delegate packaging to maturin. Explicit profile, target and feature arguments from maturin's build settings also apply to the binaries. Without `native-binaries`, wheel builds go straight to maturin, and `[tool.maturin].data` is optional.
|
|
221
233
|
|
|
@@ -310,7 +322,7 @@ Sync also defaults `[term] quiet = true` in that file to suppress routine Cargo
|
|
|
310
322
|
|
|
311
323
|
Do not commit a `Cargo.lock` generated under these patches. Its source-less local entries cannot be resolved on another machine.
|
|
312
324
|
|
|
313
|
-
Sync writes `.cargo/rustc-lock` and makes it Cargo's `rustc-wrapper`. The script runs each rustc call holding the timing lock shared (see `cargo develop` above). Inside the lock it runs the wrapper that the config named before sync first wrote the script, where another tool set one, and otherwise `sccache` when it's installed, so unchanged compilation units are reused across the workspace's otherwise-independent Cargo target directories. Later syncs keep that inner wrapper. The script costs about 9 ms a rustc call, mostly the Python interpreter's start. If `sccache` isn't installed
|
|
325
|
+
Sync writes `.cargo/rustc-lock` and makes it Cargo's `rustc-wrapper`. The script runs each rustc call holding the timing lock shared (see `cargo develop` above). Inside the lock it runs the wrapper that the config named before sync first wrote the script, where another tool set one, and otherwise `sccache` when it's installed, so unchanged compilation units are reused across the workspace's otherwise-independent Cargo target directories. When `ws-setup` has configured an isolated `r2-sccache` AWS credentials profile for a shared R2 cache, the script passes `AWS_PROFILE=r2-sccache` to `sccache` (clearing ambient `AWS_*` keys in that child process) so it never collides with AWS CLI or `boto3`. Later syncs keep that inner wrapper. The script costs about 9 ms a rustc call, mostly the Python interpreter's start. If `sccache` isn't installed—or `SCCACHE_R2` is set without matching `sccache` config—sync warns and tells you to run `ws-setup`. On Windows, where the lock does nothing, the config keeps another tool's wrapper, or else names `sccache`.
|
|
314
326
|
|
|
315
327
|
For an isolated build workspace, `fastws.core.cargo_setup(root)` regenerates these Cargo patches and the same compiler wrapper without pulling, syncing Python or building.
|
|
316
328
|
|
|
@@ -320,7 +332,7 @@ Each sync updates `packages` in the root `pnpm-workspace.yaml` (creating it with
|
|
|
320
332
|
|
|
321
333
|
When JavaScript workspace members are present, `ws-sync` reads `vp toolchain --json -g` and populates `devDependencies["vite-plus"]` in `package.json` plus matching `vite@*` and `vitest@*` entries under `overrides` in `pnpm-workspace.yaml`. Optional tracked `pnpm-workspace.shared.yaml` and `package.json.shared` files are merged on top on every sync. Object-valued fields merge one level deep, shared values win conflicts, and arrays replace rather than concatenate. Unrelated local settings remain; removing a shared key does not delete its local value. Use these files to declare `packageManager`, `devEngines.runtime`, shared policies such as `allowBuilds`, or explicit Vite+ overrides.
|
|
322
334
|
|
|
323
|
-
Before `uv sync`, fastws regenerates `tool.uv.no-build-isolation-package` with the sorted package names of projects using `fastws.build_backend`, including external checkouts. These builds use the shared environment's `fastws-cli` and `maturin
|
|
335
|
+
Before `uv sync`, fastws regenerates `tool.uv.no-build-isolation-package` and `[tool.uv.config-settings-package]` (`metadata-only = "1"`) with the sorted package names of projects using `fastws.build_backend`, including external checkouts. These builds use the shared environment's `fastws-cli` and `maturin`, skip Rust compilation during editable installs inside the workspace, and keep metadata-only wheels separate from compiled editable wheels in uv's cache. Leave global build isolation enabled for other projects.
|
|
324
336
|
|
|
325
337
|
After `uv sync`, fastws writes `_fastws_pytest.pth` into the workspace venv's `site-packages` to default `PYTEST_DISABLE_PLUGIN_AUTOLOAD=1`, keeping pytest plugins installed for one repo from leaking into others. Repos enable the plugins they need via `-p` in `addopts` (override for a run with `PYTEST_DISABLE_PLUGIN_AUTOLOAD=""`).
|
|
326
338
|
|
|
@@ -334,9 +346,9 @@ After installation, fastws runs `pnpm -r --if-present --workspace-concurrency=<N
|
|
|
334
346
|
|
|
335
347
|
`--build-workers` sets the maximum concurrent projects within the Python-native, WebAssembly, and JavaScript build phases, defaulting to the CPU count; `--build-workers 1` runs each phase serially. It is separate from `--workers`, which controls cloning, pulling and dependency updates. Cargo keeps its own within-project parallelism, so increasing project concurrency also increases CPU and memory demand. Cargo may serialize builds that share a target directory.
|
|
336
348
|
|
|
337
|
-
When JavaScript workspaces are present, fastws requires Vite+ (`vp`) on `PATH` with managed `node` and `pnpm` shims active
|
|
349
|
+
When JavaScript workspaces are present, fastws requires Vite+ (`vp`) on `PATH` with managed `node` and `pnpm` shims active. When WebAssembly packages (`[tool.fastws].wasm-package`) are present, fastws also requires rustup's `rustc`/`cargo` proxies and the `wasm32-unknown-unknown` target. Run `ws-setup` to install or configure any missing prerequisites.
|
|
338
350
|
|
|
339
|
-
At most once per day, sync upgrades Python dependencies with `uv sync -U
|
|
351
|
+
At most once per day, sync upgrades Python dependencies with `uv sync -U`. At most once every seven days, when Rust crates are present, it updates the stable toolchain with `rustup update stable` (if `rustup` is on `PATH` and no `rust-toolchain.toml` or `rust-toolchain` exists at the workspace root) and runs a parallel `cargo update` in every member with a `Cargo.toml`. It prints the changes and records each run in its own stamp file inside the workspace's `.git` directory (`fastws-upgraded` and `fastws-cargo-upgraded`). Pass `--upgrade` to force both upgrades regardless of the last run time.
|
|
340
352
|
|
|
341
353
|
```bash
|
|
342
354
|
ws-sync
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
r"Maturin build backend whose editable installs
|
|
1
|
+
r"Maturin build backend whose editable installs skip Rust when configured with `metadata-only`, and whose wheels can include Cargo binaries."
|
|
2
2
|
import argparse, base64, csv, hashlib, io
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
from tempfile import TemporaryDirectory
|
|
@@ -6,8 +6,10 @@ from zipfile import ZipFile, ZIP_DEFLATED
|
|
|
6
6
|
import maturin
|
|
7
7
|
from .cargo import settings, stage_binaries
|
|
8
8
|
|
|
9
|
+
METADATA_ONLY = 'metadata-only' # PEP 660 config setting set by workspace `pyproject.toml` so editable installs leave Rust builds to `cargo develop`
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
|
|
12
|
+
def _stage(config_settings, default_profile='release'):
|
|
11
13
|
root = Path.cwd()
|
|
12
14
|
tool = settings(root)
|
|
13
15
|
if not tool.get('fastws', {}).get('native-binaries'): return
|
|
@@ -19,7 +21,7 @@ def _stage(config_settings):
|
|
|
19
21
|
parser.add_argument('--all-features', action='store_true')
|
|
20
22
|
parser.add_argument('--no-default-features', action='store_true')
|
|
21
23
|
args, _ = parser.parse_known_args(maturin.get_maturin_pep517_args(config_settings))
|
|
22
|
-
profile = args.profile or ('release' if args.release else tool['maturin'].get('profile',
|
|
24
|
+
profile = args.profile or ('release' if args.release else tool['maturin'].get('profile', default_profile))
|
|
23
25
|
stage_binaries(root, profile, args.target, args.features, args.all_features, args.no_default_features)
|
|
24
26
|
|
|
25
27
|
|
|
@@ -29,7 +31,10 @@ def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
|
|
|
29
31
|
|
|
30
32
|
|
|
31
33
|
def build_editable(wheel_directory, config_settings=None, metadata_directory=None):
|
|
32
|
-
r"Build
|
|
34
|
+
r"Build a metadata-only editable wheel when `config_settings` sets `metadata-only`; delegate to maturin otherwise."
|
|
35
|
+
if str((config_settings or {}).get(METADATA_ONLY, '')).lower() in ('', '0', 'false'):
|
|
36
|
+
_stage(config_settings, default_profile='dev')
|
|
37
|
+
return maturin.build_editable(wheel_directory, config_settings, metadata_directory)
|
|
33
38
|
with TemporaryDirectory() as tmp:
|
|
34
39
|
info = Path(metadata_directory) if metadata_directory else Path(tmp)/prepare_metadata_for_build_editable(tmp, config_settings)
|
|
35
40
|
name = info.name.removesuffix('.dist-info')
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
__all__ = ["ws_setup", "ws_clone", "ws_pull", "ws_status", "ws_branches", "ws_build", "ws_sync", "ws_add", "ws_remove", "cargo_develop", "cargo_stage", "cargo_wait", "cargo_setup"]
|
|
4
4
|
|
|
5
|
-
import ast, fnmatch, json, os, re, shlex, shutil, subprocess, sys, tarfile, time
|
|
5
|
+
import ast, configparser, fnmatch, json, os, re, shlex, shutil, subprocess, sys, tarfile, time
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
from contextlib import contextmanager
|
|
8
8
|
from concurrent.futures import ThreadPoolExecutor
|
|
9
9
|
from tempfile import TemporaryDirectory
|
|
10
|
+
from urllib.parse import parse_qs, unquote, urlsplit
|
|
10
11
|
|
|
11
12
|
from fastcore.parallel import parallel_async_gen
|
|
12
13
|
from fastcore.script import call_parse
|
|
@@ -67,14 +68,18 @@ def _repo_key(repo: str) -> str: return repo.strip().rstrip("/").removesuffix(".
|
|
|
67
68
|
|
|
68
69
|
def _pkg_key(name: str) -> str: return canonicalize_name(name)
|
|
69
70
|
|
|
71
|
+
def _toml_key(k: str) -> str: return k if re.fullmatch(r"[A-Za-z0-9_-]+", k) else json.dumps(k)
|
|
72
|
+
|
|
70
73
|
def _fmt_toml_val(v) -> str:
|
|
71
74
|
if isinstance(v, bool): return "true" if v else "false"
|
|
75
|
+
if isinstance(v, int): return str(v)
|
|
72
76
|
if isinstance(v, str): return json.dumps(v)
|
|
73
|
-
|
|
77
|
+
if isinstance(v, list): return "[" + ", ".join(_fmt_toml_val(x) for x in v) + "]"
|
|
78
|
+
raise SystemExit(f"Unsupported TOML value: {v!r}")
|
|
74
79
|
|
|
75
80
|
def _fmt_source(src: dict) -> str:
|
|
76
|
-
"A
|
|
77
|
-
return "{ " + ", ".join(f"{k} = {_fmt_toml_val(v)}" for k,v in src.items()) + " }"
|
|
81
|
+
"A TOML inline table, e.g. `{ path = \"../x\", editable = true }`"
|
|
82
|
+
return "{ " + ", ".join(f"{_toml_key(k)} = {_fmt_toml_val(v)}" for k,v in src.items()) + " }"
|
|
78
83
|
|
|
79
84
|
def _ws_root(workspace: str = "", repos_file: str = "repos.txt", pyproject_file: str = "pyproject.toml",
|
|
80
85
|
template_file: str = "pyproject.tmpl") -> Path:
|
|
@@ -343,14 +348,33 @@ def _sync_ws_pyproject(pyproject_path: Path, template_path: Path, projects: list
|
|
|
343
348
|
if content != original: pyproject_path.write_text(content)
|
|
344
349
|
return missing + [n for n,_ in ext_missing]
|
|
345
350
|
|
|
346
|
-
def
|
|
347
|
-
"Regenerate uv's
|
|
351
|
+
def _sync_build_backend(pyproject_path: Path, projects: list[tuple[str, Path]]):
|
|
352
|
+
"Regenerate uv's build-isolation and metadata-only config settings for projects using the fastws backend."
|
|
353
|
+
from .build_backend import METADATA_ONLY
|
|
348
354
|
content = pyproject_path.read_text()
|
|
349
355
|
packages = sorted({name for name,d in projects
|
|
350
356
|
if tomllib.loads((d/'pyproject.toml').read_text()).get('build-system', {}).get('build-backend') == 'fastws.build_backend'})
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
357
|
+
uv = tomllib.loads(content).get('tool', {}).get('uv', {})
|
|
358
|
+
cur_iso = uv.get('no-build-isolation-package', [])
|
|
359
|
+
cur_cfg = uv.get('config-settings-package', {})
|
|
360
|
+
pkg_keys = {_pkg_key(p): p for p in packages}
|
|
361
|
+
new_cfg = {}
|
|
362
|
+
for pkg, opts in cur_cfg.items():
|
|
363
|
+
if not isinstance(opts, dict): continue
|
|
364
|
+
merged = {k: v for k, v in opts.items() if k != METADATA_ONLY}
|
|
365
|
+
if (key := _pkg_key(pkg)) in pkg_keys:
|
|
366
|
+
merged[METADATA_ONLY] = '1'
|
|
367
|
+
new_cfg[pkg_keys[key]] = merged
|
|
368
|
+
elif merged: new_cfg[pkg] = merged
|
|
369
|
+
for pkg in packages: new_cfg.setdefault(pkg, {METADATA_ONLY: '1'})
|
|
370
|
+
if packages == cur_iso and new_cfg == cur_cfg: return
|
|
371
|
+
if packages != cur_iso: content = _replace_array(content, 'tool.uv', 'no-build-isolation-package', packages)
|
|
372
|
+
if new_cfg != cur_cfg:
|
|
373
|
+
if new_cfg:
|
|
374
|
+
lines = "\n".join(f"{_toml_key(pkg)} = {_fmt_source(new_cfg[pkg])}" for pkg in sorted(new_cfg))
|
|
375
|
+
content = _replace_table(content, 'tool.uv.config-settings-package', lines)
|
|
376
|
+
elif span := _table_span(content, 'tool.uv.config-settings-package'):
|
|
377
|
+
content = content[:span[0]] + content[span[1]:]
|
|
354
378
|
tomllib.loads(content)
|
|
355
379
|
pyproject_path.write_text(content)
|
|
356
380
|
|
|
@@ -448,30 +472,101 @@ async def _changed_dirs(dirs: list[Path]) -> list[Path]:
|
|
|
448
472
|
heads = await _remote_heads([(s, b) for _, (s, b, _) in known])
|
|
449
473
|
return [d for ((d, (_, _, local)), remote) in zip(known, heads) if remote != local] + unknown
|
|
450
474
|
|
|
475
|
+
def _prepend_path(env: dict, *dirs: Path):
|
|
476
|
+
cur = env.get("PATH", "").split(os.pathsep) if env.get("PATH") else []
|
|
477
|
+
add = [str(d) for d in dirs if d.is_dir() and str(d) not in cur]
|
|
478
|
+
if add: env["PATH"] = os.pathsep.join(add + cur)
|
|
479
|
+
|
|
480
|
+
def _setup_tools(root: Path, repos_file: str = "repos.txt", env: dict = None) -> tuple[list[str], dict]:
|
|
481
|
+
"Check workspace toolchain and sccache prerequisites, installing or configuring anything missing."
|
|
482
|
+
env = dict(os.environ if env is None else env)
|
|
483
|
+
which = lambda cmd: shutil.which(cmd, path=env.get("PATH", ""))
|
|
484
|
+
actions = []
|
|
485
|
+
has_rust = bool(_crate_dirs(root))
|
|
486
|
+
wasm_pkgs = _wasm_packages(root, repos_file)
|
|
487
|
+
js_members = _js_dirs(root, repos_file)
|
|
488
|
+
if has_rust or wasm_pkgs:
|
|
489
|
+
if not which("rustup") and (wasm_pkgs or not which("cargo")):
|
|
490
|
+
if os.name == "nt": raise SystemExit("Install rustup from https://rustup.rs, then rerun ws-setup.")
|
|
491
|
+
subprocess.run(["sh", "-c", "curl --proto =https --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable"], env=env, check=True)
|
|
492
|
+
_prepend_path(env, Path(env.get("CARGO_HOME", Path.home()/".cargo"))/"bin")
|
|
493
|
+
actions.append("installed rustup (stable)")
|
|
494
|
+
if rustup := which("rustup"):
|
|
495
|
+
if wasm_pkgs:
|
|
496
|
+
for tool in "rustc", "cargo":
|
|
497
|
+
p = which(tool)
|
|
498
|
+
if not (p and os.path.samefile(p, rustup)):
|
|
499
|
+
print(f"⚠️ {tool} resolves to {p or 'nothing'} rather than rustup; put $HOME/.cargo/bin first on PATH.")
|
|
500
|
+
installed = subprocess.run([rustup, "target", "list", "--installed"], capture_output=True, text=True, env=env, check=True).stdout.splitlines()
|
|
501
|
+
if "wasm32-unknown-unknown" not in installed:
|
|
502
|
+
subprocess.run([rustup, "target", "add", "wasm32-unknown-unknown"], env=env, check=True)
|
|
503
|
+
actions.append("added wasm32-unknown-unknown target")
|
|
504
|
+
if has_rust:
|
|
505
|
+
if not which("sccache"):
|
|
506
|
+
if cargo := which("cargo"):
|
|
507
|
+
subprocess.run([cargo, "install", "sccache", "--locked"], env=env, check=True)
|
|
508
|
+
actions.append("installed sccache")
|
|
509
|
+
else: print("⚠️ cargo not found; install Rust first, then rerun ws-setup to install sccache.")
|
|
510
|
+
if _sync_sccache_config(root):
|
|
511
|
+
actions.append("configured sccache for SCCACHE_R2")
|
|
512
|
+
if sccache := which("sccache"):
|
|
513
|
+
subprocess.run([sccache, "--stop-server"], env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
514
|
+
if (lock := root/".cargo/rustc-lock").exists(): lock.touch() # invalidate Cargo's cached .rustc_info.json
|
|
515
|
+
_sync_cargo_wrapper(root, env=env)
|
|
516
|
+
if js_members:
|
|
517
|
+
if not which("vp"):
|
|
518
|
+
if os.name == "nt": raise SystemExit("Install Vite+ from https://viteplus.dev, then rerun ws-setup.")
|
|
519
|
+
subprocess.run(["sh", "-c", "curl -fsSL https://vite.plus | bash"], env=env, check=True)
|
|
520
|
+
_prepend_path(env, Path.home()/".vite-plus/bin", Path.home()/".local/bin")
|
|
521
|
+
actions.append("installed Vite+ (vp)")
|
|
522
|
+
if vp := which("vp"):
|
|
523
|
+
if any(not ((p := which(t)) and os.path.samefile(p, vp)) for t in ("node", "pnpm")):
|
|
524
|
+
subprocess.run([vp, "env", "on"], env=env, check=True)
|
|
525
|
+
actions.append("enabled Vite+ managed shims")
|
|
526
|
+
for t in ("node", "pnpm"):
|
|
527
|
+
p = which(t)
|
|
528
|
+
if not (p and os.path.samefile(p, vp)):
|
|
529
|
+
print(f"⚠️ {t} still resolves to {p or 'nothing'} rather than vp; put Vite+'s bin dir first on PATH (e.g. ~/.config/vite-plus/env).")
|
|
530
|
+
return actions, env
|
|
531
|
+
|
|
451
532
|
@call_parse
|
|
452
533
|
def ws_setup(
|
|
453
|
-
repo: str, # Workspace repository
|
|
454
|
-
dest: str, # New workspace directory (must not exist)
|
|
455
|
-
|
|
456
|
-
|
|
534
|
+
repo: str = "", # Workspace repository (owner/repo or GitHub URL) to clone; omit to check/configure an existing workspace
|
|
535
|
+
dest: str = "", # New workspace directory (must not exist when `repo` is given)
|
|
536
|
+
workspace: str = "", # Existing workspace root when `repo` is omitted; defaults to active venv parent
|
|
537
|
+
repos_file: str = "repos.txt", # Repo list used to detect workspace requirements
|
|
538
|
+
python: str = "3.13", # Python version for a new workspace environment
|
|
539
|
+
workers: int = None, # Parallel workers for cloning and initial ws-sync; omit to use defaults
|
|
457
540
|
):
|
|
458
|
-
"
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
541
|
+
"Bootstrap a new workspace, or check and complete missing toolchain and sccache setup on an existing workspace."
|
|
542
|
+
if repo:
|
|
543
|
+
if not dest: raise SystemExit("Destination directory is required when cloning a workspace repository.")
|
|
544
|
+
root = Path(dest).expanduser().absolute()
|
|
545
|
+
if root.exists() or root.is_symlink(): raise SystemExit(f'Destination exists: {root}; run bare `ws-setup` or `ws-sync` for an existing workspace')
|
|
546
|
+
repo = _normalize_repo(repo)
|
|
547
|
+
root.parent.mkdir(parents=True, exist_ok=True)
|
|
548
|
+
Git(root.parent, raise_exc=True).clone(f'git@github.com:{repo}.git', str(root))
|
|
549
|
+
venv = root/'.venv'
|
|
550
|
+
bindir = venv/'bin'
|
|
551
|
+
env = dict(os.environ, VIRTUAL_ENV=str(venv), UV_PROJECT_ENVIRONMENT=str(venv),
|
|
552
|
+
UV_PROJECT=str(root), UV_WORKING_DIR=str(root), PATH=f'{bindir}{os.pathsep}{os.environ["PATH"]}')
|
|
553
|
+
subprocess.run(['uv', 'venv', '--python', python, str(venv)], cwd=root, env=env, check=True)
|
|
554
|
+
subprocess.run(['uv', 'pip', 'install', '--python', str(bindir/'python'), 'fastws-cli>=0.0.14'], cwd=root, env=env, check=True)
|
|
555
|
+
clone = [str(bindir/'ws-clone'), '--repos-file', repos_file]
|
|
556
|
+
if workers: clone += ['--workers', str(workers)]
|
|
557
|
+
subprocess.run(clone, cwd=root, env=env, check=True)
|
|
558
|
+
_, env = _setup_tools(root, repos_file, env=env)
|
|
559
|
+
sync = [str(bindir/'ws-sync'), '--workspace', str(root), '--repos-file', repos_file]
|
|
560
|
+
if workers: sync += ['--workers', str(workers)]
|
|
561
|
+
subprocess.run(sync, cwd=root, env=env, check=True)
|
|
562
|
+
print(f'Workspace ready: {root}\n\nsource {shlex.quote(str(bindir/"activate"))}\ncd {shlex.quote(str(root))}')
|
|
563
|
+
if (root/'aai-coding/SETUP.md').exists(): print('Then ask your coding agent to follow aai-coding/SETUP.md.')
|
|
564
|
+
return
|
|
565
|
+
if dest: raise SystemExit(f'Unexpected destination without repo: {dest}; use --workspace to target an existing workspace')
|
|
566
|
+
root = _ws_root(workspace, repos_file)
|
|
567
|
+
actions, _ = _setup_tools(root, repos_file)
|
|
568
|
+
if actions: print("Setup completed: " + ", ".join(actions))
|
|
569
|
+
else: print(f"Workspace setup up to date: {root}")
|
|
475
570
|
|
|
476
571
|
@call_parse
|
|
477
572
|
async def ws_clone(
|
|
@@ -876,32 +971,165 @@ def _sync_cargo_patches(root: Path, root_dir=False) -> tuple[list[str], list[str
|
|
|
876
971
|
added, removed = _entry_changes(before, after)
|
|
877
972
|
return sorted(added), sorted(removed)
|
|
878
973
|
|
|
974
|
+
_SCCACHE_AWS_PROFILE = "r2-sccache"
|
|
975
|
+
|
|
976
|
+
def _sccache_config_path() -> Path:
|
|
977
|
+
if conf := os.environ.get("SCCACHE_CONF"): return Path(conf).expanduser()
|
|
978
|
+
if sys.platform == "darwin": return Path.home()/"Library/Application Support/Mozilla.sccache/config"
|
|
979
|
+
if os.name == "nt": return Path(os.environ.get("APPDATA", Path.home()/"AppData/Roaming"))/"Mozilla/sccache/config/config"
|
|
980
|
+
return Path(os.environ.get("XDG_CONFIG_HOME", Path.home()/".config"))/"sccache/config"
|
|
981
|
+
|
|
982
|
+
def _sccache_disk_dir() -> Path:
|
|
983
|
+
if d := os.environ.get("SCCACHE_DIR"): return Path(d).expanduser()
|
|
984
|
+
if sys.platform == "darwin": return Path.home()/"Library/Caches/Mozilla.sccache"
|
|
985
|
+
if os.name == "nt": return Path(os.environ.get("LOCALAPPDATA", Path.home()/"AppData/Local"))/"Mozilla/sccache"
|
|
986
|
+
return Path(os.environ.get("XDG_CACHE_HOME", Path.home()/".cache"))/"sccache"
|
|
987
|
+
|
|
988
|
+
def _aws_creds_path() -> Path:
|
|
989
|
+
return Path(os.environ.get("AWS_SHARED_CREDENTIALS_FILE", Path.home()/".aws/credentials")).expanduser()
|
|
990
|
+
|
|
991
|
+
def _parse_sccache_r2(url: str) -> dict:
|
|
992
|
+
"Parse `SCCACHE_R2` (`https://[key:secret@]<acct>.r2.cloudflarestorage.com/<bucket>[/prefix][?rw_mode=READ_ONLY]`)."
|
|
993
|
+
u = urlsplit(url.strip())
|
|
994
|
+
if u.scheme not in ("http", "https") or not u.hostname:
|
|
995
|
+
raise SystemExit("Invalid SCCACHE_R2 URL: expected https://[key:secret@]<endpoint>/<bucket>")
|
|
996
|
+
parts = [p for p in u.path.strip("/").split("/") if p]
|
|
997
|
+
if not parts: raise SystemExit("Invalid SCCACHE_R2 URL: missing bucket name in path")
|
|
998
|
+
if (u.username is None) != (u.password is None):
|
|
999
|
+
raise SystemExit("Invalid SCCACHE_R2 URL: specify both access key and secret key, or neither")
|
|
1000
|
+
endpoint = f"{u.scheme}://{u.hostname}" + (f":{u.port}" if u.port else "")
|
|
1001
|
+
rw_mode = parse_qs(u.query).get("rw_mode", [None])[0]
|
|
1002
|
+
access_key = unquote(u.username) if u.username is not None else None
|
|
1003
|
+
secret_key = unquote(u.password) if u.password is not None else None
|
|
1004
|
+
return dict(endpoint=endpoint, bucket=parts[0], key_prefix="/".join(parts[1:]),
|
|
1005
|
+
use_ssl=(u.scheme == "https"), access_key=access_key, secret_key=secret_key, rw_mode=rw_mode)
|
|
1006
|
+
|
|
1007
|
+
def _has_aws_profile(profile: str = _SCCACHE_AWS_PROFILE) -> bool:
|
|
1008
|
+
path = _aws_creds_path()
|
|
1009
|
+
if not path.exists(): return False
|
|
1010
|
+
cp = configparser.RawConfigParser()
|
|
1011
|
+
cp.read(path)
|
|
1012
|
+
return cp.has_section(profile)
|
|
1013
|
+
|
|
1014
|
+
def _sync_aws_profile(access_key: str, secret_key: str, profile: str = _SCCACHE_AWS_PROFILE) -> bool:
|
|
1015
|
+
"Write or update `profile` in AWS credentials without disturbing other profiles; return True if changed."
|
|
1016
|
+
path = _aws_creds_path()
|
|
1017
|
+
cp = configparser.RawConfigParser()
|
|
1018
|
+
if path.exists(): cp.read(path)
|
|
1019
|
+
if cp.has_section(profile) and cp.get(profile, "aws_access_key_id", fallback=None) == access_key \
|
|
1020
|
+
and cp.get(profile, "aws_secret_access_key", fallback=None) == secret_key: return False
|
|
1021
|
+
if not cp.has_section(profile): cp.add_section(profile)
|
|
1022
|
+
cp.set(profile, "aws_access_key_id", access_key)
|
|
1023
|
+
cp.set(profile, "aws_secret_access_key", secret_key)
|
|
1024
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
1025
|
+
with path.open("w") as f: cp.write(f)
|
|
1026
|
+
if os.name != "nt": path.chmod(0o600)
|
|
1027
|
+
return True
|
|
1028
|
+
|
|
1029
|
+
def _set_top_array(content: str, key: str, values: list[str]) -> str:
|
|
1030
|
+
"Set or replace a top-level TOML array `key` before the first `[table]` header."
|
|
1031
|
+
line = f"{key} = {_fmt_toml_val(values)}"
|
|
1032
|
+
m_tbl = re.search(r"(?m)^[ \t]*\[", content)
|
|
1033
|
+
preamble, rest = (content[:m_tbl.start()], content[m_tbl.start():]) if m_tbl else (content, "")
|
|
1034
|
+
if m := re.search(rf"(?m)^{re.escape(key)}\s*=\s*\[", preamble):
|
|
1035
|
+
arr_end = _find_array_end(preamble, m.end()-1)
|
|
1036
|
+
preamble = preamble[:m.start()] + line + preamble[arr_end+1:]
|
|
1037
|
+
else: preamble = (preamble.rstrip() + "\n" + line + "\n\n").lstrip("\n")
|
|
1038
|
+
return preamble + rest
|
|
1039
|
+
|
|
1040
|
+
def _sccache_uses_s3() -> bool:
|
|
1041
|
+
path = _sccache_config_path()
|
|
1042
|
+
if not path.exists(): return False
|
|
1043
|
+
try: return "s3" in tomllib.loads(path.read_text()).get("cache", {})
|
|
1044
|
+
except tomllib.TOMLDecodeError: return False
|
|
1045
|
+
|
|
1046
|
+
def _render_sccache_config(root: Path, spec: dict, content: str) -> str:
|
|
1047
|
+
"Return sccache TOML config with `root` in `basedirs`, multilevel `disk`+`s3`, and `[cache.s3]` from `spec`."
|
|
1048
|
+
data = tomllib.loads(content) if content else {}
|
|
1049
|
+
basedirs = list(data.get("basedirs", []))
|
|
1050
|
+
ws_str = str(root.resolve())
|
|
1051
|
+
if ws_str not in basedirs: basedirs.append(ws_str)
|
|
1052
|
+
content = _set_top_array(content, "basedirs", basedirs)
|
|
1053
|
+
if "multilevel" not in data.get("cache", {}):
|
|
1054
|
+
content = _replace_table(content, "cache.multilevel", 'chain = ["disk", "s3"]\nwrite_error_policy = "l0"')
|
|
1055
|
+
if "disk" not in data.get("cache", {}):
|
|
1056
|
+
content = _replace_table(content, "cache.disk", f'dir = {json.dumps(str(_sccache_disk_dir()))}\nsize = 10737418240')
|
|
1057
|
+
s3 = dict(data.get("cache", {}).get("s3", {}))
|
|
1058
|
+
s3 |= dict(bucket=spec["bucket"], endpoint=spec["endpoint"], region="auto", use_ssl=spec["use_ssl"])
|
|
1059
|
+
if spec["key_prefix"]: s3["key_prefix"] = spec["key_prefix"]
|
|
1060
|
+
else: s3.pop("key_prefix", None)
|
|
1061
|
+
if spec["rw_mode"]: s3["rw_mode"] = spec["rw_mode"]
|
|
1062
|
+
elif not spec["access_key"]: s3["rw_mode"] = "READ_ONLY"
|
|
1063
|
+
s3["no_credentials"] = not spec["access_key"]
|
|
1064
|
+
content = _replace_table(content, "cache.s3", "\n".join(f"{_toml_key(k)} = {_fmt_toml_val(v)}" for k, v in s3.items()))
|
|
1065
|
+
return content.strip() + "\n"
|
|
1066
|
+
|
|
1067
|
+
def _sccache_r2_needs_setup(root: Path) -> bool:
|
|
1068
|
+
url = os.environ.get("SCCACHE_R2", "").strip()
|
|
1069
|
+
if not url: return False
|
|
1070
|
+
try: spec = _parse_sccache_r2(url)
|
|
1071
|
+
except SystemExit: return True
|
|
1072
|
+
cfg_path = _sccache_config_path()
|
|
1073
|
+
if not cfg_path.exists(): return True
|
|
1074
|
+
try:
|
|
1075
|
+
original = cfg_path.read_text()
|
|
1076
|
+
if _render_sccache_config(root, spec, original) != original: return True
|
|
1077
|
+
except tomllib.TOMLDecodeError: return True
|
|
1078
|
+
return bool(spec["access_key"]) and not _has_aws_profile()
|
|
1079
|
+
|
|
1080
|
+
def _sync_sccache_config(root: Path) -> bool:
|
|
1081
|
+
"Configure sccache multilevel local+R2 caching and isolated AWS profile from `SCCACHE_R2`; return True if anything changed."
|
|
1082
|
+
url = os.environ.get("SCCACHE_R2", "").strip()
|
|
1083
|
+
if not url: return False
|
|
1084
|
+
spec = _parse_sccache_r2(url)
|
|
1085
|
+
changed = bool(spec["access_key"]) and _sync_aws_profile(spec["access_key"], spec["secret_key"])
|
|
1086
|
+
cfg_path = _sccache_config_path()
|
|
1087
|
+
original = cfg_path.read_text() if cfg_path.exists() else ""
|
|
1088
|
+
new = _render_sccache_config(root, spec, original)
|
|
1089
|
+
if new != original:
|
|
1090
|
+
tomllib.loads(new)
|
|
1091
|
+
cfg_path.parent.mkdir(parents=True, exist_ok=True)
|
|
1092
|
+
cfg_path.write_text(new)
|
|
1093
|
+
changed = True
|
|
1094
|
+
return changed
|
|
1095
|
+
|
|
879
1096
|
# The rustc wrapper that `_sync_cargo_wrapper` writes. It imports only `fastws.timelock`, by its file, so that each rustc call pays for little more than the interpreter's start.
|
|
880
1097
|
_RUSTC_LOCK = r"""#!{python} -IS
|
|
881
1098
|
# Written by ws-sync. Cargo runs each rustc call through this script, which holds the machine's timing lock shared until rustc ends (`fastws.timelock`){via}.
|
|
882
|
-
import sys
|
|
1099
|
+
import os, sys
|
|
883
1100
|
sys.path.insert(0, {dir!r})
|
|
884
1101
|
from timelock import exec_shared
|
|
885
1102
|
INNER = {inner!r} # The wrapper that each rustc call runs through inside the lock, kept by later syncs; None: rustc alone
|
|
1103
|
+
PROFILE = {profile!r} # AWS profile for sccache R2 access when configured by ws-setup; None: leave AWS env alone
|
|
1104
|
+
if PROFILE:
|
|
1105
|
+
os.environ["AWS_PROFILE"] = PROFILE
|
|
1106
|
+
for _k in ("AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"): os.environ.pop(_k, None)
|
|
886
1107
|
exec_shared([INNER, *sys.argv[1:]] if INNER else sys.argv[1:])
|
|
887
1108
|
"""
|
|
888
1109
|
|
|
889
|
-
def _sync_cargo_wrapper(root: Path):
|
|
1110
|
+
def _sync_cargo_wrapper(root: Path, env: dict = None):
|
|
890
1111
|
"Point the generated Cargo config's `rustc-wrapper` at `.cargo/rustc-lock`, written here, which runs each rustc call holding the machine's timing lock shared (`fastws.timelock`). Inside the lock it runs the wrapper that the config named before, where that's another tool's, or else sccache where it's installed. On Windows, where the lock does nothing, the config keeps another tool's wrapper, or else names sccache."
|
|
891
1112
|
config, script = root/".cargo"/"config.toml", root/".cargo"/"rustc-lock"
|
|
892
1113
|
content = config.read_text() if config.exists() else ""
|
|
893
1114
|
current = (tomllib.loads(content) if content else {}).get("build", {}).get("rustc-wrapper")
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
1115
|
+
path_env = (env or os.environ).get("PATH")
|
|
1116
|
+
if not (sccache := shutil.which("sccache", path=path_env)):
|
|
1117
|
+
print("⚠️ sccache not found; Rust builds won't use compiler caching. Run ws-setup to install it.")
|
|
1118
|
+
elif _sccache_r2_needs_setup(root):
|
|
1119
|
+
print("⚠️ SCCACHE_R2 is set, but sccache is not configured for it yet. Run ws-setup to configure it.")
|
|
897
1120
|
recorded = script.exists() and current == str(script) and re.search(r"(?m)^INNER = (.+?) #", script.read_text())
|
|
898
1121
|
previous = ast.literal_eval(recorded[1]) if recorded else current
|
|
899
1122
|
inner = previous if previous not in (None, str(script)) else sccache
|
|
1123
|
+
is_sccache = bool(inner) and Path(inner).stem == "sccache"
|
|
1124
|
+
profile = _SCCACHE_AWS_PROFILE if (is_sccache and _sccache_uses_s3() and _has_aws_profile()) else None
|
|
900
1125
|
if os.name == "nt": wrapper = inner
|
|
901
1126
|
else:
|
|
902
1127
|
script.parent.mkdir(exist_ok=True)
|
|
903
|
-
|
|
904
|
-
|
|
1128
|
+
rendered = _RUSTC_LOCK.format(python=sys.executable, dir=str(Path(__file__).parent),
|
|
1129
|
+
via=f", through {Path(inner).name}" if inner else "", inner=inner, profile=profile)
|
|
1130
|
+
if not script.exists() or script.read_text() != rendered:
|
|
1131
|
+
script.write_text(rendered)
|
|
1132
|
+
script.chmod(0o755)
|
|
905
1133
|
wrapper = str(script)
|
|
906
1134
|
if not wrapper or current == wrapper: return
|
|
907
1135
|
content = re.sub(r"(?m)^rustc-wrapper = .*\n", "", content)
|
|
@@ -920,6 +1148,14 @@ def _cargo_dep_tables(data, every=False):
|
|
|
920
1148
|
for name in names: yield target.get(name, {})
|
|
921
1149
|
if every: yield data.get("workspace", {}).get("dependencies", {})
|
|
922
1150
|
|
|
1151
|
+
def _rustup_update(root: Path):
|
|
1152
|
+
"Update the stable Rust toolchain when the workspace has crates, rustup is installed, and no root toolchain pin exists."
|
|
1153
|
+
if not _crate_dirs(root) or not (rustup := shutil.which("rustup")): return
|
|
1154
|
+
if any((root/f).exists() for f in ("rust-toolchain.toml", "rust-toolchain")): return
|
|
1155
|
+
res = subprocess.run([rustup, "update", "stable"], capture_output=True, text=True)
|
|
1156
|
+
if res.returncode: print(f"⚠️ rustup update stable failed\n{((res.stdout or '') + (res.stderr or '')).strip()}")
|
|
1157
|
+
elif out := (res.stdout or "").strip(): print(out)
|
|
1158
|
+
|
|
923
1159
|
def _cargo_update(root: Path, workers: int = 16):
|
|
924
1160
|
"Float each member crate's Cargo.lock to latest matching versions, in parallel; prints what moved."
|
|
925
1161
|
crates = _crate_dirs(root)
|
|
@@ -1076,8 +1312,7 @@ def _js_graph(members: list[Path], wasm_pkgs: dict = None):
|
|
|
1076
1312
|
def _check_rustup(wasm: bool = False):
|
|
1077
1313
|
"Require rustup's compiler proxies, and optionally the `wasm32-unknown-unknown` target."
|
|
1078
1314
|
if not (rustup := shutil.which("rustup")):
|
|
1079
|
-
raise SystemExit("Rust-backed WebAssembly builds require rustup.
|
|
1080
|
-
"select a stable toolchain with `rustup default stable`, then reopen your shell and rerun ws-sync.")
|
|
1315
|
+
raise SystemExit("Rust-backed WebAssembly builds require rustup. Run ws-setup to install it.")
|
|
1081
1316
|
for tool in "rustc","cargo":
|
|
1082
1317
|
path = shutil.which(tool)
|
|
1083
1318
|
if path and os.path.samefile(path, rustup): continue
|
|
@@ -1088,20 +1323,17 @@ def _check_rustup(wasm: bool = False):
|
|
|
1088
1323
|
if wasm:
|
|
1089
1324
|
installed = subprocess.run([rustup, "target", "list", "--installed"], capture_output=True, text=True, check=True).stdout.splitlines()
|
|
1090
1325
|
if "wasm32-unknown-unknown" not in installed:
|
|
1091
|
-
raise SystemExit("WebAssembly builds require the wasm32-unknown-unknown Rust target. "
|
|
1092
|
-
"Install it with: rustup target add wasm32-unknown-unknown")
|
|
1326
|
+
raise SystemExit("WebAssembly builds require the wasm32-unknown-unknown Rust target. Run ws-setup to install it.")
|
|
1093
1327
|
|
|
1094
1328
|
def _check_vp():
|
|
1095
1329
|
"Require Vite+ (`vp`) and its managed `node` and `pnpm` shims on PATH."
|
|
1096
1330
|
if not (vp := shutil.which("vp")):
|
|
1097
|
-
raise SystemExit("JavaScript workspaces require Vite+ (vp).
|
|
1098
|
-
"(`curl -fsSL https://vite.plus | bash`), enable managed Node.js and package-manager shims when prompted, "
|
|
1099
|
-
"then reopen your shell and rerun ws-sync.")
|
|
1331
|
+
raise SystemExit("JavaScript workspaces require Vite+ (vp). Run ws-setup to install it.")
|
|
1100
1332
|
for tool in "node", "pnpm":
|
|
1101
1333
|
path = shutil.which(tool)
|
|
1102
1334
|
if path and os.path.samefile(path, vp): continue
|
|
1103
1335
|
raise SystemExit(f"JavaScript workspaces require Vite+-managed {tool}, but {tool} resolves to {path or 'nothing'}. "
|
|
1104
|
-
"
|
|
1336
|
+
"Run ws-setup to enable Vite+ managed shims, and put Vite+'s bin directory first on PATH "
|
|
1105
1337
|
"(normally via `~/.config/vite-plus/env`), then open a new shell and rerun ws-sync.")
|
|
1106
1338
|
|
|
1107
1339
|
def _vp_toolchain() -> dict[str, str]:
|
|
@@ -1147,7 +1379,7 @@ async def ws_sync(
|
|
|
1147
1379
|
upgrade: bool = False, # Force the once-daily dependency upgrade pass
|
|
1148
1380
|
build_workers: int = os.cpu_count() or 1, # Concurrent projects per build phase; defaults to CPU count
|
|
1149
1381
|
):
|
|
1150
|
-
"Pull the workspace baseline, clone missing shared/local repos, then pull projects and sync; upgrade Python deps daily and Cargo deps weekly."
|
|
1382
|
+
"Pull the workspace baseline, clone missing shared/local repos, then pull projects and sync; upgrade Python deps daily and Rust toolchain/Cargo deps weekly."
|
|
1151
1383
|
with _cli_errors():
|
|
1152
1384
|
root = _ws_root(workspace, repos_file, pyproject_file, template_file)
|
|
1153
1385
|
repos_path = _resolve_path(root, repos_file)
|
|
@@ -1175,7 +1407,7 @@ async def ws_sync(
|
|
|
1175
1407
|
_repo_extras(root, entries))
|
|
1176
1408
|
if missing_projects: print(f"Added workspace projects: {', '.join(missing_projects)}")
|
|
1177
1409
|
projects = _build_projects(root, repos_file)
|
|
1178
|
-
|
|
1410
|
+
_sync_build_backend(pyproject_path, projects)
|
|
1179
1411
|
|
|
1180
1412
|
added_p, removed_p = cargo_setup(root)
|
|
1181
1413
|
if added_p: print(f"Cargo patches added: {', '.join(added_p)}")
|
|
@@ -1197,7 +1429,9 @@ async def ws_sync(
|
|
|
1197
1429
|
return
|
|
1198
1430
|
up = upgrade or _should_upgrade(root)
|
|
1199
1431
|
cargo_up = upgrade or _should_upgrade(root, max_age=7*86400, name="fastws-cargo-upgraded")
|
|
1200
|
-
if cargo_up:
|
|
1432
|
+
if cargo_up:
|
|
1433
|
+
_rustup_update(root)
|
|
1434
|
+
_cargo_update(root, workers=workers)
|
|
1201
1435
|
subprocess.run(["uv", "sync", "-U"] if up else ["uv", "sync"], check=True, cwd=root)
|
|
1202
1436
|
_write_pytest_pth(root)
|
|
1203
1437
|
from .cargo import develop
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastws-cli
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.40
|
|
4
4
|
Summary: Fast workspace tools for multi-repo management
|
|
5
5
|
Author: Jeremy Howard
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -103,7 +103,7 @@ Keep `repos.txt` tracked in the workspace Git repo. Put personal additions in a
|
|
|
103
103
|
|
|
104
104
|
`--repos-file myrepos.txt` uses `myrepos-local.txt` alongside it. Either list may be absent. Removing a repo from the baseline does not delete its checkout. The next sync discovers an existing root checkout as a personal addition unless `[tool.fastws].exclude` matches its path. External checkouts also remain on disk; add them to the local list to keep managing them.
|
|
105
105
|
|
|
106
|
-
The workspace `pyproject.toml` is local generated state. `ws-sync` creates it from the tracked `pyproject.tmpl` when available, or generates a minimal one, then maintains it while preserving personal settings except for the managed repo extras, workspace exclusions,
|
|
106
|
+
The workspace `pyproject.toml` is local generated state. `ws-sync` creates it from the tracked `pyproject.tmpl` when available, or generates a minimal one, then maintains it while preserving personal settings except for the managed repo extras, workspace exclusions, build-isolation list, and `metadata-only` backend config settings. The template supplies starting defaults only: later template edits do not overwrite existing configuration. Ignore these files in the workspace repo (not in its member repos):
|
|
107
107
|
|
|
108
108
|
```gitignore
|
|
109
109
|
/repos-local.txt
|
|
@@ -140,16 +140,28 @@ echo source ~/aai-ws/.venv/bin/activate >> ~/.bashrc
|
|
|
140
140
|
|
|
141
141
|
### `ws-setup`
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
Bootstrap a new workspace, or check an existing workspace and complete any missing toolchain and `sccache` setup.
|
|
144
144
|
|
|
145
145
|
```bash
|
|
146
|
-
ws-setup
|
|
147
|
-
ws-setup
|
|
148
|
-
ws-setup
|
|
146
|
+
ws-setup # check/configure the active workspace
|
|
147
|
+
ws-setup --workspace ~/aai-ws # check/configure a specific workspace
|
|
148
|
+
ws-setup AnswerDotAI/aai-ws ~/aai-ws # bootstrap a new workspace
|
|
149
149
|
ws-setup AnswerDotAI/private-ws ~/aai-ws --workers 8
|
|
150
|
+
ws-setup owner/workspace ~/my-workspace --python 3.13
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
With `repo` and `dest`, `ws-setup` clones the workspace repo into a new directory (which must not exist, including as an empty directory or symlink), creates its `.venv`, installs fastws, clones the workspace repos, installs any missing Rust/WebAssembly/JavaScript prerequisites and `sccache` config, and runs that environment's `ws-sync`. It targets the new environment even when another workspace or uv tool environment is already active, and never changes shell startup files or harness settings. A failed step leaves the checkout in place for inspection.
|
|
154
|
+
|
|
155
|
+
With no `repo`, `ws-setup` inspects the existing workspace and completes any missing steps idempotently: installing `rustup` and `wasm32-unknown-unknown` when Rust/WebAssembly packages are present, installing `sccache`, installing Vite+ (`vp`) and enabling its managed `node`/`pnpm` shims when JavaScript packages are present, and configuring `sccache` when `SCCACHE_R2` is set.
|
|
156
|
+
|
|
157
|
+
Set `SCCACHE_R2` to a single R2 URL to configure multilevel local-disk + Cloudflare R2 `sccache` caching:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
export SCCACHE_R2="https://<access_key_id>:<secret_access_key>@<account_id>.r2.cloudflarestorage.com/<bucket>"
|
|
161
|
+
ws-setup
|
|
150
162
|
```
|
|
151
163
|
|
|
152
|
-
|
|
164
|
+
`ws-setup` writes `[cache.multilevel]` (`disk` + `s3`), `[cache.disk]`, `[cache.s3]`, and the workspace root under `basedirs` into the platform `sccache` config (`~/Library/Application Support/Mozilla.sccache/config` on macOS, `~/.config/sccache/config` on Linux, or `SCCACHE_CONF`), preserving existing `basedirs` and unrelated sections. Credentials are written to an isolated `[r2-sccache]` profile in `~/.aws/credentials` (leaving `[default]` untouched), and `.cargo/rustc-lock` selects that profile for `sccache`. Append `?rw_mode=READ_ONLY` for read-only tokens, omit credentials for public read-only buckets, or add `/<prefix>` after `<bucket>` for a `key_prefix`.
|
|
153
165
|
|
|
154
166
|
### `ws-clone`
|
|
155
167
|
|
|
@@ -244,7 +256,7 @@ On Unix, cooperating `cargo develop` runs take a per-project lock through compil
|
|
|
244
256
|
|
|
245
257
|
On Unix, every rustc call holds a shared `flock` on `/tmp/aai-ws-timing.lock`, through the rustc wrapper that sync writes (see `ws-sync`). A speed test that takes that lock exclusively stays apart from participating builds and test runs. A timing also holds `/tmp/aai-ws-timing.gate` while it waits for the lock and holds it, and a shared hold passes that file first, so new rustc calls and test runs wait behind the timing. Both shared and exclusive acquisition fail after 5 minutes; work never proceeds unlocked. Python code takes the same lock with `fastws.timelock.timing_lock`: `with timing_lock(exclusive=True):` around a timing, and `with timing_lock():` around a test run. Shared-inside-shared in one thread reuses its hold; each thread otherwise takes its own hold. Any nesting involving exclusive raises `RuntimeError` immediately. An exclusive hold that has waited 30 seconds prints the processes that have the lock's file open. Windows builds and tests run without this timing coordination.
|
|
246
258
|
|
|
247
|
-
Use `fastws.build_backend` as the build backend of a mixed Rust/Python project (with `fastws-cli>=0.0.29` alongside `maturin>=1.13,<2.0` in `[build-system].requires`) or a `bindings = "bin"` Rust CLI project (`fastws-cli>=0.0.39`).
|
|
259
|
+
Use `fastws.build_backend` as the build backend of a mixed Rust/Python project (with `fastws-cli>=0.0.29` alongside `maturin>=1.13,<2.0` in `[build-system].requires`) or a `bindings = "bin"` Rust CLI project (`fastws-cli>=0.0.39`). Inside a fastws workspace, `ws-sync` writes `[tool.uv.config-settings-package]` with `metadata-only = "1"` into the workspace `pyproject.toml`, so editable builds through `uv sync` install only Python metadata (and the source path when `python-source` is set) and leave Rust compilation to `cargo develop`, which installs the extension, binaries, and wheel data files. Outside the workspace, including `pip install -e .` in CI and standalone installs, editable builds receive no `metadata-only` setting, stage any `native-binaries`, and delegate to maturin so they compile normally.
|
|
248
260
|
|
|
249
261
|
For distribution wheels containing the binaries, also set `[tool.maturin].data` to a generated wheel-data directory. With `native-binaries = true`, wheel builds through the backend replace its `scripts/` subdirectory with the current Python-free binaries, then delegate packaging to maturin. Explicit profile, target and feature arguments from maturin's build settings also apply to the binaries. Without `native-binaries`, wheel builds go straight to maturin, and `[tool.maturin].data` is optional.
|
|
250
262
|
|
|
@@ -339,7 +351,7 @@ Sync also defaults `[term] quiet = true` in that file to suppress routine Cargo
|
|
|
339
351
|
|
|
340
352
|
Do not commit a `Cargo.lock` generated under these patches. Its source-less local entries cannot be resolved on another machine.
|
|
341
353
|
|
|
342
|
-
Sync writes `.cargo/rustc-lock` and makes it Cargo's `rustc-wrapper`. The script runs each rustc call holding the timing lock shared (see `cargo develop` above). Inside the lock it runs the wrapper that the config named before sync first wrote the script, where another tool set one, and otherwise `sccache` when it's installed, so unchanged compilation units are reused across the workspace's otherwise-independent Cargo target directories. Later syncs keep that inner wrapper. The script costs about 9 ms a rustc call, mostly the Python interpreter's start. If `sccache` isn't installed
|
|
354
|
+
Sync writes `.cargo/rustc-lock` and makes it Cargo's `rustc-wrapper`. The script runs each rustc call holding the timing lock shared (see `cargo develop` above). Inside the lock it runs the wrapper that the config named before sync first wrote the script, where another tool set one, and otherwise `sccache` when it's installed, so unchanged compilation units are reused across the workspace's otherwise-independent Cargo target directories. When `ws-setup` has configured an isolated `r2-sccache` AWS credentials profile for a shared R2 cache, the script passes `AWS_PROFILE=r2-sccache` to `sccache` (clearing ambient `AWS_*` keys in that child process) so it never collides with AWS CLI or `boto3`. Later syncs keep that inner wrapper. The script costs about 9 ms a rustc call, mostly the Python interpreter's start. If `sccache` isn't installed—or `SCCACHE_R2` is set without matching `sccache` config—sync warns and tells you to run `ws-setup`. On Windows, where the lock does nothing, the config keeps another tool's wrapper, or else names `sccache`.
|
|
343
355
|
|
|
344
356
|
For an isolated build workspace, `fastws.core.cargo_setup(root)` regenerates these Cargo patches and the same compiler wrapper without pulling, syncing Python or building.
|
|
345
357
|
|
|
@@ -349,7 +361,7 @@ Each sync updates `packages` in the root `pnpm-workspace.yaml` (creating it with
|
|
|
349
361
|
|
|
350
362
|
When JavaScript workspace members are present, `ws-sync` reads `vp toolchain --json -g` and populates `devDependencies["vite-plus"]` in `package.json` plus matching `vite@*` and `vitest@*` entries under `overrides` in `pnpm-workspace.yaml`. Optional tracked `pnpm-workspace.shared.yaml` and `package.json.shared` files are merged on top on every sync. Object-valued fields merge one level deep, shared values win conflicts, and arrays replace rather than concatenate. Unrelated local settings remain; removing a shared key does not delete its local value. Use these files to declare `packageManager`, `devEngines.runtime`, shared policies such as `allowBuilds`, or explicit Vite+ overrides.
|
|
351
363
|
|
|
352
|
-
Before `uv sync`, fastws regenerates `tool.uv.no-build-isolation-package` with the sorted package names of projects using `fastws.build_backend`, including external checkouts. These builds use the shared environment's `fastws-cli` and `maturin
|
|
364
|
+
Before `uv sync`, fastws regenerates `tool.uv.no-build-isolation-package` and `[tool.uv.config-settings-package]` (`metadata-only = "1"`) with the sorted package names of projects using `fastws.build_backend`, including external checkouts. These builds use the shared environment's `fastws-cli` and `maturin`, skip Rust compilation during editable installs inside the workspace, and keep metadata-only wheels separate from compiled editable wheels in uv's cache. Leave global build isolation enabled for other projects.
|
|
353
365
|
|
|
354
366
|
After `uv sync`, fastws writes `_fastws_pytest.pth` into the workspace venv's `site-packages` to default `PYTEST_DISABLE_PLUGIN_AUTOLOAD=1`, keeping pytest plugins installed for one repo from leaking into others. Repos enable the plugins they need via `-p` in `addopts` (override for a run with `PYTEST_DISABLE_PLUGIN_AUTOLOAD=""`).
|
|
355
367
|
|
|
@@ -363,9 +375,9 @@ After installation, fastws runs `pnpm -r --if-present --workspace-concurrency=<N
|
|
|
363
375
|
|
|
364
376
|
`--build-workers` sets the maximum concurrent projects within the Python-native, WebAssembly, and JavaScript build phases, defaulting to the CPU count; `--build-workers 1` runs each phase serially. It is separate from `--workers`, which controls cloning, pulling and dependency updates. Cargo keeps its own within-project parallelism, so increasing project concurrency also increases CPU and memory demand. Cargo may serialize builds that share a target directory.
|
|
365
377
|
|
|
366
|
-
When JavaScript workspaces are present, fastws requires Vite+ (`vp`) on `PATH` with managed `node` and `pnpm` shims active
|
|
378
|
+
When JavaScript workspaces are present, fastws requires Vite+ (`vp`) on `PATH` with managed `node` and `pnpm` shims active. When WebAssembly packages (`[tool.fastws].wasm-package`) are present, fastws also requires rustup's `rustc`/`cargo` proxies and the `wasm32-unknown-unknown` target. Run `ws-setup` to install or configure any missing prerequisites.
|
|
367
379
|
|
|
368
|
-
At most once per day, sync upgrades Python dependencies with `uv sync -U
|
|
380
|
+
At most once per day, sync upgrades Python dependencies with `uv sync -U`. At most once every seven days, when Rust crates are present, it updates the stable toolchain with `rustup update stable` (if `rustup` is on `PATH` and no `rust-toolchain.toml` or `rust-toolchain` exists at the workspace root) and runs a parallel `cargo update` in every member with a `Cargo.toml`. It prints the changes and records each run in its own stamp file inside the workspace's `.git` directory (`fastws-upgraded` and `fastws-cargo-upgraded`). Pass `--upgrade` to force both upgrades regardless of the last run time.
|
|
369
381
|
|
|
370
382
|
```bash
|
|
371
383
|
ws-sync
|
|
@@ -139,46 +139,6 @@ console.log('bundled app');
|
|
|
139
139
|
assert not list(out.glob('.fastws-*'))
|
|
140
140
|
|
|
141
141
|
|
|
142
|
-
@pytest.mark.skipif(not shutil.which('vp'), reason='JavaScript builds need Vite+ (vp)')
|
|
143
|
-
def test_wasm_build_always_runs_cargo_and_packs_dist(tmp_path, monkeypatch):
|
|
144
|
-
root, out = tmp_path/'ws', tmp_path/'ws'/'.dists'
|
|
145
|
-
root.mkdir()
|
|
146
|
-
_write_cached_vp_shared(root)
|
|
147
|
-
sibling = tmp_path/'rustymath'
|
|
148
|
-
sibling.mkdir()
|
|
149
|
-
(sibling/'src.txt').write_text('v1')
|
|
150
|
-
app = _mk_proj(root, 'app', '[tool.fastws]\njs-packages = ["frontend"]')
|
|
151
|
-
(app/'frontend').mkdir()
|
|
152
|
-
(app/'frontend'/'package.json').write_text(json.dumps({'name': 'app-fe', 'private': True, 'dependencies': {'basedpl': '>=0.1.0'}}))
|
|
153
|
-
bpl = _mk_proj(root, 'basedpl', 'version = "0.1.0"\n[build-system]\nrequires = ["setuptools>=77"]\nbuild-backend = "setuptools.build_meta"\n[tool.setuptools]\npy-modules = []\n[tool.fastws]\nwasm-package = { name = "basedpl", path = "wasm/pkg" }')
|
|
154
|
-
(bpl/'package.json').write_text(json.dumps({'name': 'basedpl', 'version': '0.1.0', 'private': True}))
|
|
155
|
-
_mk_proj(root, 'mdhtml', '[tool.fastws]\nwasm-package = { name = "@answerdotai/mdhtml", path = "wasm/pkg" }')
|
|
156
|
-
core._sync_ws_pnpm_workspace(root, core._js_dirs(root))
|
|
157
|
-
core._sync_ws_package_json(root)
|
|
158
|
-
|
|
159
|
-
built_wasm = []
|
|
160
|
-
def fake_wasm(repo):
|
|
161
|
-
built_wasm.append(repo.name)
|
|
162
|
-
pkg = repo/'wasm'/'pkg'
|
|
163
|
-
pkg.mkdir(parents=True, exist_ok=True)
|
|
164
|
-
val = (sibling/'src.txt').read_text()
|
|
165
|
-
if not (pkg/'out.js').exists() or (pkg/'out.js').read_text() != val:
|
|
166
|
-
(pkg/'out.js').write_text(val)
|
|
167
|
-
(pkg/'package.json').write_text(json.dumps({'name': 'basedpl', 'version': '0.1.0', 'files': ['out.js']}))
|
|
168
|
-
monkeypatch.setattr(core, '_check_rustup', lambda wasm=False: None)
|
|
169
|
-
monkeypatch.setattr(core, '_build_wasm', fake_wasm)
|
|
170
|
-
|
|
171
|
-
core.ws_build(workspace=str(root), project='app-fe', workers=2)
|
|
172
|
-
assert built_wasm == ['basedpl']
|
|
173
|
-
tgz, = out.glob('*.tgz')
|
|
174
|
-
assert tgz.name == 'basedpl-0.1.0.tgz' and _archive_text(tgz, 'out.js') == 'v1'
|
|
175
|
-
|
|
176
|
-
# Editing an external sibling crate without touching basedpl still invokes Cargo and repacks updated WASM.
|
|
177
|
-
(sibling/'src.txt').write_text('v2')
|
|
178
|
-
core.ws_build(workspace=str(root), project='app-fe', workers=2)
|
|
179
|
-
assert built_wasm == ['basedpl', 'basedpl']
|
|
180
|
-
assert _archive_text(out/'basedpl-0.1.0.tgz', 'out.js') == 'v2'
|
|
181
|
-
|
|
182
142
|
@pytest.mark.parametrize('body, diagnostic', [('', ''), ('let unused = 1;', 'warning'), ('compile_error!("broken");', 'error')])
|
|
183
143
|
def test_build_diagnostics(tmp_path, capfd, monkeypatch, body, diagnostic):
|
|
184
144
|
(tmp_path/'pyproject.toml').write_text('[tool.maturin]\n[tool.fastws]\ncargo = '+json.dumps(shutil.which('cargo'))+'\n')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import base64, csv, hashlib, io
|
|
2
2
|
from zipfile import ZipFile
|
|
3
|
-
from fastws.build_backend import build_editable
|
|
3
|
+
from fastws.build_backend import METADATA_ONLY, build_editable
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
def test_editable_wheel(tmp_path, monkeypatch):
|
|
@@ -14,7 +14,7 @@ data = "wheel"
|
|
|
14
14
|
(info/'WHEEL').write_text('Wheel-Version: 1.0\nRoot-Is-Purelib: false\nTag: py3-none-any\n')
|
|
15
15
|
(info/'METADATA').write_text('Metadata-Version: 2.1\nName: demo\nVersion: 1.0\n')
|
|
16
16
|
(info/'entry_points.txt').write_text('[console_scripts]\ndemo = demo:main\n')
|
|
17
|
-
with ZipFile(tmp_path/build_editable(tmp_path, metadata_directory=info)) as wheel:
|
|
17
|
+
with ZipFile(tmp_path/build_editable(tmp_path, config_settings={METADATA_ONLY: '1'}, metadata_directory=info)) as wheel:
|
|
18
18
|
assert wheel.read('demo-1.0.pth').decode() == str(tmp_path/'python') + '\n'
|
|
19
19
|
assert wheel.read('demo-1.0.dist-info/entry_points.txt') == (info/'entry_points.txt').read_bytes()
|
|
20
20
|
record = list(csv.reader(io.StringIO(wheel.read('demo-1.0.dist-info/RECORD').decode())))
|
|
@@ -24,16 +24,3 @@ data = "wheel"
|
|
|
24
24
|
assert digest == 'sha256=' + base64.urlsafe_b64encode(hashlib.sha256(data).digest()).rstrip(b'=').decode()
|
|
25
25
|
assert int(size) == len(data)
|
|
26
26
|
assert record[-1] == ['demo-1.0.dist-info/RECORD', '', '']
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def test_editable_wheel_bin(tmp_path, monkeypatch):
|
|
30
|
-
monkeypatch.chdir(tmp_path)
|
|
31
|
-
(tmp_path/'pyproject.toml').write_text('[tool.maturin]\nbindings = "bin"\n')
|
|
32
|
-
info = tmp_path/'demo-1.0.dist-info'
|
|
33
|
-
info.mkdir()
|
|
34
|
-
(info/'WHEEL').write_text('Wheel-Version: 1.0\nRoot-Is-Purelib: false\nTag: py3-none-any\n')
|
|
35
|
-
(info/'METADATA').write_text('Metadata-Version: 2.1\nName: demo\nVersion: 1.0\n')
|
|
36
|
-
with ZipFile(tmp_path/build_editable(tmp_path, metadata_directory=info)) as wheel:
|
|
37
|
-
assert 'demo-1.0.pth' not in wheel.namelist()
|
|
38
|
-
record = list(csv.reader(io.StringIO(wheel.read('demo-1.0.dist-info/RECORD').decode())))
|
|
39
|
-
assert {row[0] for row in record} == set(wheel.namelist())
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import os, shutil, subprocess, pytest
|
|
2
|
+
from fastws._toml import tomllib
|
|
3
|
+
import fastws.core as core
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_setup_preserves_existing_destinations(tmp_path):
|
|
7
|
+
marker = tmp_path/'keep.txt'
|
|
8
|
+
marker.write_text('personal work')
|
|
9
|
+
with pytest.raises(SystemExit, match='exists'): core.ws_setup('org/base', str(tmp_path))
|
|
10
|
+
assert marker.read_text() == 'personal work'
|
|
11
|
+
link = tmp_path/'link'
|
|
12
|
+
link.symlink_to(tmp_path/'missing')
|
|
13
|
+
with pytest.raises(SystemExit, match='exists'): core.ws_setup('org/base', str(link))
|
|
14
|
+
assert link.is_symlink() and not (tmp_path/'missing').exists()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_sccache_config_merge_and_schema(tmp_path):
|
|
18
|
+
ws1, ws2 = tmp_path/'ws1', tmp_path/'ws2'
|
|
19
|
+
ws1.mkdir(); ws2.mkdir()
|
|
20
|
+
existing = 'server_startup_timeout_ms = 5000\n\n[dist]\nscheduler_url = "http://1.2.3.4:10600"\n'
|
|
21
|
+
spec = core._parse_sccache_r2('https://r2id:r2sec@acct.r2.cloudflarestorage.com/aai-sccache')
|
|
22
|
+
rendered = core._render_sccache_config(ws1, spec, existing)
|
|
23
|
+
assert core._render_sccache_config(ws1, spec, rendered) == rendered
|
|
24
|
+
merged = core._render_sccache_config(ws2, spec, rendered)
|
|
25
|
+
data = tomllib.loads(merged)
|
|
26
|
+
assert data['server_startup_timeout_ms'] == 5000 and data['dist']['scheduler_url'] == 'http://1.2.3.4:10600'
|
|
27
|
+
assert data['basedirs'] == [str(ws1.resolve()), str(ws2.resolve())]
|
|
28
|
+
pub = core._render_sccache_config(ws1, core._parse_sccache_r2('https://acct.r2.cloudflarestorage.com/pub/pfx'), '')
|
|
29
|
+
if os.name != 'nt' and (sc := shutil.which('sccache')):
|
|
30
|
+
env = {'PATH': os.environ['PATH'], 'HOME': str(tmp_path), 'SCCACHE_SERVER_UDS': str(tmp_path/'sc.sock')}
|
|
31
|
+
for name, text in (('auth', merged), ('pub', pub)):
|
|
32
|
+
cfg = tmp_path/f'{name}.toml'
|
|
33
|
+
cfg.write_text(text)
|
|
34
|
+
r = subprocess.run([sc, '--stop-server'], env=env | {'SCCACHE_CONF': str(cfg)}, capture_output=True, text=True)
|
|
35
|
+
assert 'Stopping sccache server' in r.stdout, r.stderr
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import json, os, sys, pytest
|
|
1
|
+
import json, os, subprocess, sys, pytest
|
|
2
2
|
from fastgit import Git
|
|
3
3
|
import fastws.core as core
|
|
4
4
|
|
|
@@ -93,13 +93,15 @@ def test_sync_extras_preserves_constraints_markers_and_unrelated_settings(tmp_pa
|
|
|
93
93
|
|
|
94
94
|
@pytest.mark.skipif(os.name == 'nt', reason='Windows has no timing lock, so no rustc-lock script')
|
|
95
95
|
def test_rustc_wrapper_keeps_another_tools_wrapper(tmp_path):
|
|
96
|
-
config, script = tmp_path/'.cargo'/'config.toml', tmp_path/'.cargo'/'rustc-lock'
|
|
96
|
+
config, script, wrap = tmp_path/'.cargo'/'config.toml', tmp_path/'.cargo'/'rustc-lock', tmp_path/'wrap'
|
|
97
|
+
wrap.write_text('#!/bin/sh\nprintf "wrapped:%s" "$*"\n')
|
|
98
|
+
wrap.chmod(0o755)
|
|
97
99
|
config.parent.mkdir()
|
|
98
|
-
config.write_text('[build]\nrustc-wrapper = "
|
|
100
|
+
config.write_text(f'[build]\nrustc-wrapper = "{wrap}"\n')
|
|
99
101
|
for _ in range(2):
|
|
100
102
|
core._sync_cargo_wrapper(tmp_path)
|
|
101
|
-
assert
|
|
102
|
-
assert
|
|
103
|
+
assert core.tomllib.loads(config.read_text())['build']['rustc-wrapper'] == str(script)
|
|
104
|
+
assert subprocess.run([str(script), 'hi'], capture_output=True, text=True, check=True).stdout == 'wrapped:hi'
|
|
103
105
|
|
|
104
106
|
|
|
105
107
|
def test_remove_from_pyproject(tmp_path):
|
|
@@ -175,7 +177,6 @@ def test_sync_ws_pnpm_workspace_and_package_json(tmp_path):
|
|
|
175
177
|
data = core._yaml_load(ws)
|
|
176
178
|
assert data['packages'] == ['../outside', 'tools/*', 'app']
|
|
177
179
|
assert data['allowBuilds'] == {'other': False, 'esbuild': True}
|
|
178
|
-
assert data['linkWorkspacePackages'] == 'deep' and data['preferWorkspacePackages'] is True and data['minimumReleaseAge'] == 1440
|
|
179
180
|
assert 'overrides' not in data
|
|
180
181
|
|
|
181
182
|
ws.write_text(ws.read_text() + 'overrides:\n keep: 1.0.0\n vite: npm:@voidzero-dev/vite-plus-core@8.0.0\n vitest: 4.0.0\n')
|
|
@@ -199,3 +200,21 @@ def test_sync_ws_pnpm_workspace_and_package_json(tmp_path):
|
|
|
199
200
|
pkg_shared.write_text(json.dumps({'packageManager': 'pnpm@10.34.9', 'devDependencies': {'vite-plus': '1.7.0'}}))
|
|
200
201
|
assert core._sync_ws_package_json(tmp_path, toolchain=tc) is True
|
|
201
202
|
assert json.loads(pkg.read_text())['devDependencies'] == {'keep': '1', 'vite-plus': '1.7.0'}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def test_sync_build_backend(tmp_path):
|
|
206
|
+
ws = tmp_path/'pyproject.toml'
|
|
207
|
+
ws.write_text('[project]\nname = "ws"\n\n[tool.uv.config-settings-package]\na = { "maturin.build-args" = ["--features", "x"] }\nb = { metadata-only = "1", custom = "yes" }\ngone = { metadata-only = "1" }\n')
|
|
208
|
+
a, b = tmp_path/'a', tmp_path/'b'
|
|
209
|
+
a.mkdir(); b.mkdir()
|
|
210
|
+
(a/'pyproject.toml').write_text('[build-system]\nbuild-backend = "fastws.build_backend"\n[project]\nname = "a"\n')
|
|
211
|
+
(b/'pyproject.toml').write_text('[build-system]\nbuild-backend = "maturin"\n[project]\nname = "b"\n')
|
|
212
|
+
core._sync_build_backend(ws, [('a', a), ('b', b)])
|
|
213
|
+
uv = core.tomllib.loads(ws.read_text())['tool']['uv']
|
|
214
|
+
assert uv['no-build-isolation-package'] == ['a']
|
|
215
|
+
assert uv['config-settings-package'] == {'a': {'maturin.build-args': ['--features', 'x'], 'metadata-only': '1'}, 'b': {'custom': 'yes'}}
|
|
216
|
+
(a/'pyproject.toml').write_text('[build-system]\nbuild-backend = "maturin"\n[project]\nname = "a"\n')
|
|
217
|
+
ws.write_text('[project]\nname = "ws"\n\n[tool.uv]\nno-build-isolation-package = ["a"]\n\n[tool.uv.config-settings-package]\na = { metadata-only = "1" }\n')
|
|
218
|
+
core._sync_build_backend(ws, [('a', a), ('b', b)])
|
|
219
|
+
uv = core.tomllib.loads(ws.read_text())['tool']['uv']
|
|
220
|
+
assert uv['no-build-isolation-package'] == [] and 'config-settings-package' not in uv
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
import fastws.core as core
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def test_setup_preserves_existing_destinations(tmp_path):
|
|
6
|
-
marker = tmp_path/'keep.txt'
|
|
7
|
-
marker.write_text('personal work')
|
|
8
|
-
with pytest.raises(SystemExit, match='exists'): core.ws_setup('org/base', str(tmp_path))
|
|
9
|
-
assert marker.read_text() == 'personal work'
|
|
10
|
-
link = tmp_path/'link'
|
|
11
|
-
link.symlink_to(tmp_path/'missing')
|
|
12
|
-
with pytest.raises(SystemExit, match='exists'): core.ws_setup('org/base', str(link))
|
|
13
|
-
assert link.is_symlink() and not (tmp_path/'missing').exists()
|
|
14
|
-
|
|
15
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|