Skip to content

Commit 66c4dcb

Browse files
authored
build: Add Conda environment setup and dependency installation script (#2023)
Update INSTALL.md and add configure_conda_env.bash script Signed-off-by: Alexandru Biscoveanu <alex.biscoveanu.gfx@gmail.com>
1 parent b5f2069 commit 66c4dcb

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

INSTALL.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,31 @@ Here are the steps to check out, build, and test the OSL distribution:
126126

127127
make test
128128

129+
Conda Environment
130+
-----------------
131+
132+
To simplify installation of Python and other dependencies, you can use
133+
the provided Conda environment setup script located at `src/build-scripts/`
134+
by running:
135+
136+
source src/build-scripts/configure_conda_env.bash
137+
138+
**This script will:**
139+
* Check for Miniconda installation.
140+
* Create a Conda environment named `osl-env` if it doesn't exist.
141+
* Install all required dependencies into the environment.
142+
* Activate the environment for the current shell session.
143+
144+
After running this script, the `osl-env` environment will be created, and
145+
all you need to do when opening a new shell session is simply activate the
146+
Conda environment.
147+
148+
**When to use it:**
149+
Run this script after cloning the repository and before building OSL. It
150+
sets up a consistent development environment without manually installing
151+
all dependencies. If you already have all required dependencies installed,
152+
running it is optional.
153+
129154
Troubleshooting
130155
----------------
131156

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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

Comments
 (0)