buildPythonPackage: remove bytecode from bin folder
When a Python script has the extension `.py`, bytecode is generated. Typically, executables in bin have no extension, so no bytecode is generated. However, some packages do provide executables with extensions, and thus bytecode is generated.
This commit is contained in:
parent
926aaa4870
commit
d945b3e53b
@ -40,6 +40,12 @@
|
|||||||
# Skip wrapping of python programs altogether
|
# Skip wrapping of python programs altogether
|
||||||
, dontWrapPythonPrograms ? false
|
, dontWrapPythonPrograms ? false
|
||||||
|
|
||||||
|
# Remove bytecode from bin folder.
|
||||||
|
# When a Python script has the extension `.py`, bytecode is generated
|
||||||
|
# Typically, executables in bin have no extension, so no bytecode is generated.
|
||||||
|
# However, some packages do provide executables with extensions, and thus bytecode is generated.
|
||||||
|
, removeBinBytecode ? true
|
||||||
|
|
||||||
, meta ? {}
|
, meta ? {}
|
||||||
|
|
||||||
, passthru ? {}
|
, passthru ? {}
|
||||||
@ -77,6 +83,11 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs [
|
|||||||
|
|
||||||
postFixup = lib.optionalString (!dontWrapPythonPrograms) ''
|
postFixup = lib.optionalString (!dontWrapPythonPrograms) ''
|
||||||
wrapPythonPrograms
|
wrapPythonPrograms
|
||||||
|
'' + lib.optionalString removeBinBytecode ''
|
||||||
|
if [ -d "$out/bin" ]; then
|
||||||
|
rm -rf "$out/bin/__pycache__" # Python 3
|
||||||
|
find "$out/bin" -type f -name "*.pyc" -delete # Python 2
|
||||||
|
fi
|
||||||
'' + lib.optionalString catchConflicts ''
|
'' + lib.optionalString catchConflicts ''
|
||||||
# Check if we have two packages with the same name in the closure and fail.
|
# Check if we have two packages with the same name in the closure and fail.
|
||||||
# If this happens, something went wrong with the dependencies specs.
|
# If this happens, something went wrong with the dependencies specs.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user