Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions activate_conda_osl_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add the customary copyright notice here.

Suggested change
# 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's pretty old. Can we use at least OpenImageIO 3.0 by default?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like conda-forge has up to v2.5.18.0 sadly :/
https://anaconda.org/conda-forge/openimageio

Maybe mamba could be an alternative?
https://openmamba.org/en/rpms/base/python-OpenImageIO/aarch64/

Copy link
Author

@bisqq bisqq Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What we could do is, download from the OpenImageIO repo binaries and install them directly

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The OpenImageIO repo does not currently provide pre-built binaries.

However, this OSL repo already has a src/build-scripts/build_openimageio.bash that can build OIIO from scratch.

else
echo -e "${GREEN}osl-env environment already exists.${NC}"

# Activate the environment
conda activate osl-env
fi

fi