nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 setuptools,
6 fetchPypi,
7 fetchpatch,
8 replaceVars,
9
10 # build
11 autoPatchelfHook,
12 attrdict,
13 cython,
14 doxygen,
15 pkg-config,
16 python,
17 requests,
18 sip,
19 which,
20 buildPackages,
21
22 # runtime
23 cairo,
24 gst_all_1,
25 gtk3,
26 libGL,
27 libGLU,
28 libSM,
29 libXinerama,
30 libXtst,
31 libXxf86vm,
32 libglvnd,
33 libgbm,
34 pango,
35 webkitgtk_4_1,
36 wxGTK,
37 xorgproto,
38
39 # propagates
40 numpy,
41 pillow,
42 six,
43
44 # checks
45 py,
46 pytest,
47 pytest-forked,
48 xvfb-run,
49}:
50
51buildPythonPackage rec {
52 pname = "wxpython";
53 version = "4.2.4";
54 pyproject = false;
55
56 src = fetchPypi {
57 inherit pname version;
58 hash = "sha256-LrEjl5yHvLMp6KJFImnWD/j59lHpvyXGdXnlPE67rjw=";
59 };
60
61 patches = [
62 (replaceVars ./4.2-ctypes.patch {
63 libgdk = "${lib.getLib gtk3}/lib/libgdk-3${stdenv.hostPlatform.extensions.sharedLibrary}";
64 libpangocairo = "${lib.getLib pango}/lib/libpangocairo-1.0${stdenv.hostPlatform.extensions.sharedLibrary}";
65 libcairo = "${lib.getLib cairo}/lib/libcairo${stdenv.hostPlatform.extensions.sharedLibrary}";
66 })
67 ./0001-add-missing-bool-c.patch # Add missing bool.c from old source
68 # TODO: drop when updating beyond version 4.2.4
69 # https://github.com/wxWidgets/Phoenix/pull/2822
70 (fetchpatch {
71 name = "Fix-wx.svg-to-work-with-cython-3.1-generated-code.patch";
72 url = "https://github.com/wxWidgets/Phoenix/commit/31303649ab0a0fed0789e0951a7487d172b65bfa.patch";
73 hash = "sha256-OAnAsyqHGPNEAiOxLLpdEGcd92K7TCxqEBYceuIb8so=";
74 })
75 ];
76
77 # https://github.com/wxWidgets/Phoenix/issues/2575
78 postPatch = ''
79 ln -s ${lib.getExe buildPackages.waf} bin/waf
80 substituteInPlace build.py \
81 --replace-fail "distutils.dep_util" "setuptools.modified" \
82 --replace-fail "runcmd(cmd, fatal=False)" "runcmd(cmd, fatal=True)" # fail when pytest reports errors
83 '';
84
85 nativeBuildInputs = [
86 attrdict
87 cython
88 pkg-config
89 requests
90 setuptools
91 sip
92 which
93 wxGTK
94 ]
95 ++ lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ];
96
97 buildInputs = [
98 wxGTK
99 ]
100 ++ lib.optionals stdenv.hostPlatform.isLinux [
101 gst_all_1.gst-plugins-base
102 gst_all_1.gstreamer
103 libGL
104 libGLU
105 libSM
106 libXinerama
107 libXtst
108 libXxf86vm
109 libglvnd
110 libgbm
111 webkitgtk_4_1
112 xorgproto
113 ];
114
115 propagatedBuildInputs = [
116 numpy
117 pillow
118 six
119 ];
120
121 nativeCheckInputs = [
122 py # py must be ordered before pytest (see https://github.com/pytest-dev/pytest-forked/issues/88)
123 pytest
124 pytest-forked
125 xvfb-run
126 ];
127
128 wafPath = "bin/waf";
129
130 buildPhase = ''
131 runHook preBuild
132
133 export DOXYGEN=${doxygen}/bin/doxygen
134 export PATH="${wxGTK}/bin:$PATH"
135
136 ${python.pythonOnBuildForHost.interpreter} build.py -v --use_syswx dox etg sip --nodoc build_py
137
138 runHook postBuild
139 '';
140
141 installPhase = ''
142 runHook preInstall
143
144 ${python.pythonOnBuildForHost.interpreter} setup.py install --skip-build --prefix=$out
145 wrapPythonPrograms
146
147 runHook postInstall
148 '';
149
150 # The majority of the tests require a graphical environment, but xvfb-run is available only on Linux.
151 # Tests fail randomly on OfBorg and Hydra.
152 doCheck = false;
153
154 checkPhase =
155 let
156 # Some tests appear to be incompatible with xvfb-run.
157 skippedTests = [
158 "dirdlg"
159 "display"
160 "filectrl"
161 "filedlg"
162 "filedlgcustomize"
163 "frame"
164 "glcanvas"
165 "pickers"
166 "windowid"
167 ];
168 testArguments = lib.concatMapStringsSep " " (
169 test: "--ignore unittests/test_${test}.py"
170 ) skippedTests;
171 in
172 ''
173 runHook preCheck
174
175 HOME=$(mktemp -d) xvfb-run ${python.interpreter} build.py -v --extra_pytest='${testArguments}' test
176
177 runHook postCheck
178 '';
179
180 meta = {
181 changelog = "https://github.com/wxWidgets/Phoenix/blob/wxPython-${version}/CHANGES.rst";
182 description = "Cross platform GUI toolkit for Python, Phoenix version";
183 homepage = "http://wxpython.org/";
184 license = with lib.licenses; [
185 lgpl2Plus
186 wxWindowsException31
187 ];
188 };
189}