fastws-cli 0.0.38__tar.gz → 0.0.39__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 (32) hide show
  1. {fastws_cli-0.0.38/fastws_cli.egg-info → fastws_cli-0.0.39}/PKG-INFO +6 -7
  2. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/README.md +5 -6
  3. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/fastws/__init__.py +2 -1
  4. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/fastws/build_backend.py +2 -2
  5. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/fastws/cargo.py +21 -14
  6. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/fastws/core.py +10 -72
  7. {fastws_cli-0.0.38 → fastws_cli-0.0.39/fastws_cli.egg-info}/PKG-INFO +6 -7
  8. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/tests/test_build_backend.py +13 -0
  9. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/tests/test_sync.py +0 -31
  10. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/LICENSE +0 -0
  11. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/fastws/_toml.py +0 -0
  12. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/fastws/integrate.py +0 -0
  13. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/fastws/news.py +0 -0
  14. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/fastws/procs.py +0 -0
  15. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/fastws/releases.py +0 -0
  16. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/fastws/store.py +0 -0
  17. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/fastws/timelock.py +0 -0
  18. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/fastws_cli.egg-info/SOURCES.txt +0 -0
  19. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/fastws_cli.egg-info/dependency_links.txt +0 -0
  20. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/fastws_cli.egg-info/entry_points.txt +0 -0
  21. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/fastws_cli.egg-info/requires.txt +0 -0
  22. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/fastws_cli.egg-info/top_level.txt +0 -0
  23. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/pyproject.toml +0 -0
  24. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/setup.cfg +0 -0
  25. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/tests/test_build.py +0 -0
  26. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/tests/test_integrate.py +0 -0
  27. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/tests/test_news.py +0 -0
  28. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/tests/test_procs.py +0 -0
  29. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/tests/test_releases.py +0 -0
  30. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/tests/test_setup.py +0 -0
  31. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/tests/test_store.py +0 -0
  32. {fastws_cli-0.0.38 → fastws_cli-0.0.39}/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.38
3
+ Version: 0.0.39
4
4
  Summary: Fast workspace tools for multi-repo management
5
5
  Author: Jeremy Howard
6
6
  License-Expression: Apache-2.0
@@ -116,6 +116,7 @@ The workspace `pyproject.toml` is local generated state. `ws-sync` creates it fr
116
116
  /uv.lock
117
117
  /.cargo/
118
118
  /.fastws-upgraded
119
+ /.fastws-cargo-upgraded
119
120
  ```
120
121
 
121
122
  Keep project checkouts out of the workspace Git index too. When migrating a workspace that already tracks generated files, save local copies before pulling the change that untracks them, then restore those copies afterward. Also save personal repo entries to `repos-local.txt` before pulling a smaller baseline.
@@ -215,7 +216,7 @@ cargo develop --path /path/to/project
215
216
  cargo develop --profile quick
216
217
  ```
217
218
 
218
- 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.
219
+ Run from the project root, or give its directory with `--path`. The command reads `python-source`, `module-name`, `manifest-path`, `bindings` 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. Mixed projects must produce a `cdylib` and set `python-source`; `bindings = "bin"` projects build and install their binary targets directly into the active venv. Define the selected profile in `Cargo.toml` and keep incremental compilation enabled for the local crate.
219
220
 
220
221
  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.
221
222
 
@@ -243,7 +244,7 @@ On Unix, cooperating `cargo develop` runs take a per-project lock through compil
243
244
 
244
245
  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.
245
246
 
246
- Use `fastws.build_backend` as the build backend of a mixed project, and include `fastws-cli>=0.0.29` alongside `maturin>=1.13,<2.0` in `[build-system].requires`. Its editable builds install only Python metadata and the source path, and compile no Rust. `ws-sync` then runs `cargo develop` to build and install the extension, the binaries and the wheel data files. After standalone `uv sync`, run `cargo develop` yourself.
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`). Its editable builds install only Python metadata (and the source path when `python-source` is set) and compile no Rust. `ws-sync` then runs `cargo develop` to build and install the extension, binaries and wheel data files. After standalone `uv sync`, run `cargo develop` yourself.
247
248
 
248
249
  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.
249
250
 
@@ -352,7 +353,7 @@ Before `uv sync`, fastws regenerates `tool.uv.no-build-isolation-package` with t
352
353
 
353
354
  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=""`).
354
355
 
355
- 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.
356
+ After `uv sync`, fastws runs `cargo develop` in mixed Rust/Python projects and `bindings = "bin"` Rust CLI 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.
356
357
 
357
358
  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.
358
359
 
@@ -364,9 +365,7 @@ After installation, fastws runs `pnpm -r --if-present --workspace-concurrency=<N
364
365
 
365
366
  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`).
366
367
 
367
- 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.
368
-
369
- Before every uv sync, `ws-sync` writes `.git/fastws-cargo-key` for each member crate. The key hashes `Cargo.lock` contents and the workspace Cargo patch configuration. For Git dependencies redirected to local paths by `[patch."<url>"]`, it also hashes each patched crate's `Cargo.toml`, `build.rs`, and `src` tree, recursively. The file is rewritten only when that content changes, so projects can use `{ file = ".git/fastws-cargo-key" }` in `tool.uv.cache-keys` without rebuilding after a timestamp-only `Cargo.lock` write.
368
+ At most once per day, sync upgrades Python dependencies with `uv sync -U`, and at most once every seven days it 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.
370
369
 
371
370
  ```bash
372
371
  ws-sync
@@ -87,6 +87,7 @@ The workspace `pyproject.toml` is local generated state. `ws-sync` creates it fr
87
87
  /uv.lock
88
88
  /.cargo/
89
89
  /.fastws-upgraded
90
+ /.fastws-cargo-upgraded
90
91
  ```
91
92
 
92
93
  Keep project checkouts out of the workspace Git index too. When migrating a workspace that already tracks generated files, save local copies before pulling the change that untracks them, then restore those copies afterward. Also save personal repo entries to `repos-local.txt` before pulling a smaller baseline.
@@ -186,7 +187,7 @@ cargo develop --path /path/to/project
186
187
  cargo develop --profile quick
187
188
  ```
188
189
 
189
- 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.
190
+ Run from the project root, or give its directory with `--path`. The command reads `python-source`, `module-name`, `manifest-path`, `bindings` 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. Mixed projects must produce a `cdylib` and set `python-source`; `bindings = "bin"` projects build and install their binary targets directly into the active venv. Define the selected profile in `Cargo.toml` and keep incremental compilation enabled for the local crate.
190
191
 
191
192
  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.
192
193
 
@@ -214,7 +215,7 @@ On Unix, cooperating `cargo develop` runs take a per-project lock through compil
214
215
 
215
216
  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.
216
217
 
217
- Use `fastws.build_backend` as the build backend of a mixed project, and include `fastws-cli>=0.0.29` alongside `maturin>=1.13,<2.0` in `[build-system].requires`. Its editable builds install only Python metadata and the source path, and compile no Rust. `ws-sync` then runs `cargo develop` to build and install the extension, the binaries and the wheel data files. After standalone `uv sync`, run `cargo develop` yourself.
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`). Its editable builds install only Python metadata (and the source path when `python-source` is set) and compile no Rust. `ws-sync` then runs `cargo develop` to build and install the extension, binaries and wheel data files. After standalone `uv sync`, run `cargo develop` yourself.
218
219
 
219
220
  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.
220
221
 
@@ -323,7 +324,7 @@ Before `uv sync`, fastws regenerates `tool.uv.no-build-isolation-package` with t
323
324
 
324
325
  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=""`).
325
326
 
326
- 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.
327
+ After `uv sync`, fastws runs `cargo develop` in mixed Rust/Python projects and `bindings = "bin"` Rust CLI 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.
327
328
 
328
329
  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.
329
330
 
@@ -335,9 +336,7 @@ After installation, fastws runs `pnpm -r --if-present --workspace-concurrency=<N
335
336
 
336
337
  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`).
337
338
 
338
- 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.
339
-
340
- Before every uv sync, `ws-sync` writes `.git/fastws-cargo-key` for each member crate. The key hashes `Cargo.lock` contents and the workspace Cargo patch configuration. For Git dependencies redirected to local paths by `[patch."<url>"]`, it also hashes each patched crate's `Cargo.toml`, `build.rs`, and `src` tree, recursively. The file is rewritten only when that content changes, so projects can use `{ file = ".git/fastws-cargo-key" }` in `tool.uv.cache-keys` without rebuilding after a timestamp-only `Cargo.lock` write.
339
+ At most once per day, sync upgrades Python dependencies with `uv sync -U`, and at most once every seven days it 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.
341
340
 
342
341
  ```bash
343
342
  ws-sync
@@ -1,4 +1,5 @@
1
- __version__ = "0.0.38"
1
+ __version__ = "0.0.39"
2
+
2
3
 
3
4
 
4
5
 
@@ -36,8 +36,8 @@ def build_editable(wheel_directory, config_settings=None, metadata_directory=Non
36
36
  tag = next(line.removeprefix('Tag: ') for line in (info/'WHEEL').read_text().splitlines() if line.startswith('Tag: '))
37
37
  files = {p.relative_to(info.parent).as_posix(): p.read_bytes() for p in info.rglob('*') if p.is_file() and p != info/'RECORD'}
38
38
  root = Path.cwd()
39
- source = (root/settings(root)['maturin']['python-source']).resolve()
40
- files[f'{name}.pth'] = f'{source}\n'.encode()
39
+ if py_src := settings(root)['maturin'].get('python-source'):
40
+ files[f'{name}.pth'] = f'{(root/py_src).resolve()}\n'.encode()
41
41
  record = f'{info.name}/RECORD'
42
42
  rows = [(path, 'sha256=' + base64.urlsafe_b64encode(hashlib.sha256(data).digest()).rstrip(b'=').decode(), len(data))
43
43
  for path, data in files.items()]
@@ -375,24 +375,31 @@ def develop(root, *, profile=None):
375
375
  with store.building(root) as started:
376
376
  tool = settings(root)
377
377
  cfg = tool['maturin']
378
- if 'python-source' not in cfg: raise ConfigError(r'cargo develop requires tool.maturin.python-source')
379
- binaries = tool.get('fastws', {}).get('native-binaries', False)
380
- artifacts = build(root, binaries=binaries, profile=profile or _dev_profile(root))
381
- artifact, = [m for m in artifacts if 'cdylib' in m['target']['crate_types']]
382
- lib, = [Path(f) for f in artifact['filenames'] if Path(f).suffix in ('.dylib', '.so', '.dll')]
383
- module = cfg.get('module-name', artifact['target']['name'])
384
- src = root/cfg['python-source']
385
- ext = src/Path(*module.split('.'))
386
- ext = ext.with_name(ext.name + sysconfig.get_config_var('EXT_SUFFIX'))
378
+ bin_only = cfg.get('bindings') == 'bin'
379
+ if not bin_only and 'python-source' not in cfg: raise ConfigError(r'cargo develop requires tool.maturin.python-source')
380
+ binaries = bin_only or tool.get('fastws', {}).get('native-binaries', False)
381
+ artifacts = build(root, library=not bin_only, binaries=binaries, profile=profile or _dev_profile(root))
387
382
  env = Path(os.environ.get('VIRTUAL_ENV', sys.prefix))
388
383
  scripts = env/('Scripts' if os.name == 'nt' else 'bin')
389
384
  exes = [Path(m['executable']) for m in artifacts if binaries and m.get('executable')]
390
- package = src/module.split('.')[0]
391
- files = {f'python/{f.relative_to(src)}': f for f in package.rglob('*') if f.is_file() and f != ext and '__pycache__' not in f.parts}
392
- files |= {f'python/{ext.relative_to(src)}': lib} | {f'bin/{e.name}': e for e in exes}
385
+ files = {f'bin/{e.name}': e for e in exes}
386
+ paths = {scripts/e.name: f'bin/{e.name}' for e in exes}
387
+ built = list(exes)
388
+ if not bin_only:
389
+ artifact, = [m for m in artifacts if 'cdylib' in m['target']['crate_types']]
390
+ lib, = [Path(f) for f in artifact['filenames'] if Path(f).suffix in ('.dylib', '.so', '.dll')]
391
+ module = cfg.get('module-name', artifact['target']['name'])
392
+ src = root/cfg['python-source']
393
+ ext = src/Path(*module.split('.'))
394
+ ext = ext.with_name(ext.name + sysconfig.get_config_var('EXT_SUFFIX'))
395
+ package = src/module.split('.')[0]
396
+ files |= {f'python/{f.relative_to(src)}': f for f in package.rglob('*') if f.is_file() and f != ext and '__pycache__' not in f.parts}
397
+ files[f'python/{ext.relative_to(src)}'] = lib
398
+ paths[ext] = f'python/{ext.relative_to(src)}'
399
+ built.insert(0, lib)
393
400
  with store.access():
394
- kept = store.keep(root, files, dict.fromkeys(f for a in [lib, *exes] for f in store.dep_files(a)), started)
395
- store.install(root, kept, {ext: f'python/{ext.relative_to(src)}'} | {scripts/e.name: f'bin/{e.name}' for e in exes})
401
+ kept = store.keep(root, files, dict.fromkeys(f for a in built for f in store.dep_files(a)), started)
402
+ store.install(root, kept, paths)
396
403
  store.collect()
397
404
  if generator := tool.get('fastws', {}).get('post-develop-module'):
398
405
  subprocess.run([sys.executable, '-m', generator], cwd=root, check=True)
@@ -2,7 +2,7 @@
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, hashlib, json, os, re, shlex, shutil, subprocess, sys, tarfile, time
5
+ import ast, 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
@@ -748,35 +748,20 @@ def ws_build(
748
748
  print(f"{built} built, {len(artifacts)-len(todo)} up to date" + (f", {failed} failed" if failed else ""), file=sys.stderr)
749
749
  if failed: raise SystemExit(1)
750
750
  print(out_path)
751
- def _upgrade_stamp(root: Path) -> Path:
751
+ def _upgrade_stamp(root: Path, name: str = "fastws-upgraded") -> Path:
752
752
  "Stamp whose mtime records the last dependency upgrade; kept inside .git (never tracked) when the root is a git repo."
753
753
  gitdir = root/".git"
754
- return gitdir/"fastws-upgraded" if gitdir.is_dir() else root/".fastws-upgraded"
754
+ return gitdir/name if gitdir.is_dir() else root/f".{name}"
755
755
 
756
- def _should_upgrade(root: Path, max_age: float = 86400) -> bool:
756
+ def _should_upgrade(root: Path, max_age: float = 86400, name: str = "fastws-upgraded") -> bool:
757
757
  "True when this workspace hasn't upgraded dependencies within `max_age` seconds."
758
- stamp = _upgrade_stamp(root)
758
+ stamp = _upgrade_stamp(root, name)
759
759
  return not stamp.exists() or time.time() - stamp.stat().st_mtime > max_age
760
760
 
761
- _CARGO_KEY = Path(".git/fastws-cargo-key")
762
-
763
761
  def _crate_dirs(root: Path) -> list[Path]:
764
762
  "Root dirs containing a Cargo.toml: the crate view of the workspace, independent of uv membership"
765
763
  return [d for d in _project_dirs(root, "Cargo.toml") if not d.name.startswith((".", "_"))]
766
764
 
767
- def _cargo_patches(root: Path):
768
- "Local Cargo patches keyed by normalized Git URL and package name, plus their config file."
769
- config = root/".cargo"/"config.toml"
770
- if not config.exists(): return {}, None
771
- data = tomllib.loads(config.read_text())
772
- patches = {}
773
- for url, entries in data.get("patch", {}).items():
774
- for name, spec in entries.items():
775
- if not isinstance(spec, dict) or not (path := spec.get("path")): continue
776
- path = Path(path).expanduser()
777
- patches[(_repo_key(url), name)] = path if path.is_absolute() else (config.parent/path).resolve()
778
- return patches, config
779
-
780
765
  def _crate_manifests(d: Path):
781
766
  "(parsed `Cargo.toml`, dir) for the crate or workspace at `d` and each of its cargo workspace members"
782
767
  try: data = tomllib.loads((d/"Cargo.toml").read_text())
@@ -935,54 +920,6 @@ def _cargo_dep_tables(data, every=False):
935
920
  for name in names: yield target.get(name, {})
936
921
  if every: yield data.get("workspace", {}).get("dependencies", {})
937
922
 
938
- def _patched_cargo_deps(crate: Path, patches):
939
- data = tomllib.loads((crate/"Cargo.toml").read_text())
940
- for deps in _cargo_dep_tables(data):
941
- for name, spec in deps.items():
942
- if not isinstance(spec, dict) or not (url := spec.get("git")): continue
943
- if path := patches.get((_repo_key(url), spec.get("package", name))): yield path
944
-
945
- def _cargo_input_files(crate: Path):
946
- for name in "Cargo.toml","build.rs":
947
- if (path := crate/name).exists(): yield path
948
- src = crate/"src"
949
- if src.exists(): yield from sorted(path for path in src.rglob("*") if path.is_file())
950
-
951
- def _cargo_lock_content(path: Path) -> bytes:
952
- "Cargo.lock bytes without Cargo's order-unstable bookkeeping for unused patches"
953
- if not path.exists(): return b""
954
- return re.sub(r"(?ms)^\[\[patch\.unused\]\]\n.*?(?=^\[\[|\Z)", "", path.read_text()).encode()
955
-
956
- def _cargo_key(crate: Path, patches, config):
957
- h = hashlib.sha256()
958
- def add_content(content, name):
959
- h.update(name.encode())
960
- h.update(b"\0")
961
- h.update(content)
962
- h.update(b"\0")
963
- def add(path, name): add_content(path.read_bytes() if path.exists() else b"", name)
964
- add_content(_cargo_lock_content(crate/"Cargo.lock"), "Cargo.lock")
965
- if config: add(config, ".cargo/config.toml")
966
- seen = set()
967
- def add_dep(dep):
968
- dep = dep.resolve()
969
- if dep in seen: return
970
- seen.add(dep)
971
- for path in _cargo_input_files(dep): add(path, f"{dep.name}/{path.relative_to(dep)}")
972
- for child in _patched_cargo_deps(dep, patches): add_dep(child)
973
- for dep in _patched_cargo_deps(crate, patches): add_dep(dep)
974
- return h.hexdigest()
975
-
976
- def _sync_cargo_keys(root: Path):
977
- "Update content-derived uv keys for workspace crates, without touching unchanged keys."
978
- patches, config = _cargo_patches(root)
979
- for crate in _crate_dirs(root):
980
- key = crate/_CARGO_KEY
981
- if not key.parent.is_dir(): continue
982
- value = _cargo_key(crate, patches, config)
983
- if key.exists() and key.read_text().strip() == value: continue
984
- key.write_text(value + "\n")
985
-
986
923
  def _cargo_update(root: Path, workers: int = 16):
987
924
  "Float each member crate's Cargo.lock to latest matching versions, in parallel; prints what moved."
988
925
  crates = _crate_dirs(root)
@@ -1017,7 +954,7 @@ def _rel_ws_path(root: Path, d: Path) -> str: return Path(os.path.relpath(d.reso
1017
954
  def _is_maturin_native(d: Path) -> bool:
1018
955
  if not (d/'pyproject.toml').exists(): return False
1019
956
  cfg = tomllib.loads((d/'pyproject.toml').read_text()).get('tool', {}).get('maturin', {})
1020
- return 'python-source' in cfg and cfg.get('bindings') != 'bin'
957
+ return 'python-source' in cfg or cfg.get('bindings') == 'bin'
1021
958
 
1022
959
  def _repo_roots(root: Path, repos_file="repos.txt") -> list[Path]:
1023
960
  "Candidate top-level workspace directories plus registered external checkouts."
@@ -1210,7 +1147,7 @@ async def ws_sync(
1210
1147
  upgrade: bool = False, # Force the once-daily dependency upgrade pass
1211
1148
  build_workers: int = os.cpu_count() or 1, # Concurrent projects per build phase; defaults to CPU count
1212
1149
  ):
1213
- "Pull the workspace baseline, clone missing shared/local repos, then pull projects and sync; upgrade dependencies daily."
1150
+ "Pull the workspace baseline, clone missing shared/local repos, then pull projects and sync; upgrade Python deps daily and Cargo deps weekly."
1214
1151
  with _cli_errors():
1215
1152
  root = _ws_root(workspace, repos_file, pyproject_file, template_file)
1216
1153
  repos_path = _resolve_path(root, repos_file)
@@ -1259,8 +1196,8 @@ async def ws_sync(
1259
1196
  print(f"⚠️ Skipping uv sync, not Python projects yet (scaffold with e.g. nbdev-new or ship-new, or remove): {', '.join(bad)}")
1260
1197
  return
1261
1198
  up = upgrade or _should_upgrade(root)
1262
- if up: _cargo_update(root, workers=workers)
1263
- _sync_cargo_keys(root)
1199
+ cargo_up = upgrade or _should_upgrade(root, max_age=7*86400, name="fastws-cargo-upgraded")
1200
+ if cargo_up: _cargo_update(root, workers=workers)
1264
1201
  subprocess.run(["uv", "sync", "-U"] if up else ["uv", "sync"], check=True, cwd=root)
1265
1202
  _write_pytest_pth(root)
1266
1203
  from .cargo import develop
@@ -1269,6 +1206,7 @@ async def ws_sync(
1269
1206
  if wasm_pkgs:
1270
1207
  with ThreadPoolExecutor(max_workers=build_workers) as ex: list(ex.map(_build_wasm, wasm_pkgs))
1271
1208
  if up: _upgrade_stamp(root).touch()
1209
+ if cargo_up: _upgrade_stamp(root, "fastws-cargo-upgraded").touch()
1272
1210
  if js_members: _sync_js(root, build_workers)
1273
1211
 
1274
1212
  @call_parse
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastws-cli
3
- Version: 0.0.38
3
+ Version: 0.0.39
4
4
  Summary: Fast workspace tools for multi-repo management
5
5
  Author: Jeremy Howard
6
6
  License-Expression: Apache-2.0
@@ -116,6 +116,7 @@ The workspace `pyproject.toml` is local generated state. `ws-sync` creates it fr
116
116
  /uv.lock
117
117
  /.cargo/
118
118
  /.fastws-upgraded
119
+ /.fastws-cargo-upgraded
119
120
  ```
120
121
 
121
122
  Keep project checkouts out of the workspace Git index too. When migrating a workspace that already tracks generated files, save local copies before pulling the change that untracks them, then restore those copies afterward. Also save personal repo entries to `repos-local.txt` before pulling a smaller baseline.
@@ -215,7 +216,7 @@ cargo develop --path /path/to/project
215
216
  cargo develop --profile quick
216
217
  ```
217
218
 
218
- 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.
219
+ Run from the project root, or give its directory with `--path`. The command reads `python-source`, `module-name`, `manifest-path`, `bindings` 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. Mixed projects must produce a `cdylib` and set `python-source`; `bindings = "bin"` projects build and install their binary targets directly into the active venv. Define the selected profile in `Cargo.toml` and keep incremental compilation enabled for the local crate.
219
220
 
220
221
  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.
221
222
 
@@ -243,7 +244,7 @@ On Unix, cooperating `cargo develop` runs take a per-project lock through compil
243
244
 
244
245
  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.
245
246
 
246
- Use `fastws.build_backend` as the build backend of a mixed project, and include `fastws-cli>=0.0.29` alongside `maturin>=1.13,<2.0` in `[build-system].requires`. Its editable builds install only Python metadata and the source path, and compile no Rust. `ws-sync` then runs `cargo develop` to build and install the extension, the binaries and the wheel data files. After standalone `uv sync`, run `cargo develop` yourself.
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`). Its editable builds install only Python metadata (and the source path when `python-source` is set) and compile no Rust. `ws-sync` then runs `cargo develop` to build and install the extension, binaries and wheel data files. After standalone `uv sync`, run `cargo develop` yourself.
247
248
 
248
249
  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.
249
250
 
@@ -352,7 +353,7 @@ Before `uv sync`, fastws regenerates `tool.uv.no-build-isolation-package` with t
352
353
 
353
354
  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=""`).
354
355
 
355
- 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.
356
+ After `uv sync`, fastws runs `cargo develop` in mixed Rust/Python projects and `bindings = "bin"` Rust CLI 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.
356
357
 
357
358
  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.
358
359
 
@@ -364,9 +365,7 @@ After installation, fastws runs `pnpm -r --if-present --workspace-concurrency=<N
364
365
 
365
366
  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`).
366
367
 
367
- 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.
368
-
369
- Before every uv sync, `ws-sync` writes `.git/fastws-cargo-key` for each member crate. The key hashes `Cargo.lock` contents and the workspace Cargo patch configuration. For Git dependencies redirected to local paths by `[patch."<url>"]`, it also hashes each patched crate's `Cargo.toml`, `build.rs`, and `src` tree, recursively. The file is rewritten only when that content changes, so projects can use `{ file = ".git/fastws-cargo-key" }` in `tool.uv.cache-keys` without rebuilding after a timestamp-only `Cargo.lock` write.
368
+ At most once per day, sync upgrades Python dependencies with `uv sync -U`, and at most once every seven days it 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.
370
369
 
371
370
  ```bash
372
371
  ws-sync
@@ -24,3 +24,16 @@ 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())
@@ -135,37 +135,6 @@ def test_ws_remove_refuses_unsafe_repos(tmp_path):
135
135
  assert (tmp_path/'repos.txt').read_text() == 'AnswerDotAI/keep\n'
136
136
 
137
137
 
138
- def test_cargo_key_hashes_lock_and_patched_dependency_contents(tmp_path):
139
- crate, dep = tmp_path/'crate', tmp_path/'dep'
140
- for d in crate, dep: (d/'src').mkdir(parents=True)
141
- (crate/'Cargo.toml').write_text(r'''[dependencies]
142
- dep = { git = "https://example.com/dep" }
143
- ''')
144
- (dep/'Cargo.toml').touch()
145
- source, lock = dep/'src'/'lib.rs', crate/'Cargo.lock'
146
- source.write_text('original')
147
- lock.write_text('first lock')
148
- patches = {('https://example.com/dep', 'dep'): dep}
149
- first = core._cargo_key(crate, patches, None)
150
- lock.write_text('second lock')
151
- second = core._cargo_key(crate, patches, None)
152
- assert second != first
153
- source.write_text('changed')
154
- assert core._cargo_key(crate, patches, None) != second
155
-
156
-
157
- def test_cargo_lock_ignores_unused_patches(tmp_path):
158
- lock = tmp_path/'Cargo.lock'
159
- header = r'''version = 4
160
- [[package]]
161
- name = "crate"
162
- '''
163
- lock.write_text(header + r'''[[patch.unused]]
164
- name = "unused"
165
- ''')
166
- assert core._cargo_lock_content(lock) == header.encode()
167
-
168
-
169
138
  def test_sync_cargo_patches_generates_and_preserves(tmp_path):
170
139
  (tmp_path/'.cargo').mkdir()
171
140
  config = tmp_path/'.cargo'/'config.toml'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes