Created
June 19, 2018 17:44
-
-
Save PerilousApricot/9e4d0e2c4f7a21ca05a1731697822204 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the CMSSW libraries (specifically ROOT) | |
SCRAM_ARCH=$(ls -d /cvmfs/cms.cern.ch/$(/cvmfs/cms.cern.ch/common/cmsos)*/cms/cmssw/${CMSSW_VER} | tail -n 1 | awk -F / '{ print $4 }') | |
export SCRAM_ARCH | |
source /cvmfs/cms.cern.ch/cmsset_default.sh | |
if [ ! -d cmssw-env ]; then | |
scramv1 project --name cmssw-env CMSSW $CMSSW_VER | |
fi | |
cd cmssw-env | |
eval `scramv1 runtime -sh` | |
virtualenv venv | |
source venv/bin/activate | |
pip install <PACKAGES> | |
# Make a wrapper script to load CMSSW python | |
cat << 'EOF' > bin/python_wrapper.sh | |
#!/bin/bash | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
source /cvmfs/cms.cern.ch/cmsset_default.sh | |
cd $DIR | |
eval `scramv1 runtime -sh` | |
source venv/bin/activate | |
cd - | |
exec python "$@" | |
EOF | |
chmod +x bin/python_wrapper.sh | |
# Create the kernel | |
mkdir -p "$HOME/.local/share/jupyter/kernels/$KERNEL_NAME" | |
cat << EOF > "$HOME/.local/share/jupyter/kernels/$KERNEL_NAME/kernel.json" | |
{ | |
"display_name": "$KERNEL_NAME", | |
"language": "python", | |
"argv": [ | |
"$PWD/bin/python_wrapper.sh", | |
"-m", | |
"ipykernel_launcher", | |
"-f", | |
"{connection_file}" | |
] | |
} | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment