diff --git a/attrs.nix b/attrs.nix new file mode 100644 index 0000000000000000000000000000000000000000..96037464e5a0b3ee883e273b2c0380015100ae36 --- /dev/null +++ b/attrs.nix @@ -0,0 +1,30 @@ +{ lib, stdenv, buildPythonPackage, fetchPypi, pytest, hypothesis, zope_interface +, pympler, coverage, six, clang }: + +buildPythonPackage rec { + pname = "attrs"; + version = "19.2.0"; + + src = fetchPypi { + inherit pname version; + sha256 = "sha256:15hkbvwzw87474ra22mmzbbikkqkrnk9npifa1pw7lv32qp4j4zr"; + }; + + # macOS needs clang for testing + checkInputs = [ + pytest hypothesis zope_interface pympler coverage six + ] ++ lib.optionals (stdenv.isDarwin) [ clang ]; + + checkPhase = '' + py.test + ''; + + # To prevent infinite recursion with pytest + doCheck = false; + + meta = with lib; { + description = "Python attributes without boilerplate"; + homepage = https://github.com/hynek/attrs; + license = licenses.mit; + }; +} diff --git a/hypothesis.nix b/hypothesis.nix new file mode 100644 index 0000000000000000000000000000000000000000..32490967a437e31d670a6a25a7c2f2793d7c12f2 --- /dev/null +++ b/hypothesis.nix @@ -0,0 +1,40 @@ +{ lib, buildPythonPackage, fetchFromGitHub +, isPy3k, attrs, coverage, enum34 +, doCheck ? true, pytest, pytest_xdist, flaky, mock, pexpect +}: +buildPythonPackage rec { + # https://hypothesis.readthedocs.org/en/latest/packaging.html + + # Hypothesis has optional dependencies on the following libraries + # pytz fake_factory django numpy pytest + # If you need these, you can just add them to your environment. + + version = "4.38.3"; + pname = "hypothesis"; + + # Use github tarballs that includes tests + src = fetchFromGitHub { + owner = "HypothesisWorks"; + repo = "hypothesis-python"; + rev = "hypothesis-python-${version}"; + sha256 = "1w9mjc3bad8qgx3pygawvvwrbdrm4yix0ys4x6ry6hhln85xnpxx"; + }; + + postUnpack = "sourceRoot=$sourceRoot/hypothesis-python"; + + propagatedBuildInputs = [ attrs coverage ] ++ lib.optional (!isPy3k) [ enum34 ]; + + checkInputs = [ pytest pytest_xdist flaky mock pexpect ]; + inherit doCheck; + + checkPhase = '' + rm tox.ini # This file changes how py.test runs and breaks it + py.test tests/cover + ''; + + meta = with lib; { + description = "A Python library for property based testing"; + homepage = https://github.com/HypothesisWorks/hypothesis; + license = licenses.mpl20; + }; +} diff --git a/overlays.nix b/overlays.nix index a22a766007e627e2f9a6cf96153c77d0b82c2f58..17905cc72d4060155b2939711d88947f13d6735c 100644 --- a/overlays.nix +++ b/overlays.nix @@ -5,6 +5,21 @@ self: super: { python27 = super.python27.override { packageOverrides = python-self: python-super: { + # A newer version of Hypothesis is required for compatibility with the + # typing module which gets pulled in by some dependency or other. + # + # A bug report filed against nixpkgs - + # https://github.com/NixOS/nixpkgs/issues/70431 + hypothesis = python-super.callPackage ./hypothesis.nix { }; + + # The newer hypothesis requires a newer attrs. + attrs = python-super.callPackage ./attrs.nix { }; + + # The newer hypothesis or attrs breaks the pytest test suite. + pytest = python-super.pytest.overrideAttrs (old: { + doInstallCheck = false; + }); + # new tahoe-lafs dependency eliot = python-super.callPackage ./eliot.nix { }; # new autobahn requires a newer cryptography