diff options
author | Robert Reed <robert.mc.reed@gmail.com> | 2021-08-22 22:28:19 -0700 |
---|---|---|
committer | Robert Reed <robert.mc.reed@gmail.com> | 2021-08-22 22:28:19 -0700 |
commit | 2ab2653cd5fd1622797771eb5dfc0b64b1ec71e2 (patch) | |
tree | 47fc7ba3d824c9948d50f60a4bd903b7f7747219 | |
parent | 32963214d5e6768da2129e75c87522a824301adf (diff) |
feat: automate setup via conda
-rwxr-xr-x | conda.sh | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/conda.sh b/conda.sh new file mode 100755 index 0000000..6eacf90 --- /dev/null +++ b/conda.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +# exit on any errors +set -e + +function inform() { echo -e "\n[INFO] $@\n"; } +function warn() { echo -e "\n[WARN] $@\n"; } +function error() { echo -e "\n[ERROR] $@\n"; } + +# exit unless user responds with yes +function confirmContinue() { + while true; do + read -p "$@ [y/n]" yn + case $yn in + [Yy]* ) break;; + [Nn]* ) exit 0;; + * ) error "Please answer yes or no.";; + esac + done +} + +if ! which conda &> /dev/null; then + error "Conda not found.\n\nVisit https://docs.anaconda.com/anaconda/install/index.html for more info." + exit 1 +fi + +# Enable "conda activate" and "conda deactivate" +eval "$(conda shell.bash hook)" + +envName=dactyl-keyboard + +if [ "$1" = "--uninstall" ]; then + confirmContinue "Would you like to remove the conda environment $envName?" + conda deactivate + conda env remove -n $envName + exit +fi + +if conda info --envs | grep $envName &> /dev/null; then + warn "Conda env \"$envName\" already exists." + confirmContinue "Do you want to overwrite it?" +fi + +inform "Creating conda environment: $envName..." + +conda create --name=$envName python=3.7 -y + +conda activate $envName + +inform "Installing PythonOCC..." + +conda install -c conda-forge pythonocc-core=7.4.1 -y + +inform "Installing CadQuery..." + +conda install -c conda-forge -c cadquery cadquery=2 -y + +inform "Installing dataclasses_json..." + +pip install dataclasses-json + +inform "Installing numpy..." + +pip install numpy + +inform "Installing scipy..." + +pip install scipy + +inform "Updating conda dependencies..." + +conda update --all -y + +inform "Success!\n\n\tRun \"conda activate $envName\" to activate the environment." |