Micah P. Dombrowski / Jan 18 2019
Auto-Env Mockup/NGLview
Auto-Env Mockup/NGLview
git clone https://github.com/arose/nglview
cd nglview if [ -f "environment.yml" ]; then # remove any python entry—it just causes issues sed -i '/ python/d' environment.yml source activate base conda-env elif [ -f requirements.txt ]; then pip install -r requirements.txt elif [ -f setup.py ]; then reqs=$(paste -s -d ' ' setup.py | \ sed "s/.*install_requires.:[[:space:]]*\[//; s/].*//; s/['\",]//g") opts=$(paste -s -d ' ' setup.py | \ sed "s/.*extras_require.:[[:space:]]*{//; s/}.*//; s/],/]\n/g" | \ sed "s/^.*://; s/[]['\"]//g; s/,/ /g" | paste -s -d ' ') pip install ${reqs} fi
Determine which packages are available via conda and which require pip.
293.5s
Language:Bash
primary="nglview" reqs="ipywidgets>=7 numpy" opts="simpletraj mdtraj pytraj MDAnalysis parmed rdkit ase htmd" set +u echo "Discovering conda packages..." for pkg in $reqs; do if conda search "$pkg" &> /dev/null; then reqs_con="$reqs_con $pkg" else reqs_pip="$reqs_pip $pkg"; fi done for pkg in $opts; do if conda search "$pkg" &> /dev/null; then opts_con="$opts_con $pkg" else opts_pip="$opts_pip $pkg"; fi done # This makes things work. ¯\_(ツ)_/¯ con_inst="$reqs_con"; pip_inst="$reqs_pip" if [ -n "$con_inst" ]; then echo "Installing required conda packages..." conda install -q $con_inst fi if [ -n "$opts_con" ]; then echo "Attempting install of optional conda packages..." for pkg in $opts_con; do if conda install -q "$pkg"; then echo -e "\t$pkg succeeded." else echo -e "\t$pkg failed."; fi done fi if [ -n "$pip_inst" ]; then echo "Installing required pip packages..." pip -q install $pip_inst fi if [ -n "$opts_pip" ]; then echo "Attempting install of optional pip packages..." for pkg in $opts_pip; do if pip -q install "$pkg"; then echo -e "\t$pkg succeeded." else echo -e "\t$pkg failed."; fi done fi if [ -n "$primary" ]; then echo "Installing primary package $primary..." pip install $primary fi echo "done."