Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3Packages.pytest4: deterministic bytecode #72091

Merged
merged 1 commit into from Apr 22, 2020

Conversation

d-xo
Copy link
Contributor

@d-xo d-xo commented Oct 27, 2019

Motivation for this change

For reasons that are not clear to me, the pytest4 check phase produces a lot of non-deterministic bytecode files. This PR turns off bytecode generation during test execution and additionally disables a test that force enables bytecode generation.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @domenkozar @lovek323 @madjar @lsix

For reasons that are not clear to me, the pytest4 check phase produces a
lot of non-deterministic bytecode files. This PR turns off bytecode
generation and disables a test that force enables bytecode generation.
@domenkozar
Copy link
Member

@FRidh opinions?

rm testing/test_argcomplete.py

# determinism - this test writes non deterministic bytecode
rm -rf testing/test_assertrewrite.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's I think because it uses _write_pyc_fp() which is pytest's own internal testing function for writing bytecode.

# determinism - this test writes non deterministic bytecode
rm -rf testing/test_assertrewrite.py

PYTHONDONTWRITEBYTECODE=1 $out/bin/py.test -x testing/ -k "not test_collect_pyargs_with_testpaths"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of files have indeed been rewritten with this bad bytecode.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add PYTHONDONTWRITEBYTECODE=1 to the pytestCheckHook @FRidh ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. It can happen in case pytest is simply used. A better solution is probably for it to adhere to SOURCE_DATE_EPOCH, but there's probably a reason why this custom function exists.

@domenkozar
Copy link
Member

@GrahamcOfBorg build python3Packages.pytest4

@domenkozar
Copy link
Member

@GrahamcOfBorg build python3Packages.pytest_4

@domenkozar domenkozar merged commit a63762a into NixOS:master Apr 22, 2020
Staging automation moved this from Ready to Done Apr 22, 2020
@d-xo d-xo deleted the reproducible-pytest4 branch April 22, 2020 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Staging
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants