d
This commit is contained in:
@@ -1,34 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
# Bootstrap script for POSIX (Linux/macOS) to create a Python venv and install the project.
|
||||
# Usage: scripts/bootstrap.sh [--editable] [--venv <path>] [--python <python>] [--desktop] [--no-install]
|
||||
set -e
|
||||
|
||||
# Ensure script is running under Bash. Some users invoke this script with `sh` (dash)
|
||||
# which does not support the Bash features used below (e.g., [[ ]], arrays, read -p).
|
||||
# If not running under Bash, re-exec using a discovered bash binary.
|
||||
if [ -z "${BASH_VERSION:-}" ]; then
|
||||
if command -v bash >/dev/null 2>&1; then
|
||||
echo "This script requires Bash; re-execing as 'bash $0'..."
|
||||
exec bash "$0" "$@"
|
||||
else
|
||||
echo "ERROR: This script requires Bash. Please run with 'bash $0' or install Bash." >&2
|
||||
exit 2
|
||||
fi
|
||||
# Thin POSIX wrapper that delegates to the canonical Python installer
|
||||
# (scripts/bootstrap.py). Platform bootstraps should prefer calling the
|
||||
# Python script using --no-delegate and -q/--quiet for quiet/non-interactive mode.
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO="$(cd "$SCRIPT_DIR/.." && pwd -P)"
|
||||
|
||||
# Prefer repo venv python, then system pythons
|
||||
if [ -x "$REPO/.venv/bin/python" ]; then
|
||||
PY="$REPO/.venv/bin/python"
|
||||
elif [ -x "$REPO/.venv/bin/python3" ]; then
|
||||
PY="$REPO/.venv/bin/python3"
|
||||
elif command -v python3 >/dev/null 2>&1; then
|
||||
PY="python3"
|
||||
elif command -v python >/dev/null 2>&1; then
|
||||
PY="python"
|
||||
else
|
||||
echo "Error: No Python interpreter found; please install Python 3 or create the project's .venv." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -euo pipefail
|
||||
# Translate -q into --quiet for the Python installer
|
||||
ARGS=()
|
||||
for a in "$@"; do
|
||||
if [ "$a" = "-q" ]; then
|
||||
ARGS+=("--quiet")
|
||||
else
|
||||
ARGS+=("$a")
|
||||
fi
|
||||
done
|
||||
|
||||
VENV_PATH=".venv"
|
||||
EDITABLE=false
|
||||
DESKTOP=false
|
||||
PYTHON_CMD=""
|
||||
NOINSTALL=false
|
||||
FORCE=false
|
||||
QUIET=false
|
||||
FIX_URLLIB3=false
|
||||
# Playwright options
|
||||
PLAYWRIGHT_BROWSERS="chromium" # comma-separated (chromium,firefox,webkit) or 'all'
|
||||
NO_PLAYWRIGHT=false
|
||||
REMOVE_PTH=false
|
||||
exec "$PY" "$REPO/scripts/bootstrap.py" --no-delegate "${ARGS[@]}"
|
||||
|
||||
# Prompt helper: read from the controlling terminal so prompts still work
|
||||
# when stdout/stderr are redirected or piped (e.g., piping output to sed).
|
||||
@@ -382,12 +386,7 @@ PY
|
||||
|
||||
else
|
||||
echo "WARNING: Could not import 'medeia_macina.cli_entry' from the venv." >&2
|
||||
# Check if legacy top-level module is present; if so, inform the user to prefer the packaged entrypoint
|
||||
if "$VENV_PY" -c 'import importlib; importlib.import_module("medeia_entry")' >/dev/null 2>&1; then
|
||||
echo "Note: 'medeia_entry' top-level module is present. It's recommended to install the project so 'medeia_macina.cli_entry' is available." >&2
|
||||
else
|
||||
echo "Action: Try running: $VENV_PY -m pip install -e . or inspect the venv site-packages to verify the installation." >&2
|
||||
fi
|
||||
echo "Action: Try running: $VENV_PY -m pip install -e . or inspect the venv site-packages to verify the installation." >&2
|
||||
fi
|
||||
|
||||
echo "Verifying environment for known issues (urllib3 compatibility)..."
|
||||
|
||||
Reference in New Issue
Block a user