Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c055851648cd
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: da12111115c4
Choose a head ref
  • 3 commits
  • 5 files changed
  • 2 contributors

Commits on Jun 13, 2020

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a7ea828 View commit details
  2. buildPythonPackage: recompile bytecode for reproducibility

    Due to a change in pip the unpacked wheels are no longer reproducible.
    We recompile the bytecode to cleanup this error.
    #81441
    FRidh committed Jun 13, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    818cf78 View commit details
  3. Merge pull request #90208 from FRidh/bytecode

    buildPythonPackage: recompile bytecode for reproducibility
    FRidh authored Jun 13, 2020
    Copy the full SHA
    da12111 View commit details
11 changes: 11 additions & 0 deletions pkgs/development/interpreters/python/hooks/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Hooks for building Python packages.
{ python
, lib
, callPackage
, makeSetupHook
, disabledIf
@@ -97,6 +98,16 @@ in rec {
};
} ./python-namespaces-hook.sh) {};

pythonRecompileBytecodeHook = callPackage ({ }:
makeSetupHook {
name = "python-recompile-bytecode-hook";
substitutions = {
inherit pythonInterpreter pythonSitePackages;
compileArgs = lib.concatStringsSep " " (["-q" "-f" "-i -"] ++ lib.optionals isPy3k ["-j $NIX_BUILD_CORES"]);
bytecodeName = if isPy3k then "__pycache__" else "*.pyc";
};
} ./python-recompile-bytecode-hook.sh ) {};

pythonRemoveBinBytecodeHook = callPackage ({ }:
makeSetupHook {
name = "python-remove-bin-bytecode-hook";
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Setup hook for recompiling bytecode.
# https://github.com/NixOS/nixpkgs/issues/81441
echo "Sourcing python-recompile-bytecode-hook.sh"

# Remove all bytecode from the $out output. Then, recompile only site packages folder
# Note this effectively duplicates `python-remove-bin-bytecode`, but long-term
# this hook should be removed again.

pythonRecompileBytecodePhase () {
# TODO: consider other outputs than $out

items="$(find "$out" -name "@bytecodeName@")"
if [[ -n $items ]]; then
for pycache in $items; do
rm -rf "$pycache"
done
fi

find "$out"/@pythonSitePackages@ -name "*.py" -exec @pythonInterpreter@ -OO -m compileall @compileArgs@ {} +
}

if [ -z "${dontUsePythonRecompileBytecode-}" ]; then
postPhases+=" pythonRecompileBytecodePhase"
fi
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Setup hook for detecting conflicts in Python packages
# Setup hook for removing bytecode from the bin folder
echo "Sourcing python-remove-bin-bytecode-hook.sh"

# 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.
# Intentionally kept in a subdirectory, see catch_conflicts/README.md.
# The bin folder is added to $PATH and should only contain executables.
# It may happen there are executables with a .py extension for which
# bytecode is generated. This hook removes that bytecode.

pythonRemoveBinBytecodePhase () {
if [ -d "$out/bin" ]; then
2 changes: 2 additions & 0 deletions pkgs/development/interpreters/python/mk-python-derivation.nix
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
, pythonCatchConflictsHook
, pythonImportsCheckHook
, pythonNamespacesHook
, pythonRecompileBytecodeHook
, pythonRemoveBinBytecodeHook
, pythonRemoveTestsDirHook
, setuptoolsBuildHook
@@ -110,6 +111,7 @@ let
python
wrapPython
ensureNewerSourcesForZipFilesHook # move to wheel installer (pip) or builder (setuptools, flit, ...)?
pythonRecompileBytecodeHook # Remove when solved https://github.com/NixOS/nixpkgs/issues/81441
pythonRemoveTestsDirHook
] ++ lib.optionals catchConflicts [
setuptools pythonCatchConflictsHook
1 change: 1 addition & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
@@ -118,6 +118,7 @@ in {
pythonCatchConflictsHook
pythonImportsCheckHook
pythonNamespacesHook
pythonRecompileBytecodeHook
pythonRemoveBinBytecodeHook
pythonRemoveTestsDirHook
setuptoolsBuildHook