source: trunk/nix/python-overrides.nix

Last change on this file was b37d602, checked in by Benoit Donneaux <benoit@…>, at 2024-12-05T11:06:07Z

Use nixpkgs-provided txi2p-tahoe

  • Property mode set to 100644
File size: 4.8 KB
Line 
1# Override various Python packages to create a package set that works for
2# Tahoe-LAFS on CPython and PyPy.
3self: super:
4let
5
6  # Run a function on a derivation if and only if we're building for PyPy.
7  onPyPy = f: drv: if super.isPyPy then f drv else drv;
8
9  # Disable a Python package's test suite.
10  dontCheck = drv: drv.overrideAttrs (old: { doInstallCheck = false; });
11
12  # string -> any -> derivation -> derivation
13  #
14  # If the overrideable function for the given derivation accepts an argument
15  # with the given name, override it with the given value.
16  #
17  # Since we try to work with multiple versions of nixpkgs, sometimes we need
18  # to override a parameter that exists in one version but not others.  This
19  # makes it a bit easier to do so.
20  overrideIfPresent = name: value: drv:
21    if (drv.override.__functionArgs ? ${name})
22    then drv.override { "${name}" = value; }
23    else drv;
24
25  # Disable building a Python package's documentation.
26  dontBuildDocs = drv: (
27    overrideIfPresent "sphinxHook" null (
28      overrideIfPresent "sphinx-rtd-theme" null
29        drv
30    )
31  ).overrideAttrs ({ outputs, ... }: {
32    outputs = builtins.filter (x: "doc" != x) outputs;
33  });
34
35in {
36  tahoe-lafs = self.callPackage ./tahoe-lafs.nix {
37    # Define the location of the Tahoe-LAFS source to be packaged (the same
38    # directory as contains this file).  Clean up as many of the non-source
39    # files (eg the `.git` directory, `~` backup files, nix's own `result`
40    # symlink, etc) as possible to avoid needing to re-build when files that
41    # make no difference to the package have changed.
42    tahoe-lafs-src = self.lib.cleanSource ../.;
43  };
44
45  # collections-extended is currently broken for Python 3.11 in nixpkgs but
46  # we know where a working version lives.
47  collections-extended = self.callPackage ./collections-extended.nix {
48    # Avoid infinite recursion.
49    inherit (super) collections-extended;
50  };
51
52  # greenlet is incompatible with PyPy but PyPy has a builtin equivalent.
53  # Fixed in nixpkgs in a5f8184fb816a4fd5ae87136838c9981e0d22c67.
54  greenlet = onPyPy (drv: null) super.greenlet;
55
56  # tornado and tk pull in a huge dependency trees for functionality we don't
57  # care about, also tkinter doesn't work on PyPy.
58  matplotlib = onPyPy (matplotlib: matplotlib.override {
59    tornado = null;
60    enableTk = false;
61  }) super.matplotlib;
62
63  tqdm = onPyPy (tqdm: tqdm.override {
64    # ibid.
65    tkinter = null;
66    # pandas is only required by the part of the test suite covering
67    # integration with pandas that we don't care about.  pandas is a huge
68    # dependency.
69    pandas = null;
70  }) super.tqdm;
71
72  # The treq test suite depends on httpbin.  httpbin pulls in babel (flask ->
73  # jinja2 -> babel) and arrow (brotlipy -> construct -> arrow).  babel fails
74  # its test suite and arrow segfaults.
75  treq = onPyPy dontCheck super.treq;
76
77  # the six test suite fails on PyPy because it depends on dbm which the
78  # nixpkgs PyPy build appears to be missing.  Maybe fixed in nixpkgs in
79  # a5f8184fb816a4fd5ae87136838c9981e0d22c67.
80  six = onPyPy dontCheck super.six;
81
82  # Likewise for beautifulsoup4.
83  beautifulsoup4 = onPyPy dontBuildDocs super.beautifulsoup4;
84
85  # The autobahn test suite pulls in a vast number of dependencies for
86  # functionality we don't care about.  It might be nice to *selectively*
87  # disable just some of it but this is easier.
88  autobahn = dontCheck super.autobahn;
89
90  # and python-dotenv tests pulls in a lot of dependencies, including jedi,
91  # which does not work on PyPy.
92  python-dotenv = onPyPy dontCheck super.python-dotenv;
93
94  # By default, the sphinx docs are built, which pulls in a lot of
95  # dependencies - including jedi, which does not work on PyPy.
96  hypothesis = onPyPy dontBuildDocs super.hypothesis;
97
98  # flaky's test suite depends on nose and nose appears to have Python 3
99  # incompatibilities (it includes `print` statements, for example).
100  flaky = onPyPy dontCheck super.flaky;
101
102  # collections-extended is packaged with poetry-core.  poetry-core test suite
103  # uses virtualenv and virtualenv test suite fails on PyPy.
104  poetry-core = onPyPy dontCheck super.poetry-core;
105
106  # The test suite fails with some rather irrelevant (to us) string comparison
107  # failure on PyPy.  Probably a PyPy bug but doesn't seem like we should
108  # care.
109  rich = onPyPy dontCheck super.rich;
110
111  # The pyutil test suite fails in some ... test ... for some deprecation
112  # functionality we don't care about.
113  pyutil = onPyPy dontCheck super.pyutil;
114
115  # testCall1 fails fairly inscrutibly on PyPy.  Perhaps someone can fix that,
116  # or we could at least just skip that one test.  Probably better to fix it
117  # since we actually depend directly and significantly on Foolscap.
118  foolscap = onPyPy dontCheck super.foolscap;
119
120  # CircleCI build systems don't have enough memory to run this test suite.
121  lz4 = onPyPy dontCheck super.lz4;
122}
Note: See TracBrowser for help on using the repository browser.