-
-
Save digitalsignalperson/4af0eb8324d1a94ec5968f882140c8f9 to your computer and use it in GitHub Desktop.
uw - a uv wrapper to run a uv "workspace" with independent uv.lock from its dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| # Walk up from CWD looking for .uw | |
| find_uw_root() { | |
| local dir="$PWD" | |
| while [[ "$dir" != "/" ]]; do | |
| if [[ -f "$dir/.uw" ]]; then | |
| echo "$dir" | |
| return 0 | |
| fi | |
| dir="$(dirname "$dir")" | |
| done | |
| echo "uw: no .uw file found in any parent directory" >&2 | |
| return 1 | |
| } | |
| UW_ROOT="$(find_uw_root)" | |
| # Parse the workspace path from .uw (handles `workspace = "packages/workspace"`) | |
| WORKSPACE_REL="$(grep '^workspace' "$UW_ROOT/.uw" | sed 's/.*=\s*"\(.*\)"/\1/')" | |
| WORKSPACE_DIR="$UW_ROOT/$WORKSPACE_REL" | |
| if [[ ! -d "$WORKSPACE_DIR" ]]; then | |
| echo "uw: workspace directory not found: $WORKSPACE_DIR" >&2 | |
| exit 1 | |
| fi | |
| # Run uv with the workspace package as the project root | |
| exec uv --project "$WORKSPACE_DIR" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment