generated from cording12/next-fast-turbo
-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add conda one-click installer script and documentation #389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Aki-07
wants to merge
5
commits into
MODSetter:main
Choose a base branch
from
Aki-07:feat/conda-script
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+147
−5
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
099e333
feat: add conda one-click installer
Aki-07 2c30139
docs: document conda one-click installer
Aki-07 8b150cf
feat: move script to the project root
Aki-07 0a11de9
feat: Prioritize Conda one-click installer in README
Aki-07 184df08
fix: Define BACKEND_DIR and correct usage in oneclick-conda-install.sh
Aki-07 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| ###################################################################### | ||
| # SurfSense one-click installer (Conda based) | ||
| # | ||
| # This script bootstraps the SurfSense stack by: | ||
| # 1. Creating a Conda environment with Python 3.12 (configurable) | ||
| # 2. Installing the backend in editable mode with all Python deps | ||
| # 3. Installing frontend dependencies (Next.js app + browser extension) | ||
| # | ||
| # Requirements: | ||
| # - Miniconda/Anaconda available on PATH (`conda --version`) | ||
| # - Node.js LTS (v18+) with npm for the frontend pieces | ||
| # | ||
| # Usage: | ||
| # chmod +x oneclick-conda-install.sh | ||
| # ./oneclick-conda-install.sh # installs into env `surfsense` | ||
| # SURFSENSE_ENV_NAME=custom ./oneclick-conda-install.sh | ||
| # SURFSENSE_PYTHON_VERSION=3.11 ./oneclick-conda-install.sh | ||
| # | ||
| # The script is idempotent — rerunning will reuse the Conda environment | ||
| # and only reinstall missing dependencies. | ||
| ###################################################################### | ||
|
|
||
| readonly PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| readonly FRONTEND_DIR="${PROJECT_ROOT}/surfsense_web" | ||
| readonly EXTENSION_DIR="${PROJECT_ROOT}/surfsense_browser_extension" | ||
| readonly BACKEND_DIR="${PROJECT_ROOT}/surfsense_backend" | ||
|
|
||
| ENV_NAME="${SURFSENSE_ENV_NAME:-surfsense}" | ||
| PYTHON_VERSION="${SURFSENSE_PYTHON_VERSION:-3.12}" | ||
|
|
||
| info() { | ||
| printf "\033[1;32m[INFO]\033[0m %s\n" "$*" | ||
| } | ||
|
|
||
| warn() { | ||
| printf "\033[1;33m[WARN]\033[0m %s\n" "$*" >&2 | ||
| } | ||
|
|
||
| error() { | ||
| printf "\033[1;31m[ERROR]\033[0m %s\n" "$*" >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| require_command() { | ||
| local cmd="$1" | ||
| if ! command -v "$cmd" >/dev/null 2>&1; then | ||
| error "Command '$cmd' not found. Please install it and re-run." | ||
| fi | ||
| } | ||
|
|
||
| conda_env_exists() { | ||
| conda env list | awk '{print $1}' | grep -Fxq "$ENV_NAME" | ||
| } | ||
|
|
||
| conda_run() { | ||
| conda run --no-capture-output -n "$ENV_NAME" "$@" | ||
| } | ||
|
|
||
| main() { | ||
| info "SurfSense one-click Conda installer starting…" | ||
|
|
||
| require_command conda | ||
|
|
||
| if ! conda_env_exists; then | ||
| info "Creating Conda environment '$ENV_NAME' with Python ${PYTHON_VERSION}…" | ||
| conda create -y -n "$ENV_NAME" "python=${PYTHON_VERSION}" | ||
| else | ||
| info "Conda environment '$ENV_NAME' already exists. Reusing it." | ||
| fi | ||
|
|
||
| info "Upgrading pip/setuptools/wheel inside '$ENV_NAME'…" | ||
| conda_run python -m pip install --upgrade pip setuptools wheel | ||
|
|
||
| info "Installing SurfSense backend dependencies…" | ||
| if [[ ! -d "${BACKEND_DIR}" ]]; then | ||
| error "Backend directory not found at '${BACKEND_DIR}'. Verify repository layout and adjust BACKEND_DIR." | ||
| fi | ||
| conda_run python -m pip install -e "${BACKEND_DIR}" | ||
|
|
||
| info "Installing optional developer helpers…" | ||
| conda_run python -m pip install "pre-commit>=3.8.0" | ||
|
|
||
| if command -v npm >/dev/null 2>&1; then | ||
| if command -v node >/dev/null 2>&1; then | ||
| NODE_MAJOR="$(node -v | sed -E 's/^v([0-9]+).*/\1/')" | ||
| if [[ "${NODE_MAJOR}" -lt 18 ]]; then | ||
| warn "Detected Node.js v$(node -v). Require >= v18; skipping frontend installs." | ||
| NODE_OK=false | ||
| else | ||
| NODE_OK=true | ||
| fi | ||
| else | ||
| warn "node not found (only npm present); skipping frontend installs." | ||
| NODE_OK=false | ||
| fi | ||
| if [[ "${NODE_OK:-false}" == true ]]; then | ||
| if [[ -d "${FRONTEND_DIR}" ]]; then | ||
| info "Installing frontend dependencies (surfsense_web)…" | ||
| (cd "${FRONTEND_DIR}" && npm install) | ||
| else | ||
| warn "Frontend directory not found at '${FRONTEND_DIR}'. Skipping web app install." | ||
| fi | ||
| if [[ -d "${EXTENSION_DIR}" ]]; then | ||
| info "Installing browser extension dependencies (surfsense_browser_extension)…" | ||
| (cd "${EXTENSION_DIR}" && npm install) | ||
| else | ||
| warn "Extension directory not found at '${EXTENSION_DIR}'. Skipping extension install." | ||
| fi | ||
| fi | ||
| else | ||
| warn "npm not found; skipping frontend dependency installation. Install Node.js 18+ to enable the web UI." | ||
| fi | ||
|
|
||
| info "Done! To begin using SurfSense:" | ||
| cat <<EOF | ||
|
|
||
| 1. Activate the Conda environment: | ||
| conda activate ${ENV_NAME} | ||
|
|
||
| 2. Start the backend API: | ||
| (cd "${BACKEND_DIR}" && uvicorn app.app:app --reload) | ||
| or refer to DEPLOYMENT_GUIDE.md for production options. | ||
|
|
||
| 3. Start the web app (if npm was available): | ||
| (cd ${FRONTEND_DIR} && npm run dev) | ||
|
|
||
| Refer to README.md for next steps and environment configuration. | ||
| EOF | ||
| } | ||
|
|
||
| main "$@" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.