24 buildPythonPackage rec {
29 disabled = pythonOlder "3.7";
31 src = fetchFromGitHub {
32 owner = "HypothesisWorks";
34 rev = "hypothesis-python-${version}";
35 hash = "sha256-KVi4BAgrswvhZxArYVnYQ6ksvCf84aSEZbJcRSlwsZE=";
38 # I tried to package sphinx-selective-exclude, but it throws
39 # error about "module 'sphinx' has no attribute 'directives'".
41 # It probably has to do with monkey-patching internals of Sphinx.
42 # On bright side, this extension does not introduces new commands,
43 # only changes "::only" command, so we probably okay with stock
46 # I wonder how upstream of "hypothesis" builds documentation.
48 sed -i -e '/sphinx_selective_exclude.eager_only/ d' docs/conf.py
51 postUnpack = "sourceRoot=$sourceRoot/hypothesis-python";
53 nativeBuildInputs = [ setuptools ];
55 propagatedBuildInputs = [
58 ] ++ lib.optionals (pythonOlder "3.11") [ exceptiongroup ];
64 ] ++ lib.optionals isPyPy [ tzdata ];
68 # This file changes how pytest runs and breaks it
73 pytestFlagsArray = [ "tests/cover" ];
77 # racy, fails to find a file sometimes
78 "test_recreate_charmap"
79 "test_uses_cached_charmap"
81 ++ lib.optionals (pythonOlder "3.10") [
82 # not sure why these tests fail with only 3.9
83 # FileNotFoundError: [Errno 2] No such file or directory: 'git'
85 "test_assume_has_status_reason"
86 "test_observability_captures_stateful_reprs"
89 pythonImportsCheck = [ "hypothesis" ];
92 doc = stdenv.mkDerivation {
93 # Forge look and feel of multi-output derivation as best as we can.
95 # Using 'outputs = [ "doc" ];' breaks a lot of assumptions.
96 name = "${pname}-${version}-doc";
97 inherit src pname version;
99 postInstallSphinx = ''
100 mv $out/share/doc/* $out/share/doc/python$pythonVersion-$pname-$version
103 nativeBuildInputs = [
110 inherit (python) pythonVersion;
116 description = "Library for property based testing";
117 mainProgram = "hypothesis";
118 homepage = "https://github.com/HypothesisWorks/hypothesis";
119 changelog = "https://hypothesis.readthedocs.io/en/latest/changes.html#v${
120 lib.replaceStrings [ "." ] [ "-" ] version
122 license = licenses.mpl20;