#!/bin/bash -i
# Create a fresh conda environment with the dependencies, then export it
# Usage:
#    ./freeze_env

# Configure bash with conda active
shopt -s expand_aliases
source ~/.bashrc

start=$SECONDS
basename="sciris_docs_v"
version=`python -c 'import sciris as sc; print(sc.__version__)'`
name="$basename$version"

echo "===== Creating and activating environment $name... ======"
conda create -n $name python=3.9 -y
conda activate $name

echo "===== Installing Sciris $version and docs requirements... ======"
pip install -r ../requirements.txt
pip install -r requirements.txt

echo "===== Exporting conda environment $name... ======"
conda env export > environment.yml

echo "===== Deleting conda environment $name... ======"
conda activate base
conda env remove -n $name

duration=$(( SECONDS - start ))
echo "Done: took $duration seconds."