fastws-cli 0.0.35__tar.gz → 0.0.37__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.
Files changed (33) hide show
  1. {fastws_cli-0.0.35/fastws_cli.egg-info → fastws_cli-0.0.37}/PKG-INFO +33 -16
  2. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/README.md +31 -15
  3. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/fastws/__init__.py +3 -1
  4. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/fastws/cargo.py +59 -21
  5. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/fastws/core.py +312 -108
  6. {fastws_cli-0.0.35 → fastws_cli-0.0.37/fastws_cli.egg-info}/PKG-INFO +33 -16
  7. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/fastws_cli.egg-info/requires.txt +1 -0
  8. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/pyproject.toml +2 -0
  9. fastws_cli-0.0.37/tests/test_build.py +320 -0
  10. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/tests/test_integrate.py +6 -1
  11. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/tests/test_sync.py +32 -14
  12. fastws_cli-0.0.35/tests/test_build.py +0 -137
  13. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/LICENSE +0 -0
  14. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/fastws/_toml.py +0 -0
  15. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/fastws/build_backend.py +0 -0
  16. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/fastws/integrate.py +0 -0
  17. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/fastws/news.py +0 -0
  18. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/fastws/procs.py +0 -0
  19. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/fastws/releases.py +0 -0
  20. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/fastws/store.py +0 -0
  21. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/fastws/timelock.py +0 -0
  22. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/fastws_cli.egg-info/SOURCES.txt +0 -0
  23. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/fastws_cli.egg-info/dependency_links.txt +0 -0
  24. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/fastws_cli.egg-info/entry_points.txt +0 -0
  25. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/fastws_cli.egg-info/top_level.txt +0 -0
  26. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/setup.cfg +0 -0
  27. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/tests/test_build_backend.py +0 -0
  28. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/tests/test_news.py +0 -0
  29. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/tests/test_procs.py +0 -0
  30. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/tests/test_releases.py +0 -0
  31. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/tests/test_setup.py +0 -0
  32. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/tests/test_store.py +0 -0
  33. {fastws_cli-0.0.35 → fastws_cli-0.0.37}/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.35
3
+ Version: 0.0.37
4
4
  Summary: Fast workspace tools for multi-repo management
5
5
  Author: Jeremy Howard
6
6
  License-Expression: Apache-2.0
@@ -14,6 +14,7 @@ Requires-Dist: fastcore>=2.2.33
14
14
  Requires-Dist: fastgit>=0.1.2
15
15
  Requires-Dist: ghapi>=2.0.6
16
16
  Requires-Dist: packaging
17
+ Requires-Dist: pyyaml
17
18
  Requires-Dist: rich
18
19
  Requires-Dist: maturin<2.0,>=1.13
19
20
  Requires-Dist: tomli; python_version < "3.11"
@@ -100,7 +101,7 @@ Extras from duplicate entries in `repos.txt` and `repos-local.txt` are combined.
100
101
 
101
102
  Keep `repos.txt` tracked in the workspace Git repo. Put personal additions in a gitignored `repos-local.txt`, using the same format. Every command reads both lists. `ws-add` and automatic discovery append only to the local list. Edit the shared list deliberately when changing the team's baseline. Duplicate repo names are matched case-insensitively. Conflicting explicit locations, or two different repos targeting the same directory, cause errors.
102
103
 
103
- `--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. External checkouts also remain on disk; add them to the local list to keep managing them.
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.
104
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, and build-isolation list. 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):
106
107
 
@@ -108,7 +109,8 @@ The workspace `pyproject.toml` is local generated state. `ws-sync` creates it fr
108
109
  /repos-local.txt
109
110
  /pyproject.toml
110
111
  /package.json
111
- /package-lock.json
112
+ /pnpm-workspace.yaml
113
+ /pnpm-lock.yaml
112
114
  /node_modules/
113
115
  /pyrightconfig.json
114
116
  /uv.lock
@@ -185,7 +187,11 @@ ws-branches --expected develop
185
187
 
186
188
  ### `ws-build`
187
189
 
188
- Build an sdist of each workspace project, including `repos.txt` checkouts outside the root, into `.dists` or a specified output directory. A project is rebuilt only when a file in it is newer than its existing sdist. Rebuilding removes older versions of that package from the output directory. A failed build produces a warning and does not stop the other builds. The command exits with status 1 if any project failed.
190
+ Build Python sdists and npm tarballs into `.dists` or a specified output directory. JavaScript packages use the same workspace discovery as sync; a non-private package needs a name and version to produce an npm artifact. Private or versionless packages still participate in builds, and mixed Python/JavaScript packages produce both formats when applicable.
191
+
192
+ For any selected WebAssembly package (`[tool.fastws].wasm-package`), `ws-build` invokes `cargo develop` (for mixed Maturin repos) and `cargo wasm` first so Cargo's own dependency tracking keeps generated outputs fresh across sibling crates, while unrelated WebAssembly crates outside the selected closure are skipped using static metadata. If all selected artifacts are current, skip JavaScript builds and packaging. Otherwise run the selected packages' declared JavaScript builds in topological order via pnpm (`pnpm -r` or `pnpm --filter`), then check freshness again before packaging. This prepares shared assets before either distribution is packaged without rerunning generators on a no-op build. A generated JavaScript consumer also considers its local JS dependencies and the active root `pnpm-lock.yaml`. Changes to an ordinary Python runtime dependency do not invalidate every dependent sdist. Packaging uses `uv build --sdist` and `vp pm pack`.
193
+
194
+ Each artifact is staged separately and promoted only after a successful package command. Rebuilding removes older versions of that package, leaving unrelated artifacts alone. A packaging failure reports a warning and does not stop independent packaging jobs; a preparatory build failure stops before packaging. The command exits nonzero on failure.
189
195
 
190
196
  Progress goes to stderr. On success, the output directory path goes to stdout. Scripts can use `$(ws-build)` to build the packages and obtain that path. Use the distributions with a resolver such as `uv pip install --find-links`, or in a Docker build context that needs unreleased workspace packages:
191
197
 
@@ -196,7 +202,7 @@ ws-build --out /tmp/dists
196
202
  ws-build --project solveit # only this package and its transitive workspace dependencies
197
203
  ```
198
204
 
199
- `--project` selects by package name and follows declared runtime and build dependencies, including workspace packages in external checkouts. Other packages in the output directory are left untouched. Without it, the whole workspace is built as before.
205
+ `--project` accepts a Python or npm package name. Selection follows local Python runtime/build dependencies and JS runtime/development/optional dependencies, joining both sets for co-located packages. External registered projects and declared nested workspaces participate too. Other packages in the output directory are left untouched. Without it, the whole workspace is selected.
200
206
 
201
207
  ### `cargo develop`
202
208
 
@@ -210,6 +216,12 @@ cargo develop --profile quick
210
216
 
211
217
  Run from the project root, or give its directory with `--path`. The command reads `python-source`, `module-name`, `manifest-path` and features from `[tool.maturin]`. `[tool.fastws] dev-profile = "quick"` selects a project's default for both `cargo develop` and `fastws.cargo.run_tests`. Without that setting they use `test`. An explicit `--profile NAME` overrides the project default. The project must produce a `cdylib` and set `python-source`. Define the selected profile in `Cargo.toml` and keep incremental compilation enabled for the local crate.
212
218
 
219
+ The workspace's `[tool.fastws] cargo = "/path/to/cargo"` optionally selects one explicit Cargo executable for fastws builds, checks, metadata and tests, including nextest's subordinate Cargo calls. A missing executable fails without falling back. With no selection, subprocess uses its normal PATH and working-directory rules. Upstream Cargo stays installed and usable; manifests, profiles, features and package selection are unchanged.
220
+
221
+ Optional workspace `cargo-target-dir` passes through Cargo's `CARGO_TARGET_DIR`. The path is absolute or relative to the fastws workspace; explicit caller/environment values win. Cargo's own `[unstable] root-dir` sets the actual common parent of local source repositories. Enable it with `fastws.core.cargo_setup(workspace, root_dir=True)`; later setup calls and integration snapshots keep it at their actual root, including sibling repositories. Cargo command-line/environment overrides keep their normal precedence. Sharing path-crate artifacts needs a Cargo that uses this root for metadata and source paths and tracks manifest-path dependencies: ordinary Cargo's `-Zroot-dir` alone is insufficient. A source root is not a virtual alias for another checkout.
222
+
223
+ Set `FASTWS_CARGO_LOG` to a file to append the raw Cargo output already captured by builds, checks and test-compilation/listing calls; no log is created by default.
224
+
213
225
  Make the initial editable installation through `ws-sync` or maturin. Repeat that installation when package metadata or entry points change. Running Python processes keep the extension they loaded.
214
226
 
215
227
  Cargo must already build a loadable Python extension. For PyO3 extension-module builds on macOS, configure the linker in `build.rs` with `pyo3_build_config::add_extension_module_link_args()`. This command does not inject maturin's extra compiler flags.
@@ -258,7 +270,7 @@ Use it when another process's unfinished edits stop the workspace compiling, suc
258
270
 
259
271
  `fastws.cargo.run_tests` builds native tests once with Cargo, without a time limit, then runs the executables that Cargo reports directly from their package directories. Each binary gets its own `timeout`, 30 seconds by default, excluding compilation. Outside `FASTWS_JOB`, a timed-out binary is reported as a failed suite with `timed_out` set. Inside a marked job, its timeout raises so the job owner can clean up descendants. Source edits between building and running do not trigger another build: the results describe the compiled build, not necessarily the latest working tree. It supports directly runnable native tests, not cross-target runners.
260
272
 
261
- Where a root has `.config/nextest.toml`, `cargo nextest run` runs the built tests instead: each test in its own process, every binary at once, with the config's slow-test timeouts and groups. `profiles` lists the nextest profiles to run one after another, `('default',)` unless given. `timeout` bounds each profile's run, and each binary's results come from nextest's JUnit report, which lists no ignored tests. `--profile NAME` passes to nextest as `--cargo-profile NAME`, and `test_args` follow `--`.
273
+ Where a root has `.config/nextest.toml`, preparation uses `cargo nextest list` to build the tests and capture Cargo and binary metadata. The metadata graph includes all features at the native platform, independently of the features selected for compilation. Each `cargo nextest run` consumes that metadata without building or waiting for Cargo's target lock. Nextest runs each test in its own process, every binary at once, with the config's slow-test timeouts and groups. `profiles` lists the nextest profiles to run one after another, `('default',)` unless given. `timeout` bounds each profile's execution, and each binary's results come from nextest's JUnit report, which lists no ignored tests. `--profile NAME` passes to the build as `--cargo-profile NAME`, and `test_args` follow `--`.
262
274
 
263
275
  `root` can also be a list of roots, which build one after another. Roots without nextest then run their binaries in turn. Each profile then runs at the same time in every root whose config defines it: tests in different roots share a phase, and no phase starts before the previous one ends. Suite names start with the root's directory name, and with several profiles also with the profile, as in `app timed: tests/speed.rs`. A failure ends the run after its profile unless `--no-fail-fast` is given.
264
276
 
@@ -311,7 +323,7 @@ Syncing proceeds in this order:
311
323
  3. Pull project updates, using the same changed-origin check as `ws-pull`.
312
324
  4. Update workspace metadata and install the projects.
313
325
 
314
- By default, `ws-sync` uses the active venv's parent as the workspace root. It creates a missing `pyproject.toml` as described above. GitHub checkouts at the root that are absent from both lists are added to `repos-local.txt`, including non-Python repos. Directories prefixed with `_` are left alone unless explicitly listed.
326
+ By default, `ws-sync` uses the active venv's parent as the workspace root. It creates a missing `pyproject.toml` as described above. GitHub checkouts at the root that are absent from both lists are added to `repos-local.txt`, including non-Python repos. Root checkouts matching `[tool.fastws].exclude` are not automatically added. Directories prefixed with `_` are left alone unless explicitly listed.
315
327
 
316
328
  Project scanning respects `tool.uv.workspace.members` and `exclude`. If a member directory lacks `pyproject.toml`, such as a fresh empty clone, sync warns and skips the `uv sync` step.
317
329
 
@@ -329,23 +341,27 @@ Sync writes `.cargo/rustc-lock` and makes it Cargo's `rustc-wrapper`. The script
329
341
 
330
342
  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.
331
343
 
332
- Fastws discovers JavaScript packages directly under the workspace root. It reads each package's `workspaces` list for declared nested packages. These lists accept paths and globs. Fastws ignores undeclared nested packages. Lockfiles do not affect discovery. `[tool.fastws].exclude` matches paths relative to the workspace root. Fastws skips `node_modules` and directories whose names start with `.` or `_`.
344
+ Fastws discovers JavaScript packages directly under the workspace root, explicitly registered external repo roots, paths or globs retained in `pnpm-workspace.yaml`, explicit nested paths declared under `[tool.fastws].js-packages` in a repo's `pyproject.toml`, and generated WebAssembly package directories declared under `[tool.fastws].wasm-package = { name = "...", path = "wasm/pkg" }` (when a repo root's own `package.json` already declares that same package name for live source exports, fastws links the repo root in `pnpm-workspace.yaml` and still builds and packs the `wasm-package` directory in `ws-build`). It also reads each package's own `workspaces` list for declared nested packages. The install, build and distribution graph use these same members; fastws does not scan arbitrary nested package files. Lockfiles do not affect discovery. `[tool.fastws].exclude` matches paths relative to the workspace root. Fastws skips `node_modules` and directories whose names start with `.` or `_`.
333
345
 
334
- Each sync updates `workspaces` in the root `package.json`. It creates the file when needed. It preserves external paths, globs, and unrelated settings. It reports added and removed packages.
346
+ Each sync updates `packages` in the root `pnpm-workspace.yaml` (creating it with `linkWorkspacePackages: deep`, `preferWorkspacePackages: true`, and `minimumReleaseAge: 1440` by default) and maintains `private: true` in the root `package.json`. It preserves external paths, globs, and unrelated settings, and reports added and removed packages.
335
347
 
336
- An optional tracked `package.json.shared` is merged into the root `package.json` 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. Workspace discovery still manages `workspaces`. Use this file for shared policy such as version-pinned npm `allowScripts` approvals.
348
+ Optional tracked `pnpm-workspace.shared.yaml` and `package.json.shared` files are merged into `pnpm-workspace.yaml` and `package.json` 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 the workspace's toolchain (`packageManager`, `devEngines.runtime`, `vite-plus`, and matching `vite`/`vitest` overrides) and shared policies such as `allowBuilds`.
337
349
 
338
350
  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`. Leave global build isolation enabled for other projects.
339
351
 
340
- After `uv sync`, fastws runs `cargo develop` in each mixed Rust/Python project. Cargo skips unchanged compilation inputs. Projects using `fastws.build_backend` should keep only packaging inputs in `tool.uv.cache-keys`; Rust source changes are handled by Cargo. Maturin packages with `bindings = "bin"` keep their existing uv installation path.
352
+ 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=""`).
353
+
354
+ After `uv sync`, fastws runs `cargo develop` in mixed Rust/Python projects, with up to one project per CPU building concurrently by default. Cargo skips unchanged compilation inputs. Projects using `fastws.build_backend` should keep only packaging inputs in `tool.uv.cache-keys`; Rust source changes are handled by Cargo. Maturin packages with `bindings = "bin"` keep their existing uv installation path.
355
+
356
+ Strictly after `cargo develop` finishes, fastws runs `cargo wasm` in parallel for every repo declaring `[tool.fastws].wasm-package`, so any `post-develop-module` generators have already produced their assets and each generated `wasm/pkg/package.json` exists before JavaScript installation.
341
357
 
342
- Fastws then runs `<tool> install` at the workspace root. It runs `<tool> run build` in each JavaScript package containing both `Cargo.toml` and a `build` script. Cargo handles incremental compilation. Other build steps still run.
358
+ Fastws then runs `vp install` at the workspace root (driving pnpm underneath). Native pnpm workspaces link local packages whose versions satisfy their consumers' ordinary dependency ranges; consumer manifests need no local paths or special workspace protocol.
343
359
 
344
- For npm, sync hides routine install summaries and build-command banners. Install warnings, audit findings, unreviewed install scripts, and failure diagnostics remain visible. Build scripts retain their own output; configure their tools to suppress routine progress. Other package managers retain their normal output.
360
+ After installation, fastws runs `pnpm -r --if-present --workspace-concurrency=<N> run build` (through Vite+'s managed pnpm) so local dependencies build before their consumers and independent builds share the project-concurrency limit. Packages own their build commands: AnswerUI's is `nbdev-export`, for example. Python sync runs first, so a repo-list entry such as `AnswerDotAI/answerui[dev]` supplies its Python build tools through the normal extras mechanism. No additional install lifecycle hook is needed. Cargo and other build tools retain their own incremental behavior.
345
361
 
346
- When Rust-backed JavaScript builds are present, fastws checks before dependency installation that `rustc` and `cargo` on `PATH` are rustup's proxies. Install rustup from https://rustup.rs and select a stable toolchain with `rustup default stable` if not already configured. If another Rust installation shadows rustup, put its bin directory first on `PATH` after Homebrew's shell setup: `export PATH="$HOME/.cargo/bin:$PATH"` (use `$CARGO_HOME/bin` for a custom Cargo home), then open a new shell. Homebrew Rust can remain installed for Homebrew's own use. Fastws reports missing or shadowed rustup without changing your shell or installing a different toolchain. Packages using wasm-pack can then install their WASM target and matching binding tools automatically as part of their build.
362
+ `--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.
347
363
 
348
- The package manager defaults to `npm`. Set `js` under `[tool.fastws]` in the workspace `pyproject.toml` to choose another executable, such as `js = "bun"`. Fastws requires a list for `workspaces` in `package.json`, following the npm format. It stops if it cannot find the selected executable.
364
+ When JavaScript workspaces are present, fastws requires Vite+ (`vp`) on `PATH` with managed `node` and `pnpm` shims active (`curl -fsSL https://vite.plus | bash`, with Vite+'s bin directory ahead of Homebrew on `PATH`). When WebAssembly packages (`[tool.fastws].wasm-package`) are present, fastws also requires rustup's `rustc`/`cargo` proxies and the `wasm32-unknown-unknown` target (`rustup target add wasm32-unknown-unknown`).
349
365
 
350
366
  At most once per day, sync upgrades dependencies with `uv sync -U` and a parallel `cargo update` in every member with a `Cargo.toml`. It prints the changes and records the run in a stamp file inside the workspace's `.git` directory. Pass `--upgrade` to force an upgrade regardless of the last run time.
351
367
 
@@ -355,6 +371,7 @@ Before every uv sync, `ws-sync` writes `.git/fastws-cargo-key` for each member c
355
371
  ws-sync
356
372
  ws-sync --workspace ~/aai-ws
357
373
  ws-sync --upgrade
374
+ ws-sync --build-workers 1
358
375
  ```
359
376
 
360
377
  ### `ws-add`
@@ -364,7 +381,7 @@ Add a repo to `repos-local.txt`, then run `ws-sync`. Repos already in either lis
364
381
  The argument determines how fastws locates the checkout:
365
382
 
366
383
  - `owner/repo` clones the repository.
367
- - An existing local folder, such as one created by `nbdev-new` or `ship-new`, uses its `origin` remote to resolve `owner/repo`. The command reports a missing Git repo, GitHub origin, or `pyproject.toml`.
384
+ - An existing local folder uses its `origin` remote to resolve `owner/repo`. It needs a `pyproject.toml`, `Cargo.toml` or `package.json`; Rust-only and JavaScript-only projects need no Python scaffold. The command reports missing project metadata, Git repo or GitHub origin.
368
385
  - A path outside the workspace root leaves the checkout in place and records its location in the local list. The checkout needs no root `pyproject.toml`. Sync discovers its packages.
369
386
 
370
387
  ```bash
@@ -72,7 +72,7 @@ Extras from duplicate entries in `repos.txt` and `repos-local.txt` are combined.
72
72
 
73
73
  Keep `repos.txt` tracked in the workspace Git repo. Put personal additions in a gitignored `repos-local.txt`, using the same format. Every command reads both lists. `ws-add` and automatic discovery append only to the local list. Edit the shared list deliberately when changing the team's baseline. Duplicate repo names are matched case-insensitively. Conflicting explicit locations, or two different repos targeting the same directory, cause errors.
74
74
 
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. External checkouts also remain on disk; add them to the local list to keep managing them.
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
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, and build-isolation list. 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
 
@@ -80,7 +80,8 @@ The workspace `pyproject.toml` is local generated state. `ws-sync` creates it fr
80
80
  /repos-local.txt
81
81
  /pyproject.toml
82
82
  /package.json
83
- /package-lock.json
83
+ /pnpm-workspace.yaml
84
+ /pnpm-lock.yaml
84
85
  /node_modules/
85
86
  /pyrightconfig.json
86
87
  /uv.lock
@@ -157,7 +158,11 @@ ws-branches --expected develop
157
158
 
158
159
  ### `ws-build`
159
160
 
160
- Build an sdist of each workspace project, including `repos.txt` checkouts outside the root, into `.dists` or a specified output directory. A project is rebuilt only when a file in it is newer than its existing sdist. Rebuilding removes older versions of that package from the output directory. A failed build produces a warning and does not stop the other builds. The command exits with status 1 if any project failed.
161
+ Build Python sdists and npm tarballs into `.dists` or a specified output directory. JavaScript packages use the same workspace discovery as sync; a non-private package needs a name and version to produce an npm artifact. Private or versionless packages still participate in builds, and mixed Python/JavaScript packages produce both formats when applicable.
162
+
163
+ For any selected WebAssembly package (`[tool.fastws].wasm-package`), `ws-build` invokes `cargo develop` (for mixed Maturin repos) and `cargo wasm` first so Cargo's own dependency tracking keeps generated outputs fresh across sibling crates, while unrelated WebAssembly crates outside the selected closure are skipped using static metadata. If all selected artifacts are current, skip JavaScript builds and packaging. Otherwise run the selected packages' declared JavaScript builds in topological order via pnpm (`pnpm -r` or `pnpm --filter`), then check freshness again before packaging. This prepares shared assets before either distribution is packaged without rerunning generators on a no-op build. A generated JavaScript consumer also considers its local JS dependencies and the active root `pnpm-lock.yaml`. Changes to an ordinary Python runtime dependency do not invalidate every dependent sdist. Packaging uses `uv build --sdist` and `vp pm pack`.
164
+
165
+ Each artifact is staged separately and promoted only after a successful package command. Rebuilding removes older versions of that package, leaving unrelated artifacts alone. A packaging failure reports a warning and does not stop independent packaging jobs; a preparatory build failure stops before packaging. The command exits nonzero on failure.
161
166
 
162
167
  Progress goes to stderr. On success, the output directory path goes to stdout. Scripts can use `$(ws-build)` to build the packages and obtain that path. Use the distributions with a resolver such as `uv pip install --find-links`, or in a Docker build context that needs unreleased workspace packages:
163
168
 
@@ -168,7 +173,7 @@ ws-build --out /tmp/dists
168
173
  ws-build --project solveit # only this package and its transitive workspace dependencies
169
174
  ```
170
175
 
171
- `--project` selects by package name and follows declared runtime and build dependencies, including workspace packages in external checkouts. Other packages in the output directory are left untouched. Without it, the whole workspace is built as before.
176
+ `--project` accepts a Python or npm package name. Selection follows local Python runtime/build dependencies and JS runtime/development/optional dependencies, joining both sets for co-located packages. External registered projects and declared nested workspaces participate too. Other packages in the output directory are left untouched. Without it, the whole workspace is selected.
172
177
 
173
178
  ### `cargo develop`
174
179
 
@@ -182,6 +187,12 @@ cargo develop --profile quick
182
187
 
183
188
  Run from the project root, or give its directory with `--path`. The command reads `python-source`, `module-name`, `manifest-path` and features from `[tool.maturin]`. `[tool.fastws] dev-profile = "quick"` selects a project's default for both `cargo develop` and `fastws.cargo.run_tests`. Without that setting they use `test`. An explicit `--profile NAME` overrides the project default. The project must produce a `cdylib` and set `python-source`. Define the selected profile in `Cargo.toml` and keep incremental compilation enabled for the local crate.
184
189
 
190
+ The workspace's `[tool.fastws] cargo = "/path/to/cargo"` optionally selects one explicit Cargo executable for fastws builds, checks, metadata and tests, including nextest's subordinate Cargo calls. A missing executable fails without falling back. With no selection, subprocess uses its normal PATH and working-directory rules. Upstream Cargo stays installed and usable; manifests, profiles, features and package selection are unchanged.
191
+
192
+ Optional workspace `cargo-target-dir` passes through Cargo's `CARGO_TARGET_DIR`. The path is absolute or relative to the fastws workspace; explicit caller/environment values win. Cargo's own `[unstable] root-dir` sets the actual common parent of local source repositories. Enable it with `fastws.core.cargo_setup(workspace, root_dir=True)`; later setup calls and integration snapshots keep it at their actual root, including sibling repositories. Cargo command-line/environment overrides keep their normal precedence. Sharing path-crate artifacts needs a Cargo that uses this root for metadata and source paths and tracks manifest-path dependencies: ordinary Cargo's `-Zroot-dir` alone is insufficient. A source root is not a virtual alias for another checkout.
193
+
194
+ Set `FASTWS_CARGO_LOG` to a file to append the raw Cargo output already captured by builds, checks and test-compilation/listing calls; no log is created by default.
195
+
185
196
  Make the initial editable installation through `ws-sync` or maturin. Repeat that installation when package metadata or entry points change. Running Python processes keep the extension they loaded.
186
197
 
187
198
  Cargo must already build a loadable Python extension. For PyO3 extension-module builds on macOS, configure the linker in `build.rs` with `pyo3_build_config::add_extension_module_link_args()`. This command does not inject maturin's extra compiler flags.
@@ -230,7 +241,7 @@ Use it when another process's unfinished edits stop the workspace compiling, suc
230
241
 
231
242
  `fastws.cargo.run_tests` builds native tests once with Cargo, without a time limit, then runs the executables that Cargo reports directly from their package directories. Each binary gets its own `timeout`, 30 seconds by default, excluding compilation. Outside `FASTWS_JOB`, a timed-out binary is reported as a failed suite with `timed_out` set. Inside a marked job, its timeout raises so the job owner can clean up descendants. Source edits between building and running do not trigger another build: the results describe the compiled build, not necessarily the latest working tree. It supports directly runnable native tests, not cross-target runners.
232
243
 
233
- Where a root has `.config/nextest.toml`, `cargo nextest run` runs the built tests instead: each test in its own process, every binary at once, with the config's slow-test timeouts and groups. `profiles` lists the nextest profiles to run one after another, `('default',)` unless given. `timeout` bounds each profile's run, and each binary's results come from nextest's JUnit report, which lists no ignored tests. `--profile NAME` passes to nextest as `--cargo-profile NAME`, and `test_args` follow `--`.
244
+ Where a root has `.config/nextest.toml`, preparation uses `cargo nextest list` to build the tests and capture Cargo and binary metadata. The metadata graph includes all features at the native platform, independently of the features selected for compilation. Each `cargo nextest run` consumes that metadata without building or waiting for Cargo's target lock. Nextest runs each test in its own process, every binary at once, with the config's slow-test timeouts and groups. `profiles` lists the nextest profiles to run one after another, `('default',)` unless given. `timeout` bounds each profile's execution, and each binary's results come from nextest's JUnit report, which lists no ignored tests. `--profile NAME` passes to the build as `--cargo-profile NAME`, and `test_args` follow `--`.
234
245
 
235
246
  `root` can also be a list of roots, which build one after another. Roots without nextest then run their binaries in turn. Each profile then runs at the same time in every root whose config defines it: tests in different roots share a phase, and no phase starts before the previous one ends. Suite names start with the root's directory name, and with several profiles also with the profile, as in `app timed: tests/speed.rs`. A failure ends the run after its profile unless `--no-fail-fast` is given.
236
247
 
@@ -283,7 +294,7 @@ Syncing proceeds in this order:
283
294
  3. Pull project updates, using the same changed-origin check as `ws-pull`.
284
295
  4. Update workspace metadata and install the projects.
285
296
 
286
- By default, `ws-sync` uses the active venv's parent as the workspace root. It creates a missing `pyproject.toml` as described above. GitHub checkouts at the root that are absent from both lists are added to `repos-local.txt`, including non-Python repos. Directories prefixed with `_` are left alone unless explicitly listed.
297
+ By default, `ws-sync` uses the active venv's parent as the workspace root. It creates a missing `pyproject.toml` as described above. GitHub checkouts at the root that are absent from both lists are added to `repos-local.txt`, including non-Python repos. Root checkouts matching `[tool.fastws].exclude` are not automatically added. Directories prefixed with `_` are left alone unless explicitly listed.
287
298
 
288
299
  Project scanning respects `tool.uv.workspace.members` and `exclude`. If a member directory lacks `pyproject.toml`, such as a fresh empty clone, sync warns and skips the `uv sync` step.
289
300
 
@@ -301,23 +312,27 @@ Sync writes `.cargo/rustc-lock` and makes it Cargo's `rustc-wrapper`. The script
301
312
 
302
313
  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.
303
314
 
304
- Fastws discovers JavaScript packages directly under the workspace root. It reads each package's `workspaces` list for declared nested packages. These lists accept paths and globs. Fastws ignores undeclared nested packages. Lockfiles do not affect discovery. `[tool.fastws].exclude` matches paths relative to the workspace root. Fastws skips `node_modules` and directories whose names start with `.` or `_`.
315
+ Fastws discovers JavaScript packages directly under the workspace root, explicitly registered external repo roots, paths or globs retained in `pnpm-workspace.yaml`, explicit nested paths declared under `[tool.fastws].js-packages` in a repo's `pyproject.toml`, and generated WebAssembly package directories declared under `[tool.fastws].wasm-package = { name = "...", path = "wasm/pkg" }` (when a repo root's own `package.json` already declares that same package name for live source exports, fastws links the repo root in `pnpm-workspace.yaml` and still builds and packs the `wasm-package` directory in `ws-build`). It also reads each package's own `workspaces` list for declared nested packages. The install, build and distribution graph use these same members; fastws does not scan arbitrary nested package files. Lockfiles do not affect discovery. `[tool.fastws].exclude` matches paths relative to the workspace root. Fastws skips `node_modules` and directories whose names start with `.` or `_`.
305
316
 
306
- Each sync updates `workspaces` in the root `package.json`. It creates the file when needed. It preserves external paths, globs, and unrelated settings. It reports added and removed packages.
317
+ Each sync updates `packages` in the root `pnpm-workspace.yaml` (creating it with `linkWorkspacePackages: deep`, `preferWorkspacePackages: true`, and `minimumReleaseAge: 1440` by default) and maintains `private: true` in the root `package.json`. It preserves external paths, globs, and unrelated settings, and reports added and removed packages.
307
318
 
308
- An optional tracked `package.json.shared` is merged into the root `package.json` 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. Workspace discovery still manages `workspaces`. Use this file for shared policy such as version-pinned npm `allowScripts` approvals.
319
+ Optional tracked `pnpm-workspace.shared.yaml` and `package.json.shared` files are merged into `pnpm-workspace.yaml` and `package.json` 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 the workspace's toolchain (`packageManager`, `devEngines.runtime`, `vite-plus`, and matching `vite`/`vitest` overrides) and shared policies such as `allowBuilds`.
309
320
 
310
321
  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`. Leave global build isolation enabled for other projects.
311
322
 
312
- After `uv sync`, fastws runs `cargo develop` in each mixed Rust/Python project. Cargo skips unchanged compilation inputs. Projects using `fastws.build_backend` should keep only packaging inputs in `tool.uv.cache-keys`; Rust source changes are handled by Cargo. Maturin packages with `bindings = "bin"` keep their existing uv installation path.
323
+ 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=""`).
324
+
325
+ After `uv sync`, fastws runs `cargo develop` in mixed Rust/Python projects, with up to one project per CPU building concurrently by default. Cargo skips unchanged compilation inputs. Projects using `fastws.build_backend` should keep only packaging inputs in `tool.uv.cache-keys`; Rust source changes are handled by Cargo. Maturin packages with `bindings = "bin"` keep their existing uv installation path.
326
+
327
+ Strictly after `cargo develop` finishes, fastws runs `cargo wasm` in parallel for every repo declaring `[tool.fastws].wasm-package`, so any `post-develop-module` generators have already produced their assets and each generated `wasm/pkg/package.json` exists before JavaScript installation.
313
328
 
314
- Fastws then runs `<tool> install` at the workspace root. It runs `<tool> run build` in each JavaScript package containing both `Cargo.toml` and a `build` script. Cargo handles incremental compilation. Other build steps still run.
329
+ Fastws then runs `vp install` at the workspace root (driving pnpm underneath). Native pnpm workspaces link local packages whose versions satisfy their consumers' ordinary dependency ranges; consumer manifests need no local paths or special workspace protocol.
315
330
 
316
- For npm, sync hides routine install summaries and build-command banners. Install warnings, audit findings, unreviewed install scripts, and failure diagnostics remain visible. Build scripts retain their own output; configure their tools to suppress routine progress. Other package managers retain their normal output.
331
+ After installation, fastws runs `pnpm -r --if-present --workspace-concurrency=<N> run build` (through Vite+'s managed pnpm) so local dependencies build before their consumers and independent builds share the project-concurrency limit. Packages own their build commands: AnswerUI's is `nbdev-export`, for example. Python sync runs first, so a repo-list entry such as `AnswerDotAI/answerui[dev]` supplies its Python build tools through the normal extras mechanism. No additional install lifecycle hook is needed. Cargo and other build tools retain their own incremental behavior.
317
332
 
318
- When Rust-backed JavaScript builds are present, fastws checks before dependency installation that `rustc` and `cargo` on `PATH` are rustup's proxies. Install rustup from https://rustup.rs and select a stable toolchain with `rustup default stable` if not already configured. If another Rust installation shadows rustup, put its bin directory first on `PATH` after Homebrew's shell setup: `export PATH="$HOME/.cargo/bin:$PATH"` (use `$CARGO_HOME/bin` for a custom Cargo home), then open a new shell. Homebrew Rust can remain installed for Homebrew's own use. Fastws reports missing or shadowed rustup without changing your shell or installing a different toolchain. Packages using wasm-pack can then install their WASM target and matching binding tools automatically as part of their build.
333
+ `--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.
319
334
 
320
- The package manager defaults to `npm`. Set `js` under `[tool.fastws]` in the workspace `pyproject.toml` to choose another executable, such as `js = "bun"`. Fastws requires a list for `workspaces` in `package.json`, following the npm format. It stops if it cannot find the selected executable.
335
+ When JavaScript workspaces are present, fastws requires Vite+ (`vp`) on `PATH` with managed `node` and `pnpm` shims active (`curl -fsSL https://vite.plus | bash`, with Vite+'s bin directory ahead of Homebrew on `PATH`). When WebAssembly packages (`[tool.fastws].wasm-package`) are present, fastws also requires rustup's `rustc`/`cargo` proxies and the `wasm32-unknown-unknown` target (`rustup target add wasm32-unknown-unknown`).
321
336
 
322
337
  At most once per day, sync upgrades dependencies with `uv sync -U` and a parallel `cargo update` in every member with a `Cargo.toml`. It prints the changes and records the run in a stamp file inside the workspace's `.git` directory. Pass `--upgrade` to force an upgrade regardless of the last run time.
323
338
 
@@ -327,6 +342,7 @@ Before every uv sync, `ws-sync` writes `.git/fastws-cargo-key` for each member c
327
342
  ws-sync
328
343
  ws-sync --workspace ~/aai-ws
329
344
  ws-sync --upgrade
345
+ ws-sync --build-workers 1
330
346
  ```
331
347
 
332
348
  ### `ws-add`
@@ -336,7 +352,7 @@ Add a repo to `repos-local.txt`, then run `ws-sync`. Repos already in either lis
336
352
  The argument determines how fastws locates the checkout:
337
353
 
338
354
  - `owner/repo` clones the repository.
339
- - An existing local folder, such as one created by `nbdev-new` or `ship-new`, uses its `origin` remote to resolve `owner/repo`. The command reports a missing Git repo, GitHub origin, or `pyproject.toml`.
355
+ - An existing local folder uses its `origin` remote to resolve `owner/repo`. It needs a `pyproject.toml`, `Cargo.toml` or `package.json`; Rust-only and JavaScript-only projects need no Python scaffold. The command reports missing project metadata, Git repo or GitHub origin.
340
356
  - A path outside the workspace root leaves the checkout in place and records its location in the local list. The checkout needs no root `pyproject.toml`. Sync discovers its packages.
341
357
 
342
358
  ```bash
@@ -1,4 +1,6 @@
1
- __version__ = "0.0.35"
1
+ __version__ = "0.0.37"
2
+
3
+
2
4
 
3
5
 
4
6
 
@@ -24,9 +24,21 @@ def _dev_profile(root):
24
24
  return settings(root).get('fastws', {}).get('dev-profile', 'test') if (root/'pyproject.toml').exists() else 'test'
25
25
 
26
26
 
27
- def cargo(root, *args):
27
+ def _cargo_command(*args, env=None):
28
+ "One Cargo and optional shared paths for every launch, including nextest's subordinate Cargo calls."
29
+ from .core import _fastws_cfg, _ws_root
30
+ environment = os.environ | (env or {})
31
+ workspace = _ws_root()
32
+ cfg = _fastws_cfg(workspace)
33
+ configured = cfg.get('cargo')
34
+ executable = str(workspace/Path(configured).expanduser()) if configured else 'cargo'
35
+ if 'cargo-target-dir' in cfg: environment.setdefault('CARGO_TARGET_DIR', str(workspace/Path(cfg['cargo-target-dir']).expanduser()))
36
+ return [executable, *args], environment | {'CARGO': executable}
37
+
38
+ def cargo(root, *args, env=None):
28
39
  "Run Cargo in the project and return its standard output. A failure raises `CalledProcessError`, holding Cargo's standard error."
29
- return subprocess.run(['cargo', *args], cwd=Path(root).expanduser(), capture_output=True, text=True, check=True).stdout
40
+ cmd, env = _cargo_command(*args, env=env)
41
+ return subprocess.run(cmd, cwd=Path(root).expanduser(), env=env, text=True, capture_output=True, check=True).stdout
30
42
 
31
43
 
32
44
  def members(root):
@@ -47,19 +59,25 @@ class Diagnostic(NamedTuple):
47
59
 
48
60
  def _run(root, args, env=None, diagnostics=True):
49
61
  "Run the Cargo subcommand and options `args` in `root`, with the environment variables `env` set: its exit status, its output, each `Diagnostic` once, and Cargo's other JSON messages, such as artifacts. With `diagnostics`, Cargo writes JSON messages and the output renders each compiler message short; without, the output is as Cargo printed it."
50
- flags = ('--message-format=json-diagnostic-short',) if diagnostics else ()
51
- p = bounded(['cargo', args[0], *flags, *args[1:]], seconds=None, merge=True, cwd=root, env=os.environ | (env or {}))
52
- if not diagnostics: return p.returncode, p.stdout, [], []
62
+ nextest = args[0] == 'nextest'
63
+ flags = (('--cargo-message-format=json,json-diagnostic-short' if nextest else '--message-format=json-diagnostic-short'),) if diagnostics else ()
64
+ at = 2 if nextest else 1
65
+ cmd, env = _cargo_command(*args[:at], *flags, *args[at:], env=env)
66
+ # nextest's final JSON can lack a newline; stderr must not join its records.
67
+ p = bounded(cmd, seconds=None, merge=False, cwd=root, env=env)
68
+ if log := env.get('FASTWS_CARGO_LOG'):
69
+ with Path(log).expanduser().open('a') as capture: capture.write(p.stdout + '\n' + p.stderr)
70
+ if not diagnostics: return p.returncode, p.stdout + p.stderr, [], []
53
71
  text, found, rest = [], [], []
54
72
  for line in p.stdout.splitlines(keepends=True):
55
73
  if not line.startswith('{'): text.append(line); continue
56
74
  m = json.loads(line)
57
- if m['reason'] != 'compiler-message': rest.append(m); continue
75
+ if m.get('reason') != 'compiler-message': rest.append(m); continue
58
76
  msg = m['message']
59
77
  text.append(msg['rendered'])
60
78
  if s := next((s for s in msg['spans'] if s['is_primary']), None):
61
79
  found.append(Diagnostic(s['file_name'], s['line_start'], s['column_start'], msg['level'], msg['message'], (msg['code'] or {}).get('code')))
62
- return p.returncode, ''.join(text), list(dict.fromkeys(found)), rest
80
+ return p.returncode, ''.join(text) + p.stderr, list(dict.fromkeys(found)), rest
63
81
 
64
82
 
65
83
  def _lines(text, n=20, tail=False):
@@ -181,17 +199,23 @@ def _junit(path, names):
181
199
  return suites
182
200
 
183
201
 
184
- def _nextest(root, args, test_args, env, timeout, artifacts, profile='default'):
185
- "Run the built tests with `cargo nextest run --profile profile` under `timeout` as a whole: its exit status, its output, each binary's `Suite` and the run's seconds. Cargo's `--profile` in `args` becomes nextest's `--cargo-profile`."
186
- packages = {p['id']: p['name'] for p in json.loads(cargo(root, 'metadata', '--format-version', '1', '--no-deps'))['packages']}
202
+ def _nextest(root, args, test_args, env, timeout, artifacts, reuse, profile='default'):
203
+ "Run captured test binaries without entering Cargo's build phase, under the profile's execution timeout."
204
+ metadata, binaries = reuse
205
+ packages = {p['id']: p['name'] for p in metadata['packages']}
187
206
  names = {_binary_id(m, packages): _suite_name(m) for m in artifacts}
188
- args = [re.sub(r'^--profile(?==|$)', '--cargo-profile', a) for a in map(str, args)]
189
207
  with tempfile.TemporaryDirectory() as d:
190
208
  report, tool = Path(d)/'junit.xml', Path(d)/'fastws.toml'
209
+ cargo_meta, binary_meta = Path(d)/'cargo.json', Path(d)/'binaries.json'
210
+ cargo_meta.write_text(json.dumps(metadata))
211
+ binary_meta.write_text(json.dumps(binaries))
191
212
  tool.write_text(f'[profile.{profile}.junit]\npath = {json.dumps(str(report))}\n')
192
- cmd = ['cargo', 'nextest', 'run', '--tool-config-file', f'fastws:{tool}', '--profile', profile, '--show-progress=none', '--color=never', *args, *(('--', *test_args) if test_args else ())]
213
+ flags = ('--no-fail-fast',) if '--no-fail-fast' in args else ()
214
+ cmd, env = _cargo_command('nextest', 'run', '--cargo-metadata', cargo_meta, '--binaries-metadata', binary_meta,
215
+ '--tool-config-file', f'fastws:{tool}', '--profile', profile, '--show-progress=none', '--color=never', *flags,
216
+ *(('--', *test_args) if test_args else ()), env=env)
193
217
  start = time.monotonic()
194
- p, late = _bounded(cmd, timeout, cwd=root, env=os.environ | env)
218
+ p, late = _bounded(cmd, timeout, cwd=root, env=env)
195
219
  suites = _junit(report, names) if report.exists() else [Suite('nextest', p.stdout, {}, {}, '', True, late)]
196
220
  return p.returncode, p.stdout, suites, time.monotonic() - start
197
221
 
@@ -231,26 +255,37 @@ def run_tests(
231
255
  text, found, built = '', [], []
232
256
  for r in roots:
233
257
  rargs = args if has_profile else (*args, '--profile', _dev_profile(r))
234
- code, out, diags, rest = _run(r, ('test', '--no-run', *rargs), env)
258
+ defined, reuse = _nextest_profiles(r), None
259
+ if defined is None: code, out, diags, rest = _run(r, ('test', '--no-run', *rargs), env)
260
+ else:
261
+ flags = [re.sub(r'^--profile(?==|$)', '--cargo-profile', str(a)) for a in rargs if a != '--no-fail-fast']
262
+ code, out, diags, rest = _run(r, ('nextest', 'list', '--list-type=binaries-only', '--message-format=json', '--ignore-default-filter', *flags), env)
263
+ if not code:
264
+ binaries, = (m for m in rest if 'reason' not in m)
265
+ host = binaries['rust-build-meta']['platforms']['host']['platform']['triple']
266
+ # Package filters use nextest's all-feature graph, not the features selected for compilation.
267
+ try: metadata = json.loads(cargo(r, 'metadata', '--format-version', '1', '--all-features', '--filter-platform', host, env=env))
268
+ except subprocess.CalledProcessError as e: return Results('test', e.returncode, text + out + e.stderr, found + diags)
269
+ reuse = metadata, binaries
235
270
  text, found = text + out, found + diags
236
271
  if code: return Results('test', code, text, found)
237
- artifacts = [m for m in rest if m['reason'] == 'compiler-artifact' and m['profile']['test'] and m.get('executable')]
238
- built.append((r, rargs, artifacts, _nextest_profiles(r)))
272
+ artifacts = [m for m in rest if m.get('reason') == 'compiler-artifact' and m['profile']['test'] and m.get('executable')]
273
+ built.append((r, rargs, artifacts, defined, reuse))
239
274
  def named(r, p, suites):
240
275
  "`suites`, freshly read, renamed for root `r` and profile `p` where several roots or profiles ran"
241
276
  t = ' '.join(x for x in (r.name if len(roots) > 1 else '', p if p and len(profiles) > 1 else '') if x)
242
277
  for s in suites: s.name = f'{t}: {s.name}' if t else s.name
243
278
  return t, suites
244
279
  fail_fast, code, suites, start = '--no-fail-fast' not in args, 0, [], time.monotonic()
245
- for r, rargs, artifacts, defined in built:
280
+ for r, rargs, artifacts, defined, reuse in built:
246
281
  if defined is not None: continue
247
282
  c, out, ss = _libtest(r, rargs, test_args, env, timeout, artifacts)
248
283
  text, suites, code = text + out, suites + named(r, None, ss)[1], code or c
249
284
  if code and fail_fast: return Results('test', code, text, found, suites, time.monotonic() - start)
250
285
  for p in profiles:
251
- jobs = [(r, rargs, artifacts) for r, rargs, artifacts, defined in built if p in (defined or ())]
252
- with ThreadPoolExecutor(max(len(jobs), 1)) as ex: runs = list(ex.map(lambda j: _nextest(j[0], j[1], test_args, env, timeout, j[2], p), jobs))
253
- for (r, _, _), (c, out, ss, _) in zip(jobs, runs):
286
+ jobs = [(r, rargs, artifacts, reuse) for r, rargs, artifacts, defined, reuse in built if p in (defined or ())]
287
+ with ThreadPoolExecutor(max(len(jobs), 1)) as ex: runs = list(ex.map(lambda j: _nextest(j[0], j[1], test_args, env, timeout, j[2], j[3], p), jobs))
288
+ for (r, _, _, _), (c, out, ss, _) in zip(jobs, runs):
254
289
  t, ss = named(r, p, ss)
255
290
  text, suites, code = text + (f' Nextest profile {p} in {r}\n' if t else '') + out, suites + ss, code or c
256
291
  if code and fail_fast: break
@@ -311,7 +346,10 @@ def build(
311
346
  for flag, active in [('all-features', all_features), ('no-default-features', no_default_features)]:
312
347
  if active or cfg.get(flag): cmd.append('--' + flag)
313
348
  extra, env = _maturin_flags(target, os.environ) if for_maturin else ([], None)
314
- result = subprocess.run(['cargo', *cmd, *extra], cwd=root, stdout=subprocess.PIPE, text=True, env=env)
349
+ cmd, env = _cargo_command(*cmd, *extra, env=env)
350
+ result = subprocess.run(cmd, cwd=root, stdout=subprocess.PIPE, text=True, env=env)
351
+ if log := env.get('FASTWS_CARGO_LOG'):
352
+ with Path(log).expanduser().open('a') as capture: capture.write(result.stdout)
315
353
  messages = [json.loads(line) for line in result.stdout.splitlines()]
316
354
  for m in messages:
317
355
  if m.get('reason') != 'compiler-message': continue