mirror of
https://github.com/PR0M3TH3AN/python_charts.git
synced 2026-11-02 20:00:42 +00:00
Update AGENTS.md and scripts for global dependency installation
- Revise instructions in AGENTS.md to clarify that Python scripts should be run via `startup.sh`, which now installs dependencies globally. - Enhance project overview and command sections for better clarity on usage. - Update coding standards to reflect Python version requirements and Bash script practices. - Improve formatting and organization of command examples for better readability.
This commit is contained in:
1 parent
0b491c4416
commit
a1cf3c888a
5 files changed
+118
-135
No files matched your search
+17
-38
@@ -1,69 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
# -------------------------------------------------------------------
|
||||
# startup.sh — prepare Python env, ensure deps & data, then run.
|
||||
# startup.sh — install deps globally, fetch data, then run command
|
||||
# Usage:
|
||||
# ./startup.sh [options] # passes options to default plot script
|
||||
# ./startup.sh [script or cmd] # runs specified script/command
|
||||
# ./startup.sh [options] # passes options to default plot script
|
||||
# ./startup.sh <script> [args] # runs specified script with system Python
|
||||
# Examples:
|
||||
# ./startup.sh --offset 12 --end 2025-05-31 --extend-years 5
|
||||
# ./startup.sh pytest -q
|
||||
# -------------------------------------------------------------------
|
||||
set -euo pipefail
|
||||
|
||||
VENV_DIR="venv"
|
||||
REQ_FILE="requirements.txt"
|
||||
WHEELHOUSE="wheelhouse"
|
||||
DATA_DB="data/fred.db"
|
||||
PYTHON="$VENV_DIR/bin/python"
|
||||
DEFAULT_SCRIPT="scripts/lagged_oil_unrate_chart_styled.py"
|
||||
|
||||
# 1) Create or reuse venv
|
||||
if [[ ! -d "$VENV_DIR" ]]; then
|
||||
echo "🔧 Creating virtual-env…"
|
||||
python3 -m venv "$VENV_DIR"
|
||||
fi
|
||||
|
||||
# 2) Activate venv
|
||||
# shellcheck disable=SC1090
|
||||
source "$VENV_DIR/bin/activate"
|
||||
|
||||
# 3) Upgrade pip & setuptools
|
||||
# 1) Ensure pip & setuptools are up to date
|
||||
echo "🛠 Upgrading pip & setuptools…"
|
||||
$PYTHON -m pip install --upgrade pip setuptools
|
||||
pip install --upgrade pip setuptools
|
||||
|
||||
# 4) Install dependencies
|
||||
PIP_OPTS=(install --upgrade --no-input)
|
||||
if [[ -d "$WHEELHOUSE" ]]; then
|
||||
echo "📦 Installing from wheelhouse…"
|
||||
$PYTHON -m pip "${PIP_OPTS[@]}" --no-index --find-links="$WHEELHOUSE" -r "$REQ_FILE" \
|
||||
|| { echo "⚠️ Wheelhouse failed—falling back…"; \
|
||||
$PYTHON -m pip "${PIP_OPTS[@]}" -r "$REQ_FILE"; }
|
||||
else
|
||||
echo "🌐 Installing from PyPI…"
|
||||
$PYTHON -m pip "${PIP_OPTS[@]}" -r "$REQ_FILE"
|
||||
fi
|
||||
# 2) Install project dependencies globally
|
||||
echo "📦 Installing dependencies from $REQ_FILE…"
|
||||
pip install --upgrade -r "$REQ_FILE"
|
||||
|
||||
echo "✅ Virtual-env ready ($($PYTHON -V))"
|
||||
|
||||
# 5) Ensure data exists
|
||||
# 3) Ensure data exists
|
||||
if [[ ! -f "$DATA_DB" ]]; then
|
||||
echo "🔄 Data not found—downloading FRED series…"
|
||||
$PYTHON scripts/refresh_data.py
|
||||
python scripts/refresh_data.py
|
||||
fi
|
||||
|
||||
# 6) Build command
|
||||
# 4) Dispatch to the right command
|
||||
if [[ $# -eq 0 ]]; then
|
||||
CMD=("$PYTHON" "$DEFAULT_SCRIPT" --offset 18)
|
||||
# no args → run default plot
|
||||
CMD=(python "$DEFAULT_SCRIPT" --offset 18)
|
||||
elif [[ "$1" == --* ]]; then
|
||||
CMD=("$PYTHON" "$DEFAULT_SCRIPT" "$@")
|
||||
# args start with -- → forward to default plot
|
||||
CMD=(python "$DEFAULT_SCRIPT" "$@")
|
||||
else
|
||||
# first token is script or other command
|
||||
if [[ -f "$1" || "$1" == *.py ]]; then
|
||||
CMD=("$PYTHON" "$@")
|
||||
CMD=(python "$@")
|
||||
else
|
||||
CMD=("$@")
|
||||
fi
|
||||
fi
|
||||
|
||||
# 7) Execute
|
||||
echo "🚀 Executing: ${CMD[*]}"
|
||||
exec "${CMD[@]}"
|
||||
Reference in new issue
Block a user