about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/pytest/4.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/python-modules/pytest/4.nix')
-rw-r--r--nixpkgs/pkgs/development/python-modules/pytest/4.nix13
1 files changed, 13 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/python-modules/pytest/4.nix b/nixpkgs/pkgs/development/python-modules/pytest/4.nix
index fd6d3507afb8..0a0ae571ba01 100644
--- a/nixpkgs/pkgs/development/python-modules/pytest/4.nix
+++ b/nixpkgs/pkgs/development/python-modules/pytest/4.nix
@@ -43,6 +43,19 @@ buildPythonPackage rec {
     }
 
     preDistPhases+=" pytestcachePhase"
+
+    # pytest generates it's own bytecode files to improve assertion messages.
+    # These files similar to cpython's bytecode files but are never laoded
+    # by python interpreter directly. We remove them for a few reasons:
+    # - files are non-deterministic: https://github.com/NixOS/nixpkgs/issues/139292
+    #   (file headers are generatedt by pytest directly and contain timestamps)
+    # - files are not needed after tests are finished
+    pytestRemoveBytecodePhase () {
+        # suffix is defined at:
+        #    https://github.com/pytest-dev/pytest/blob/4.6.11/src/_pytest/assertion/rewrite.py#L32-L47
+        find $out -name "*-PYTEST.py[co]" -delete
+    }
+    preDistPhases+=" pytestRemoveBytecodePhase"
   '';
 
   meta = with lib; {