1# Setup hook for removing bytecode from the bin folder
2echo "Sourcing python-remove-bin-bytecode-hook.sh"
3
4# The bin folder is added to $PATH and should only contain executables.
5# It may happen there are executables with a .py extension for which
6# bytecode is generated. This hook removes that bytecode.
7
8pythonRemoveBinBytecodePhase() {
9 if [ -d "$out/bin" ]; then
10 rm -rf "$out/bin/__pycache__" # Python 3
11 find "$out/bin" -type f -name "*.pyc" -delete # Python 2
12 fi
13}
14
15if [ -z "${dontUsePythonRemoveBinBytecode-}" ]; then
16 appendToVar preDistPhases pythonRemoveBinBytecodePhase
17fi