1 | # Override various Python packages to create a package set that works for |
---|
2 | # Tahoe-LAFS on CPython and PyPy. |
---|
3 | self: super: |
---|
4 | let |
---|
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 | |
---|
35 | in { |
---|
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 | # Some dependencies aren't packaged in nixpkgs so supply our own packages. |
---|
46 | pycddl = self.callPackage ./pycddl.nix { }; |
---|
47 | txi2p = self.callPackage ./txi2p.nix { }; |
---|
48 | |
---|
49 | # Some packages are of somewhat too-old versions - update them. |
---|
50 | klein = self.callPackage ./klein.nix { |
---|
51 | # Avoid infinite recursion. |
---|
52 | inherit (super) klein; |
---|
53 | }; |
---|
54 | txtorcon = self.callPackage ./txtorcon.nix { |
---|
55 | inherit (super) txtorcon; |
---|
56 | }; |
---|
57 | |
---|
58 | # With our customized package set a Twisted unit test fails. Patch the |
---|
59 | # Twisted test suite to skip that test. |
---|
60 | # Filed upstream at https://github.com/twisted/twisted/issues/11877 |
---|
61 | twisted = super.twisted.overrideAttrs (old: { |
---|
62 | patches = (old.patches or []) ++ [ ./twisted.patch ]; |
---|
63 | }); |
---|
64 | |
---|
65 | # Update the version of pyopenssl - and since we're doing that anyway, we |
---|
66 | # don't need the docs. Unfortunately this triggers a lot of rebuilding of |
---|
67 | # dependent packages. |
---|
68 | pyopenssl = dontBuildDocs (self.callPackage ./pyopenssl.nix { |
---|
69 | inherit (super) pyopenssl; |
---|
70 | }); |
---|
71 | |
---|
72 | # The cryptography that we get from nixpkgs to satisfy the pyopenssl upgrade |
---|
73 | # that we did breaks service-identity ... so get a newer version that works. |
---|
74 | service-identity = self.callPackage ./service-identity.nix { }; |
---|
75 | |
---|
76 | # collections-extended is currently broken for Python 3.11 in nixpkgs but |
---|
77 | # we know where a working version lives. |
---|
78 | collections-extended = self.callPackage ./collections-extended.nix { |
---|
79 | inherit (super) collections-extended; |
---|
80 | }; |
---|
81 | |
---|
82 | # greenlet is incompatible with PyPy but PyPy has a builtin equivalent. |
---|
83 | # Fixed in nixpkgs in a5f8184fb816a4fd5ae87136838c9981e0d22c67. |
---|
84 | greenlet = onPyPy (drv: null) super.greenlet; |
---|
85 | |
---|
86 | # tornado and tk pull in a huge dependency trees for functionality we don't |
---|
87 | # care about, also tkinter doesn't work on PyPy. |
---|
88 | matplotlib = onPyPy (matplotlib: matplotlib.override { |
---|
89 | tornado = null; |
---|
90 | enableTk = false; |
---|
91 | }) super.matplotlib; |
---|
92 | |
---|
93 | tqdm = onPyPy (tqdm: tqdm.override { |
---|
94 | # ibid. |
---|
95 | tkinter = null; |
---|
96 | # pandas is only required by the part of the test suite covering |
---|
97 | # integration with pandas that we don't care about. pandas is a huge |
---|
98 | # dependency. |
---|
99 | pandas = null; |
---|
100 | }) super.tqdm; |
---|
101 | |
---|
102 | # The treq test suite depends on httpbin. httpbin pulls in babel (flask -> |
---|
103 | # jinja2 -> babel) and arrow (brotlipy -> construct -> arrow). babel fails |
---|
104 | # its test suite and arrow segfaults. |
---|
105 | treq = onPyPy dontCheck super.treq; |
---|
106 | |
---|
107 | # the six test suite fails on PyPy because it depends on dbm which the |
---|
108 | # nixpkgs PyPy build appears to be missing. Maybe fixed in nixpkgs in |
---|
109 | # a5f8184fb816a4fd5ae87136838c9981e0d22c67. |
---|
110 | six = onPyPy dontCheck super.six; |
---|
111 | |
---|
112 | # Likewise for beautifulsoup4. |
---|
113 | beautifulsoup4 = onPyPy dontBuildDocs super.beautifulsoup4; |
---|
114 | |
---|
115 | # The autobahn test suite pulls in a vast number of dependencies for |
---|
116 | # functionality we don't care about. It might be nice to *selectively* |
---|
117 | # disable just some of it but this is easier. |
---|
118 | autobahn = dontCheck super.autobahn; |
---|
119 | |
---|
120 | # and python-dotenv tests pulls in a lot of dependencies, including jedi, |
---|
121 | # which does not work on PyPy. |
---|
122 | python-dotenv = onPyPy dontCheck super.python-dotenv; |
---|
123 | |
---|
124 | # By default, the sphinx docs are built, which pulls in a lot of |
---|
125 | # dependencies - including jedi, which does not work on PyPy. |
---|
126 | hypothesis = onPyPy dontBuildDocs super.hypothesis; |
---|
127 | |
---|
128 | # flaky's test suite depends on nose and nose appears to have Python 3 |
---|
129 | # incompatibilities (it includes `print` statements, for example). |
---|
130 | flaky = onPyPy dontCheck super.flaky; |
---|
131 | |
---|
132 | # collections-extended is packaged with poetry-core. poetry-core test suite |
---|
133 | # uses virtualenv and virtualenv test suite fails on PyPy. |
---|
134 | poetry-core = onPyPy dontCheck super.poetry-core; |
---|
135 | |
---|
136 | # The test suite fails with some rather irrelevant (to us) string comparison |
---|
137 | # failure on PyPy. Probably a PyPy bug but doesn't seem like we should |
---|
138 | # care. |
---|
139 | rich = onPyPy dontCheck super.rich; |
---|
140 | |
---|
141 | # The pyutil test suite fails in some ... test ... for some deprecation |
---|
142 | # functionality we don't care about. |
---|
143 | pyutil = onPyPy dontCheck super.pyutil; |
---|
144 | |
---|
145 | # testCall1 fails fairly inscrutibly on PyPy. Perhaps someone can fix that, |
---|
146 | # or we could at least just skip that one test. Probably better to fix it |
---|
147 | # since we actually depend directly and significantly on Foolscap. |
---|
148 | foolscap = onPyPy dontCheck super.foolscap; |
---|
149 | |
---|
150 | # CircleCI build systems don't have enough memory to run this test suite. |
---|
151 | lz4 = onPyPy dontCheck super.lz4; |
---|
152 | } |
---|