|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 4 | +# SPDX-License-Identifier: Apache-2.0 |
| 5 | + |
| 6 | +# Setup a local conda environment for building the sphinx docs to mirror the CI environment |
| 7 | +# (see cuda_python/docs/environment-docs.yml). |
| 8 | +# |
| 9 | +# Usage: |
| 10 | +# ./toolshed/setup-docs-env.sh |
| 11 | +# |
| 12 | +# Notes: |
| 13 | +# - Requires an existing Miniforge/Conda install and `conda` on PATH. |
| 14 | +# - Installs the same packages as CI’s environment-docs.yml. |
| 15 | + |
| 16 | +set -euo pipefail |
| 17 | + |
| 18 | +ENV_NAME="cuda-python-docs" |
| 19 | +PYVER="3.12" |
| 20 | + |
| 21 | +have_cmd() { command -v "$1" >/dev/null 2>&1; } |
| 22 | + |
| 23 | +# --- sanity checks ----------------------------------------------------------- |
| 24 | +if ! have_cmd conda; then |
| 25 | + echo "ERROR: 'conda' not found on PATH. Please ensure Miniforge is installed and initialized." >&2 |
| 26 | + exit 1 |
| 27 | +fi |
| 28 | + |
| 29 | +# Load conda's shell integration into this bash process |
| 30 | +eval "$(conda shell.bash hook)" |
| 31 | + |
| 32 | +# --- create/update environment ---------------------------------------------- |
| 33 | +if conda env list | awk '{print $1}' | grep -qx "${ENV_NAME}"; then |
| 34 | + echo "⚠ Environment '${ENV_NAME}' already exists → NO ACTION" |
| 35 | + exit 0 |
| 36 | +fi |
| 37 | + |
| 38 | +echo "Creating environment '${ENV_NAME}'…" |
| 39 | +# ATTENTION: This dependency list is duplicated in |
| 40 | +# cuda_python/docs/environment-docs.yml. Please KEEP THEM IN SYNC! |
| 41 | +conda create -y -n "${ENV_NAME}" \ |
| 42 | + "python=${PYVER}" \ |
| 43 | + cython \ |
| 44 | + myst-parser \ |
| 45 | + numpy \ |
| 46 | + numpydoc \ |
| 47 | + pip \ |
| 48 | + pydata-sphinx-theme \ |
| 49 | + pytest \ |
| 50 | + scipy \ |
| 51 | + "sphinx<8.2.0" \ |
| 52 | + sphinx-copybutton \ |
| 53 | + myst-nb \ |
| 54 | + enum_tools \ |
| 55 | + sphinx-toolbox \ |
| 56 | + pyclibrary |
| 57 | + |
| 58 | +conda activate "${ENV_NAME}" |
| 59 | +python -m pip install --upgrade pip |
| 60 | +python -m pip install nvidia-sphinx-theme |
| 61 | + |
| 62 | +echo |
| 63 | +echo "✅ Environment '${ENV_NAME}' is ready." |
| 64 | +echo |
| 65 | +echo "Build docs with e.g.:" |
| 66 | +echo " conda activate ${ENV_NAME}" |
| 67 | +echo " cd cuda_pathfinder/" |
| 68 | +echo " pip install -e ." |
| 69 | +echo " (cd docs/ && rm -rf build && ./build_docs.sh)" |
0 commit comments