summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/qscintilla/default.nix
blob: 28f7608e2998cb8f6e33c070f177eb49380f39b5 (plain)
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
{
  lib,
  stdenv,

  pythonPackages,
  qmake,
  qscintilla,
  qtbase,
  qtmacextras ? null,
}:

let
  qtVersion = lib.versions.major qtbase.version;
  pyQtPackage = pythonPackages."pyqt${qtVersion}";

  inherit (pythonPackages)
    isPy3k
    python
    sip
    pyqt-builder
    ;
in
pythonPackages.buildPythonPackage {
  pname = "qscintilla-qt${qtVersion}";
  version = qscintilla.version;
  src = qscintilla.src;
  pyproject = true;

  disabled = !isPy3k;

  nativeBuildInputs = [
    sip
    qmake
    pyqt-builder
    qscintilla
    pythonPackages.setuptools
  ];

  buildInputs = [ qtbase ];

  propagatedBuildInputs = [
    pyQtPackage
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [ qtmacextras ];

  dontWrapQtApps = true;

  postPatch = ''
    cd Python
    cp pyproject-qt${qtVersion}.toml pyproject.toml
    echo '[tool.sip.project]' >> pyproject.toml
    echo 'sip-include-dirs = [ "${pyQtPackage}/${python.sitePackages}/PyQt${qtVersion}/bindings"]' \
       >> pyproject.toml
  ''
  + lib.optionalString stdenv.hostPlatform.isDarwin ''
    substituteInPlace project.py \
      --replace \
      "if self.project.qsci_external_lib:
                if self.qsci_features_dir is not None:" \
      "if self.project.qsci_external_lib:
                self.builder_settings.append('QT += widgets')

                self.builder_settings.append('QT += printsupport')

                if self.qsci_features_dir is not None:"
  '';

  dontConfigure = true;

  build = ''
    sip-install --qsci-features-dir ${qscintilla}/mkspecs/features \
    --qsci-include-dir ${qscintilla}/include \
    --qsci-library-dir ${qscintilla}/lib --api-dir ${qscintilla}/share";
  '';
  postInstall = ''
    # Needed by pythonImportsCheck to find the module
    export PYTHONPATH="$out/${python.sitePackages}:$PYTHONPATH"
  '';

  # Checked using pythonImportsCheck
  doCheck = false;

  pythonImportsCheck = [ "PyQt${qtVersion}.Qsci" ];

  meta = {
    description = "Python binding to QScintilla, Qt based text editing control";
    license = lib.licenses.lgpl21Plus;
    homepage = "https://www.riverbankcomputing.com/software/qscintilla/";
  };
}