conda build and cached packages

When developing software and building it into a conda package, an iterative development cycle can leave cached, out-of-date copies of the software under the conda root. A common result is that, though conda appears to download the source, e.g. from a git repo, the test environment is from an unknown earlier version and therefore fails to reflect the current state of the source. To get around this, I routinely use a bash script that manually removes all trace of the software package in question from the conda root:

#!/bin/bash

PKG=#package name  
CONDAROOT=#conda root, where envs/ and conda-bld/ directories exist  
CONDAPREFIX=$(conda info -a | grep sys.prefix | sed 's/sys.prefix: //')  
conda remove ${PKG}  
grep -l ${PKG} ${CONDAROOT}/envs/.pkgs/cache/* | xargs -n 1 -I {} rm {}  
rm -irf ${CONDAROOT}/envs/.pkgs/${PKG}* \  
        ${CONDAROOT}/envs/_build/lib/python3.5/site-packages/${PKG}* \
        ${CONDAROOT}/envs/_test/lib/python3.5/site-packages/${PKG}* \
        ${CONDAROOT}/conda-bld/*/${PKG}* \
        ${CONDAROOT}/conda-bld/src_cache/${PKG}* \
        ${CONDAPREFIX}/lib/python3.5/site-packages/${PKG}*

I'm not sure which of the rm paths does the trick here, but running this clean script before conda build eliminates the issue. This assumes there is only one conda root directory, which might not always be the case, but it's true on SCC right now.