3tj2rw
Last Updated: February 25, 2016
·
731
· elus

No *.pyc files in virtualenvs (virtualenvwrapper)

Easy way to prevent creating a *.pyc files in active virtualenv using virtualenvwrapper hooks:

$ echo -e '\nexport PYTHONDONTWRITEBYTECODE_BACK=$PYTHONDONTWRITEBYTECODE\nexport PYTHONDONTWRITEBYTECODE=1\n' >> $VIRTUALENVWRAPPER_HOOK_DIR/postactivate
$ echo -e '\nexport PYTHONDONTWRITEBYTECODE=$PYTHONDONTWRITEBYTECODE_BACK\nunset PYTHONDONTWRITEBYTECODE_BACK\n' >> $VIRTUALENVWRAPPER_HOOK_DIR/predeactivate