From ed746dff33de7849c2ac30a8e6e3928bf5091b72 Mon Sep 17 00:00:00 2001 From: Alexandru Biscoveanu Date: Sun, 25 Jan 2026 10:45:10 -0800 Subject: [PATCH] Update INSTALL.md and add configure_conda_env.bash script Signed-off-by: Alexandru Biscoveanu --- INSTALL.md | 25 ++++++++++ src/build-scripts/configure_conda_env.bash | 55 ++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 src/build-scripts/configure_conda_env.bash diff --git a/INSTALL.md b/INSTALL.md index 6366aae37..8c6dd5f44 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -126,6 +126,31 @@ Here are the steps to check out, build, and test the OSL distribution: make test +Conda Environment +----------------- + +To simplify installation of Python and other dependencies, you can use +the provided Conda environment setup script located at `src/build-scripts/` +by running: + + source src/build-scripts/configure_conda_env.bash + +**This script will:** + * Check for Miniconda installation. + * Create a Conda environment named `osl-env` if it doesn't exist. + * Install all required dependencies into the environment. + * Activate the environment for the current shell session. + +After running this script, the `osl-env` environment will be created, and +all you need to do when opening a new shell session is simply activate the +Conda environment. + +**When to use it:** +Run this script after cloning the repository and before building OSL. It +sets up a consistent development environment without manually installing +all dependencies. If you already have all required dependencies installed, +running it is optional. + Troubleshooting ---------------- diff --git a/src/build-scripts/configure_conda_env.bash b/src/build-scripts/configure_conda_env.bash new file mode 100644 index 000000000..0700b6ba7 --- /dev/null +++ b/src/build-scripts/configure_conda_env.bash @@ -0,0 +1,55 @@ +#!/bin/bash + +# Copyright Contributors to the Open Shading Language project. +# SPDX-License-Identifier: BSD-3-Clause +# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage + +# --- Colors --- +RED='\033[0;31m' +YELLOW='\033[1;33m' +GREEN='\033[0;32m' +NC='\033[0m' # No Color + + +# --- Check if the script is sourced --- +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + echo -e "${YELLOW}Please run this script as:" + echo -e " ${NC}source $(basename "${BASH_SOURCE[0]}")" + echo -e "Otherwise, '${YELLOW}conda activate${NC}' won't persist in your current shell." + return 0 2>/dev/null || exit 0 +fi + +# --- Check if Miniconda exists --- +if [ ! -f "$HOME/miniconda3/etc/profile.d/conda.sh" ]; then + echo -e "${RED}Miniconda not found at ~/miniconda3.${NC}" + echo -e "Please install Miniconda before running this script" + echo -e "${YELLOW}Important:${NC} During installation, decline any PATH modifications." + echo -e "This script activates the environment per session using 'source'." + return 0 2>/dev/null || exit 0 +else + # Load Conda + source ~/miniconda3/etc/profile.d/conda.sh + + # Create OSL environment if it doesn't exist + if ! conda info --envs | grep -q "osl-env"; then + echo "Creating osl-env Conda environment..." + conda create -y -n osl-env + + # Activate the environment + conda activate osl-env + + # Install dependencies + echo "Installing dependencies in osl-env..." + conda install -y -c conda-forge \ + cmake \ + llvmdev=20.1.8 clangdev clangxx_linux-64 libcxx \ + python=3.12 numpy pybind11 \ + openimageio=2.5 imath flex bison pugixml zlib + else + echo -e "${GREEN}osl-env environment already exists.${NC}" + + # Activate the environment + conda activate osl-env + fi + +fi