Skip to content

Instantly share code, notes, and snippets.

@sinewalker
Created May 21, 2019 02:16
Show Gist options
  • Save sinewalker/6733343f98c6895e55f3280f34051d33 to your computer and use it in GitHub Desktop.
Save sinewalker/6733343f98c6895e55f3280f34051d33 to your computer and use it in GitHub Desktop.
Freeze your python pip requirements to a known place, to guard against Homebrew mess-ups
freezenv() {
FUNCDESC='Freeze the active Python Environment pip requirements.
This stores the requirements.txt in the active $VIRTUAL_ENV or $CONDA_PREFIX
directory, overwriting any existing requirements file.'
if [[ -z ${VIRTUAL_ENV-$CONDA_PREFIX} ]] ; then
error "$FUNCNAME: no active python or conda venv"
return 1
fi
local VENV_REQS=${VIRTUAL_ENV-$CONDA_PREFIX}/requirements.txt
echo "Storing PIP package list into ${VENV_REQS}"
pip freeze > ${VENV_REQS}
}
@sinewalker
Copy link
Author

sinewalker commented May 21, 2019

not really necessary for Anaconda, since Homebrew won't mess with that. But I include the functionality for conda too, in case it's needed for other reasons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment