about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/science/machine-learning/shogun/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/applications/science/machine-learning/shogun/default.nix')
-rw-r--r--nixpkgs/pkgs/applications/science/machine-learning/shogun/default.nix22
1 files changed, 20 insertions, 2 deletions
diff --git a/nixpkgs/pkgs/applications/science/machine-learning/shogun/default.nix b/nixpkgs/pkgs/applications/science/machine-learning/shogun/default.nix
index 47b826078f24..a7010966c26d 100644
--- a/nixpkgs/pkgs/applications/science/machine-learning/shogun/default.nix
+++ b/nixpkgs/pkgs/applications/science/machine-learning/shogun/default.nix
@@ -8,6 +8,7 @@
 # extra support
 , pythonSupport ? true, pythonPackages ? null
 , opencvSupport ? false, opencv ? null
+, withSvmLight ? false
 }:
 
 assert pythonSupport -> pythonPackages != null;
@@ -60,7 +61,7 @@ stdenv.mkDerivation rec {
       url = "https://github.com/awild82/shogun/commit/365ce4c4c700736d2eec8ba6c975327a5ac2cd9b.patch";
       sha256 = "158hqv4xzw648pmjbwrhxjp7qcppqa7kvriif87gn3zdn711c49s";
     })
-  ];
+  ] ++ lib.optional (!withSvmLight) ./svmlight-scrubber.patch;
 
   CCACHE_DISABLE="1";
   CCACHE_DIR=".ccache";
@@ -86,12 +87,29 @@ stdenv.mkDerivation rec {
     (flag "CMAKE_VERBOSE_MAKEFILE:BOOL" doCheck)
     (flag "PythonModular" pythonSupport)
     (flag "OpenCV" opencvSupport)
+    (flag "USE_SVMLIGHT" withSvmLight)
   ];
 
+  postPatch = ''
+    # Fix preprocessing SVMlight code
+    sed -i \
+        -e 's@#ifdef SVMLIGHT@#ifdef USE_SVMLIGHT@' \
+        -e '/^#ifdef USE_SVMLIGHT/,/^#endif/ s@#endif@#endif //USE_SVMLIGHT@' \
+        src/shogun/kernel/string/CommUlongStringKernel.cpp
+    sed -i -e 's/#if USE_SVMLIGHT/#ifdef USE_SVMLIGHT/' src/interfaces/swig/Machine.i
+    sed -i -e 's@// USE_SVMLIGHT@//USE_SVMLIGHT@' src/interfaces/swig/Transfer.i
+    sed -i -e 's@/\* USE_SVMLIGHT \*/@//USE_SVMLIGHT@' src/interfaces/swig/Transfer_includes.i
+  '' + lib.optionalString (!withSvmLight) ''
+    # Run SVMlight scrubber
+    patchShebangs scripts/light-scrubber.sh
+    echo "removing SVMlight code"
+    ./scripts/light-scrubber.sh
+  '';
+
   meta = with lib; {
     description = "A toolbox which offers a wide range of efficient and unified machine learning methods";
     homepage = "http://shogun-toolbox.org/";
-    license = licenses.gpl3;
+    license = if withSvmLight then licenses.unfree else licenses.gpl3Plus;
     maintainers = with maintainers; [ edwtjo ];
   };
 }