1{ fetchurl
2, lib
3, stdenv
4, darwin
5, openglSupport ? true
6, libX11
7, wxGTK
8, wxmac
9, pkgconfig
10, buildPythonPackage
11, pyopengl
12, isPy3k
13, isPyPy
14, python
15, cairo
16, pango
17}:
18
19assert wxGTK.unicode;
20
21buildPythonPackage rec {
22 pname = "wxPython";
23 version = "3.0.2.0";
24
25 disabled = isPy3k || isPyPy;
26 doCheck = false;
27
28 src = fetchurl {
29 url = "mirror://sourceforge/wxpython/wxPython-src-${version}.tar.bz2";
30 sha256 = "0qfzx3sqx4mwxv99sfybhsij4b5pc03ricl73h4vhkzazgjjjhfm";
31 };
32
33 dontUseSetuptoolsBuild = true;
34 dontUsePipInstall = true;
35
36 hardeningDisable = [ "format" ];
37
38 nativeBuildInputs = [ pkgconfig ]
39 ++ (lib.optionals (!stdenv.isDarwin) [ wxGTK libX11 ])
40 ++ (lib.optionals stdenv.isDarwin [ wxmac darwin.apple_sdk.frameworks.Cocoa ]);
41
42 buildInputs = [ ]
43 ++ (lib.optionals (!stdenv.isDarwin) [ (wxGTK.gtk) ])
44 ++ (lib.optional openglSupport pyopengl);
45
46 preConfigure = ''
47 cd wxPython
48 # remove wxPython's darwin hack that interference with python-2.7-distutils-C++.patch
49 substituteInPlace config.py \
50 --replace "distutils.unixccompiler.UnixCCompiler = MyUnixCCompiler" ""
51 # set the WXPREFIX to $out instead of the storepath of wxwidgets
52 substituteInPlace config.py \
53 --replace "WXPREFIX = getWxConfigValue('--prefix')" "WXPREFIX = '$out'"
54 # this check is supposed to only return false on older systems running non-framework python
55 substituteInPlace src/osx_cocoa/_core_wrap.cpp \
56 --replace "return wxPyTestDisplayAvailable();" "return true;"
57 '' + lib.optionalString (!stdenv.isDarwin) ''
58 substituteInPlace wx/lib/wxcairo.py \
59 --replace 'cairoLib = None' 'cairoLib = ctypes.CDLL("${cairo}/lib/libcairo.so")'
60 substituteInPlace wx/lib/wxcairo.py \
61 --replace '_dlls = dict()' '_dlls = {k: ctypes.CDLL(v) for k, v in [
62 ("gdk", "${wxGTK.gtk}/lib/libgtk-x11-2.0.so"),
63 ("pangocairo", "${pango.out}/lib/libpangocairo-1.0.so"),
64 ("appsvc", None)
65 ]}'
66 '';
67
68 buildPhase = "";
69
70 installPhase = ''
71 ${python.interpreter} setup.py install WXPORT=${if stdenv.isDarwin then "osx_cocoa" else "gtk2"} NO_HEADERS=0 BUILD_GLCANVAS=${if openglSupport then "1" else "0"} UNICODE=1 --prefix=$out
72 wrapPythonPrograms
73 '';
74
75 passthru = { inherit wxGTK openglSupport; };
76}