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

pythonPackages.pynacl: ignore timeout in tests #34858

Merged
merged 1 commit into from Feb 18, 2018
Merged

pythonPackages.pynacl: ignore timeout in tests #34858

merged 1 commit into from Feb 18, 2018

Conversation

va1entin
Copy link
Contributor

Motivation for this change

In addition to a deadline there is also a timeout in pynacl tests, which might result in failing builds on slow machines. The new prePatch phase turns both off.

Things done

Set timeout to unlimited and deadline to None in hypothesis tests for pynacl

  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-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 nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@dotlambda
Copy link
Member

I think in this case it's better to create a patch rather than using sed. It's quite confusing like that.

@dotlambda
Copy link
Member

And why are you using prePatch now?

@FRidh
Copy link
Member

FRidh commented Feb 11, 2018

Earlier you opened #34847 which we merged. It was still not properly fixed?

@va1entin
Copy link
Contributor Author

The timeout was not fixed there, the deadline was but due to my inexperience (my first "big" PR to nixpkgs) I thought preCheck was the right stage to go with, @dotlambda was right of course: I want prePatch.

Thanks for your patience and help, guys! Creating a patch file now 😊

@dotlambda
Copy link
Member

After this has been resolved, I'll try building the package on a veeeeery slow ARMv7 machine. So please don't merge before my confirmation.

don't modify test_aead.py yet

add pynacl-no-timeout-and-deadline.patch
max_value=16 * 1024 * 1024)
)
-@settings(deadline=1500, max_examples=20)
+@settings(timeout=unlimited, deadline=None, max_examples=20)
Copy link
Member

Choose a reason for hiding this comment

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

When there was no timeout before, why do you have to set it to unlimited?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it's set to 60s by default: http://hypothesis.readthedocs.io/en/latest/settings.html?highlight=timeout#hypothesis.settings.timeout

I put a time.sleep into the tests and not specifying the timeout actually lets it fail if it takes longer than 60s. Of course you need a really really slow system for this to take longer than a minute.

Copy link
Member

Choose a reason for hiding this comment

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

If that's the case, what do you think about disabling the timeout for the hypothesis package completely, @FRidh? Of course I don't know if that's possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Besides that the timeout feature is also already deprecated and will be removed at some point in the future: http://hypothesis.readthedocs.io/en/latest/changes.html#id118
Until then using unlimited is recommended, though.

@dotlambda
Copy link
Member

dotlambda commented Feb 11, 2018

Actually, I think this derivation needs to be changed a little more.
According to https://github.com/pyca/pynacl/blob/master/INSTALL.rst#linux-source-build, pynacl ships a copy of the libsodium source. During installation, libsodium is built. However, it would be much nicer to use the libsodium provided by nixpkgs, which is possible using SODIUM_INSTALL=system.
However, I can do that in a different PR if you don't want to do it, @va1entin.

@va1entin
Copy link
Contributor Author

Thanks for pointing that out, @dotlambda
If you can spare some time, feel free to do that.
I tried to do it in installPhase but wasn't successful so far.

@dotlambda
Copy link
Member

I can confirm that tests do not fail anymore on my Banana Pi with this PR applied.
So from my point of view this is ready to go and then we can further investigate how to use system libsodium.

@dotlambda
Copy link
Member

I propose the following changes:

diff --git a/pkgs/development/python-modules/pynacl/default.nix b/pkgs/development/python-modules/pynacl/default.nix
index 981427e46f3..865b8c02fef 100644
--- a/pkgs/development/python-modules/pynacl/default.nix
+++ b/pkgs/development/python-modules/pynacl/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPythonPackage, fetchFromGitHub, pytest, coverage, libsodium, cffi, six, hypothesis}:
+{ lib, buildPythonPackage, fetchFromGitHub, isPyPy, pytest, libsodium, cffi, six, hypothesis }:
 
 buildPythonPackage rec {
   pname = "pynacl";
@@ -11,17 +11,21 @@ buildPythonPackage rec {
     sha256 = "0z9i1z4hjzmp23igyhvg131gikbrr947506lwfb3fayf0agwfv8f";
   };
 
-  #set timeout to unlimited, remove deadline from tests, see https://github.com/pyca/pynacl/issues/370
+  # set timeout to unlimited, remove deadline from tests, see https://github.com/pyca/pynacl/issues/370
   patches = [ ./pynacl-no-timeout-and-deadline.patch ];
 
-  checkInputs = [ pytest coverage hypothesis ];
-  propagatedBuildInputs = [ libsodium cffi six ];
+  checkInputs = [ pytest hypothesis ];
+  propagatedBuildInputs = [ libsodium six ] ++ lib.optional (!isPyPy) cffi;
+
+  preBuild = ''
+    export SODIUM_INSTALL=system
+  '';
 
   checkPhase = ''
-    coverage run --source nacl --branch -m pytest
+    py.test
   '';
   
-  meta = with stdenv.lib; {
+  meta = with lib; {
     maintainers = with maintainers; [ va1entin ];
     description = "Python binding to the Networking and Cryptography (NaCl) library";
     homepage = https://github.com/pyca/pynacl/;

I can't actually test with PyPy because hypothesis depends on configparser, which isn't supported for PyPy. That must still be fixed somehow :)
But pynacl's setup.py clearly states it is compatible with PyPy 2.7.

Either you incorporate the changes into your PR @va1entin or @FRidh merges this one and I open a new one.

@va1entin
Copy link
Contributor Author

Thanks for the proposal @dotlambda 👍
If it's okay with you, I'd say you create a new one because it addresses things that are out of scope for this particular PR and I can't work on it until evening.

@va1entin
Copy link
Contributor Author

@GrahamcOfBorg build python3Packages.pynacl python2Packages.pynacl

Copy link
Member

@dotlambda dotlambda left a comment

Choose a reason for hiding this comment

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

@FRidh I'll create a PR for using system libsodium as soons as this is merged.

@dotlambda
Copy link
Member

@FRidh Is there any reason why this isn't merged yet?

@FRidh FRidh merged commit 158aac7 into NixOS:master Feb 18, 2018
@va1entin va1entin deleted the pynacl branch February 18, 2018 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants