aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/development/tools/sourcetrail/python.nix
blob: 113abb77d61b6757cf15792f607a85b756d0a1b3 (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
{ stdenv, lib, fetchFromGitHub, wrapPython, python, jedi, parso, cmake, swig }:

stdenv.mkDerivation rec {
  pname = "SourcetrailPythonIndexer";
  version = "v1_db25_p5";

  src = fetchFromGitHub {
    owner = "CoatiSoftware";
    repo = pname;
    rev = version;
    sha256 = "05hlpd3am029pv1wi6mys3q0ggp64axmg8bdf1fabl9cl9jffscq";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [ wrapPython cmake swig ];
  buildInputs = [ python ];
  pythonPath = [ jedi parso ];

  dontUseCmakeConfigure = true;
  cmakeFlags = [
    "-DBUILD_BINDINGS_PYTHON=1"
    "-DPYTHON_VERSION=${lib.versions.majorMinor python.version}"
  ];

  buildPhase = ''
    pushd SourcetrailDB
    cmake -Bbuild $cmakeFlags .
    pushd build
    make -j $NIX_BUILD_CORES
    popd
    popd
  '';

  checkPhase = ''
    buildPythonPath "$pythonPath"

    # FIXME: some tests are failing
    # PYTHONPATH="$program_PYTHONPATH:SourcetrailDB/build/bindings_python" \
    #   ${python}/bin/python test.py
    PYTHONPATH="$program_PYTHONPATH:SourcetrailDB/build/bindings_python" \
      ${python}/bin/python test_shallow.py
  '';

  installPhase = ''
    shopt -s extglob
    mkdir -p $out/{bin,libexec}

    cp !(run).py $out/libexec # copy *.py excluding run.py (needs extglob)
    cat <(echo '#!/usr/bin/env python') run.py > $out/libexec/run.py
    chmod +x $out/libexec/run.py
    ln -s $out/libexec/run.py $out/bin/SourcetrailPythonIndexer

    pushd SourcetrailDB/build/bindings_python
    cp sourcetraildb.py $out/libexec
    cp _sourcetraildb* $out/libexec/_sourcetraildb.so
    popd

    wrapPythonProgramsIn "$out/libexec" "$pythonPath"
  '';

  doCheck = true;

  meta = with lib; {
    description = "Python indexer for Sourcetrail";
    homepage = "https://github.com/CoatiSoftware/SourcetrailPythonIndexer";
    license = licenses.gpl3;
  };
}