You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(runtime): standardize on 'stitched' runtime mode naming
- Rename runtime mode from 'singlefile' to 'stitched' throughout codebase
- Update pyproject.toml task names (build:script -> build:stitched, test:pytest:script -> test:pytest:stitched)
- Rename BUNDLER_SCRIPT constant to STITCH_SCRIPT
- Replace __STANDALONE__ marker with __STITCHED__ for stitched script detection
- Update tagline from 'When stdlib just isn't enough' to 'When stdlib is almost enough'
- Update all documentation, tests, and CI workflows to use new naming
*Apathetic Python Utils* provides a lightweight, dependency-free collection of utility functions designed for CLI tools. It includes helpers for file loading, path manipulation, system detection, text processing, type checking, pattern matching, and more.
Checks if the standalone script exists and is newer than all source files. If not, rebuilds it using either the provided bundler script or the Poetry-installed `serger` module.
598
+
Checks if the stitched script exists and is newer than all source files. If not, rebuilds it using either the provided bundler script or the Poetry-installed `serger` module.
599
599
600
600
**Parameters:**
601
601
602
602
| Parameter | Type | Description |
603
603
|-----------|------|-------------|
604
604
|`root`|`Path`| Project root directory |
605
-
|`script_name`|`str \| None`| Optional name of the standalone script (without .py extension). If None, defaults to `package_name`. |
605
+
|`script_name`|`str \| None`| Optional name of the stitched script (without .py extension). If None, defaults to `package_name`. |
606
606
|`package_name`|`str`| Name of the package (e.g., "apathetic_utils") |
607
607
|`bundler_script`|`str \| None`| Optional path to bundler script (relative to root). If provided and exists, uses `python {bundler_script}`. Otherwise, uses `python -m serger --config .serger.jsonc`. |
608
608
609
609
**Returns:**
610
-
-`Path`: Path to the standalone script
610
+
-`Path`: Path to the stitched script
611
611
612
612
**Raises:**
613
613
-`RuntimeError`: If the script generation fails
@@ -703,8 +703,8 @@ runtime_swap(
703
703
Pre-import hook — runs before any tests or plugins are imported.
704
704
705
705
Swaps in the appropriate runtime module based on `RUNTIME_MODE`:
706
-
-`installed` (default): uses `src/{package_name}` (no swap needed)
707
-
-`singlefile`: uses `dist/{script_name}.py` (serger-built single file)
706
+
-`package` (default): uses `src/{package_name}` (no swap needed)
707
+
-`stitched`: uses `dist/{script_name}.py` (serger-built single file)
This ensures all test imports work transparently regardless of runtime mode.
@@ -715,12 +715,12 @@ This ensures all test imports work transparently regardless of runtime mode.
715
715
|-----------|------|-------------|
716
716
|`root`|`Path`| Project root directory |
717
717
|`package_name`|`str`| Name of the package (e.g., "apathetic_utils") |
718
-
|`script_name`|`str \| None`| Optional name of the standalone script (without extension). If None, defaults to `package_name`. |
718
+
|`script_name`|`str \| None`| Optional name of the stitched script (without extension). If None, defaults to `package_name`. |
719
719
|`bundler_script`|`str \| None`| Optional path to bundler script (relative to root). If provided and exists, uses `python {bundler_script}`. Otherwise, uses `python -m serger --config .serger.jsonc`. |
720
720
|`mode`|`str \| None`| Runtime mode override. If None, reads from `RUNTIME_MODE` env var. |
721
721
722
722
**Returns:**
723
-
-`bool`: `True` if swap was performed, `False` if in installed mode
723
+
-`bool`: `True` if swap was performed, `False` if in package mode
724
724
725
725
**Raises:**
726
726
-`pytest.UsageError`: If mode is invalid or build fails
@@ -735,15 +735,15 @@ from pathlib import Path
735
735
runtime_swap(
736
736
root=Path(__file__).parent.parent,
737
737
package_name="my_package",
738
-
mode="singlefile"# or None to read from RUNTIME_MODE env var
738
+
mode="stitched"# or None to read from RUNTIME_MODE env var
739
739
)
740
740
741
741
# Using a custom script name
742
742
runtime_swap(
743
743
root=Path(__file__).parent.parent,
744
744
package_name="my_package",
745
745
script_name="my_script",
746
-
mode="singlefile"
746
+
mode="stitched"
747
747
)
748
748
749
749
# Using a local bundler script
@@ -752,7 +752,7 @@ runtime_swap(
752
752
package_name="my_package",
753
753
script_name="my_script",
754
754
bundler_script="bin/serger.py",
755
-
mode="singlefile"
755
+
mode="stitched"
756
756
)
757
757
```
758
758
@@ -1224,7 +1224,7 @@ Works in both package and stitched single-file runtimes. Walks `sys.modules` onc
1224
1224
|`func_name`|`str`| Name of the function to patch |
1225
1225
|`replacement_func`|`Callable[..., object]`| Function to replace the original with |
1226
1226
|`package_prefix`|`str \| Sequence[str]`| Package name prefix(es) to filter modules. Can be a single string (e.g., "apathetic_utils") or a sequence of strings (e.g., ["apathetic_utils", "my_package"]) to patch across multiple packages. |
1227
-
|`stitch_hints`|`set[str] \| None`| Set of path hints to identify stitched modules. Defaults to `{"/dist/", "standalone"}`. When providing custom hints, you must be certain of the path attributes of your stitched file, as this uses substring matching on the module's `__file__` path. This is a heuristic fallback when identity checks fail (e.g., when modules are reloaded). |
1227
+
|`stitch_hints`|`set[str] \| None`| Set of path hints to identify stitched modules. Defaults to `{"/dist/", "stitched"}`. When providing custom hints, you must be certain of the path attributes of your stitched file, as this uses substring matching on the module's `__file__` path. This is a heuristic fallback when identity checks fail (e.g., when modules are reloaded). |
1228
1228
|`create_if_missing`|`bool`| If True, create the attribute if it doesn't exist. If False (default), raise TypeError if the function doesn't exist. |
1229
1229
|`caller_func_name`|`str \| None`| If provided, only patch `__globals__` for this specific function to handle direct calls. If None (default), patch `__globals__` for all functions in stitched modules that reference the original function. |
Copy file name to clipboardExpand all lines: docs/index.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ permalink: /
7
7
# Apathetic Python Utils ⚙️
8
8
9
9
**Grab bag of helpers for Apathetic projects.**
10
-
*When stdlib just isn't enough.*
10
+
*When stdlib is almost enough.*
11
11
12
12
*Apathetic Python Utils* provides a lightweight, dependency-free collection of utility functions designed for CLI tools. It includes helpers for file loading, path manipulation, system detection, text processing, type checking, pattern matching, and more.
13
13
@@ -18,7 +18,7 @@ permalink: /
18
18
- 🔍 **Pattern matching** — Portable glob pattern matching with recursive `**` support
Copy file name to clipboardExpand all lines: docs/installation.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ This installation method provides:
31
31
32
32
## Alternative: Single-File Distribution
33
33
34
-
For projects that prefer a single-file dependency, we also distribute a standalone`apathetic_utils.py` file that you can download directly from [releases](https://github.com/apathetic-tools/python-utils/releases).
34
+
For projects that prefer a single-file dependency, we also distribute a stitched`apathetic_utils.py` file that you can download directly from [releases](https://github.com/apathetic-tools/python-utils/releases).
0 commit comments