#!/bin/bash
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
MODE="wheel"
REQUIREMENTS_FILE="requirements.txt"
while [ $# -gt 0 ]; do
case "$1" in
--editable|-e)
MODE="editable"
shift
;;
--cu12)
REQUIREMENTS_FILE="requirements.txt"
shift
;;
--cu13)
REQUIREMENTS_FILE="requirements-cu13.txt"
shift
;;
--help|-h)
echo "CUTLASS IR Python DSL Setup Script"
echo ""
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " -e, --editable Install in editable/development mode"
echo " --cu12 Use CUDA 12 requirements (default)"
echo " --cu13 Use CUDA 13 requirements"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " # Install from wheel (CUDA 12)"
echo " $0"
echo ""
echo " # Install from wheel (CUDA 13)"
echo " $0 --cu13"
echo ""
echo " # Install in editable mode (requires CUTLASS_IR_BUILD_DIR)"
echo " export CUTLASS_IR_BUILD_DIR=/path/to/build"
echo " $0 --editable"
echo ""
echo " # Install in editable mode with CUDA 13 dev deps"
echo " export CUTLASS_IR_BUILD_DIR=../../../build"
echo " $0 --editable --cu13"
echo ""
echo "For more details on editable install, see README.md"
exit 0
;;
*)
echo "Error: Unknown argument '$1'"
echo "Use --help for usage information"
exit 1
;;
esac
done
if [ "$MODE" = "editable" ]; then
echo "====================================================================="
echo "Installing CUTLASS IR Python DSL in EDITABLE mode"
echo "====================================================================="
echo ""
if [ -z "$CUTLASS_IR_BUILD_DIR" ]; then
echo "ERROR: CUTLASS_IR_BUILD_DIR environment variable is required for editable install"
echo ""
echo "Please set it to your CMake build directory:"
echo " export CUTLASS_IR_BUILD_DIR=/path/to/build"
echo ""
echo "Or use a relative path:"
echo " export CUTLASS_IR_BUILD_DIR=../../../build"
echo ""
echo "Then run this script again."
exit 1
fi
echo "Build directory: $CUTLASS_IR_BUILD_DIR"
echo ""
echo "Installing with dev dependencies..."
pip install -e ".[dev]"
echo ""
echo "====================================================================="
echo "Editable installation complete!"
echo "====================================================================="
echo ""
echo "You can now import cutlass from anywhere:"
echo " python -c 'import cutlass; print(cutlass.__version__)'"
echo ""
echo "Runtime environment (CUTE_DSL_LIBS) is automatically configured."
echo "Changes to Python code will be immediately available without reinstall."
echo ""
echo "See README.md for development workflow details."
else
echo "Installing CUTLASS IR Python DSL from wheel"
echo ""
REQUIREMENTS_PATH="${SCRIPT_DIR}/${REQUIREMENTS_FILE}"
if [ ! -f "$REQUIREMENTS_PATH" ]; then
echo "Error: Requirements file not found: $REQUIREMENTS_PATH"
exit 1
fi
echo "Installing from: $REQUIREMENTS_FILE"
pip install -r "$REQUIREMENTS_PATH"
echo ""
echo "Installation complete!"
fi