|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright Contributors to the Open Shading Language project. |
| 4 | +# SPDX-License-Identifier: BSD-3-Clause |
| 5 | +# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage |
| 6 | + |
| 7 | +# --- Colors --- |
| 8 | +RED='\033[0;31m' |
| 9 | +YELLOW='\033[1;33m' |
| 10 | +GREEN='\033[0;32m' |
| 11 | +NC='\033[0m' # No Color |
| 12 | + |
| 13 | + |
| 14 | +# --- Check if the script is sourced --- |
| 15 | +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then |
| 16 | + echo -e "${YELLOW}Please run this script as:" |
| 17 | + echo -e " ${NC}source $(basename "${BASH_SOURCE[0]}")" |
| 18 | + echo -e "Otherwise, '${YELLOW}conda activate${NC}' won't persist in your current shell." |
| 19 | + return 0 2>/dev/null || exit 0 |
| 20 | +fi |
| 21 | + |
| 22 | +# --- Check if Miniconda exists --- |
| 23 | +if [ ! -f "$HOME/miniconda3/etc/profile.d/conda.sh" ]; then |
| 24 | + echo -e "${RED}Miniconda not found at ~/miniconda3.${NC}" |
| 25 | + echo -e "Please install Miniconda before running this script" |
| 26 | + echo -e "${YELLOW}Important:${NC} During installation, decline any PATH modifications." |
| 27 | + echo -e "This script activates the environment per session using 'source'." |
| 28 | + return 0 2>/dev/null || exit 0 |
| 29 | +else |
| 30 | + # Load Conda |
| 31 | + source ~/miniconda3/etc/profile.d/conda.sh |
| 32 | + |
| 33 | + # Create OSL environment if it doesn't exist |
| 34 | + if ! conda info --envs | grep -q "osl-env"; then |
| 35 | + echo "Creating osl-env Conda environment..." |
| 36 | + conda create -y -n osl-env |
| 37 | + |
| 38 | + # Activate the environment |
| 39 | + conda activate osl-env |
| 40 | + |
| 41 | + # Install dependencies |
| 42 | + echo "Installing dependencies in osl-env..." |
| 43 | + conda install -y -c conda-forge \ |
| 44 | + cmake \ |
| 45 | + llvmdev=20.1.8 clangdev clangxx_linux-64 libcxx \ |
| 46 | + python=3.12 numpy pybind11 \ |
| 47 | + openimageio=2.5 imath flex bison pugixml zlib |
| 48 | + else |
| 49 | + echo -e "${GREEN}osl-env environment already exists.${NC}" |
| 50 | + |
| 51 | + # Activate the environment |
| 52 | + conda activate osl-env |
| 53 | + fi |
| 54 | + |
| 55 | +fi |
0 commit comments