1{ fetchurl 2, lib 3, stdenv 4, darwin 5, openglSupport ? true 6, libX11 7, wxGTK 8, wxmac 9, pkg-config 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 = [ pkg-config ] 39 ++ (lib.optionals (!stdenv.isDarwin) [ wxGTK libX11 ]) 40 ++ (lib.optionals stdenv.isDarwin [ wxmac ]); 41 42 buildInputs = [ ] 43 ++ (lib.optionals (!stdenv.isDarwin) [ (wxGTK.gtk) ]) 44 ++ (lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ 45 ApplicationServices 46 AudioToolbox 47 CFNetwork 48 Carbon 49 Cocoa 50 CoreGraphics 51 CoreServices 52 CoreText 53 DiskArbitration 54 IOKit 55 ImageIO 56 OpenGL 57 Security 58 ])) 59 ++ (lib.optional openglSupport pyopengl); 60 61 preConfigure = '' 62 cd wxPython 63 # remove wxPython's darwin hack that interference with python-2.7-distutils-C++.patch 64 substituteInPlace config.py \ 65 --replace "distutils.unixccompiler.UnixCCompiler = MyUnixCCompiler" "" 66 # set the WXPREFIX to $out instead of the storepath of wxwidgets 67 substituteInPlace config.py \ 68 --replace "WXPREFIX = getWxConfigValue('--prefix')" "WXPREFIX = '$out'" 69 # this check is supposed to only return false on older systems running non-framework python 70 substituteInPlace src/osx_cocoa/_core_wrap.cpp \ 71 --replace "return wxPyTestDisplayAvailable();" "return true;" 72 '' + lib.optionalString (!stdenv.isDarwin) '' 73 substituteInPlace wx/lib/wxcairo.py \ 74 --replace 'cairoLib = None' 'cairoLib = ctypes.CDLL("${cairo}/lib/libcairo.so")' 75 substituteInPlace wx/lib/wxcairo.py \ 76 --replace '_dlls = dict()' '_dlls = {k: ctypes.CDLL(v) for k, v in [ 77 ("gdk", "${wxGTK.gtk}/lib/libgtk-x11-2.0.so"), 78 ("pangocairo", "${pango.out}/lib/libpangocairo-1.0.so"), 79 ("appsvc", None) 80 ]}' 81 ''; 82 83 buildPhase = ""; 84 85 installPhase = '' 86 ${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 87 wrapPythonPrograms 88 ''; 89 90 passthru = { inherit wxGTK openglSupport; }; 91}