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 name = pname + "-" + version;
25
26 disabled = isPy3k || isPyPy;
27 doCheck = false;
28
29 src = fetchurl {
30 url = "mirror://sourceforge/wxpython/wxPython-src-${version}.tar.bz2";
31 sha256 = "0qfzx3sqx4mwxv99sfybhsij4b5pc03ricl73h4vhkzazgjjjhfm";
32 };
33
34 hardeningDisable = [ "format" ];
35
36 propagatedBuildInputs = [ pkgconfig ]
37 ++ (lib.optional openglSupport pyopengl)
38 ++ (lib.optionals (!stdenv.isDarwin) [ wxGTK (wxGTK.gtk) libX11 ])
39 ++ (lib.optionals stdenv.isDarwin [ wxmac darwin.apple_sdk.frameworks.Cocoa ])
40 ;
41 preConfigure = ''
42 cd wxPython
43 # remove wxPython's darwin hack that interference with python-2.7-distutils-C++.patch
44 substituteInPlace config.py \
45 --replace "distutils.unixccompiler.UnixCCompiler = MyUnixCCompiler" ""
46 # set the WXPREFIX to $out instead of the storepath of wxwidgets
47 substituteInPlace config.py \
48 --replace "WXPREFIX = getWxConfigValue('--prefix')" "WXPREFIX = '$out'"
49 # this check is supposed to only return false on older systems running non-framework python
50 substituteInPlace src/osx_cocoa/_core_wrap.cpp \
51 --replace "return wxPyTestDisplayAvailable();" "return true;"
52 '' + lib.optionalString (!stdenv.isDarwin) ''
53 substituteInPlace wx/lib/wxcairo.py \
54 --replace 'cairoLib = None' 'cairoLib = ctypes.CDLL("${cairo}/lib/libcairo.so")'
55 substituteInPlace wx/lib/wxcairo.py \
56 --replace '_dlls = dict()' '_dlls = {k: ctypes.CDLL(v) for k, v in [
57 ("gdk", "${wxGTK.gtk}/lib/libgtk-x11-2.0.so"),
58 ("pangocairo", "${pango.out}/lib/libpangocairo-1.0.so"),
59 ("appsvc", None)
60 ]}'
61 '';
62
63 NIX_LDFLAGS = lib.optionalString (!stdenv.isDarwin) "-lX11 -lgdk-x11-2.0";
64
65 buildPhase = "";
66
67 installPhase = ''
68 ${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
69 wrapPythonPrograms
70 '';
71
72 passthru = { inherit wxGTK openglSupport; };
73}