about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/wxPython/3.0.nix
blob: dc15c1c01bee06bfd0145a07c61f8ff330abed33 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
{ fetchurl
, lib
, stdenv
, darwin
, openglSupport ? true
, libX11
, wxGTK
, wxmac
, pkgconfig
, buildPythonPackage
, pyopengl
, isPy3k
, isPyPy
, python
, cairo
, pango
}:

assert wxGTK.unicode;

buildPythonPackage rec {
  pname = "wxPython";
  version = "3.0.2.0";

  disabled = isPy3k || isPyPy;
  doCheck = false;

  src = fetchurl {
    url = "mirror://sourceforge/wxpython/wxPython-src-${version}.tar.bz2";
    sha256 = "0qfzx3sqx4mwxv99sfybhsij4b5pc03ricl73h4vhkzazgjjjhfm";
  };

  dontUseSetuptoolsBuild = true;
  dontUsePipInstall = true;

  hardeningDisable = [ "format" ];

  nativeBuildInputs = [ pkgconfig ]
    ++ (lib.optionals (!stdenv.isDarwin) [ wxGTK libX11 ])
    ++ (lib.optionals stdenv.isDarwin [ wxmac ]);

  buildInputs = [ ]
    ++ (lib.optionals (!stdenv.isDarwin) [  (wxGTK.gtk) ])
    ++ (lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
      ApplicationServices
      AudioToolbox
      CFNetwork
      Carbon
      Cocoa
      CoreGraphics
      CoreServices
      CoreText
      DiskArbitration
      IOKit
      ImageIO
      OpenGL
      Security
    ]))
    ++ (lib.optional openglSupport pyopengl);

  preConfigure = ''
    cd wxPython
    # remove wxPython's darwin hack that interference with python-2.7-distutils-C++.patch
    substituteInPlace config.py \
      --replace "distutils.unixccompiler.UnixCCompiler = MyUnixCCompiler" ""
    # set the WXPREFIX to $out instead of the storepath of wxwidgets
    substituteInPlace config.py \
      --replace "WXPREFIX   = getWxConfigValue('--prefix')" "WXPREFIX   = '$out'"
    # this check is supposed to only return false on older systems running non-framework python
    substituteInPlace src/osx_cocoa/_core_wrap.cpp \
      --replace "return wxPyTestDisplayAvailable();" "return true;"
  '' + lib.optionalString (!stdenv.isDarwin) ''
    substituteInPlace wx/lib/wxcairo.py \
      --replace 'cairoLib = None' 'cairoLib = ctypes.CDLL("${cairo}/lib/libcairo.so")'
    substituteInPlace wx/lib/wxcairo.py \
      --replace '_dlls = dict()' '_dlls = {k: ctypes.CDLL(v) for k, v in [
        ("gdk",        "${wxGTK.gtk}/lib/libgtk-x11-2.0.so"),
        ("pangocairo", "${pango.out}/lib/libpangocairo-1.0.so"),
        ("appsvc",     None)
      ]}'
  '';

  buildPhase = "";

  installPhase = ''
    ${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
    wrapPythonPrograms
  '';

  passthru = { inherit wxGTK openglSupport; };
}