shogun: refactor build

Main changes are:

- Build with default stdenv instead of forcing GCC 8, by applying upstream
patches that fix building with newer compilers.

Together with #134390 and #134393 (and the blas library fixes on #135493
and #136535), this enables building the derivation on darwin.

- Use multiple outputs.

- Move build-only inputs to nativeBuildInputs.

- Generate the meta examples but do not compile them (they are compiled as
part of the tests), to not make the build take more time than already is.

Install the example source files into $doc (but do not install the
example binaries, only the sources).

- Enable testing by setting the CMake variable CMAKE_SKIP_BUILD_RPATH to
false (it should not be needed if #108496 is merged). This allows the
tests to locate the shogun library and run without problems.

Disable integration and meta tests to speed up the build.

With a few other minor changes:

- Use upstream URL for the json-c patch.

- Be explicit about which optional, commercial dependencies are not used,
to stop CMake searching for them.

- Do not set NIX_CFLAGS_COMPILE with '-faligned-new' because it causes a
warning when compiling C files. Set CXXFLAGS instead.

- Remove unnecessary ccache variables from the environment.

- Fix wrong Google Mock download location, which was forcing CMake to need
network access to download the tarball to the right location (which fails
within the sandbox).

+46 -27
+45 -17
pkgs/applications/science/machine-learning/shogun/default.nix
··· 6 6 # build 7 7 , cmake 8 8 , ctags 9 + , pythonPackages 9 10 , swig 10 11 # math 11 12 , eigen ··· 30 31 , colpack 31 32 # extra support 32 33 , pythonSupport ? true 33 - , pythonPackages ? null 34 34 , opencvSupport ? false 35 35 , opencv ? null 36 36 , withSvmLight ? false ··· 56 56 sha256 = "05s9dclmk7x5d7wnnj4qr6r6c827m72a44gizcv09lxr28pr9inz"; 57 57 fetchSubmodules = true; 58 58 }; 59 - # we need the packed archive 59 + 60 + # The CMake external projects expect the packed archives 60 61 rxcpp = fetchurl { 61 62 url = "https://github.com/Reactive-Extensions/RxCpp/archive/v${rxcppVersion}.tar.gz"; 62 63 sha256 = "0y2isr8dy2n1yjr9c5570kpc9lvdlch6jv0jvw000amwn5d3krsh"; ··· 71 72 stdenv.mkDerivation rec { 72 73 inherit pname version; 73 74 75 + outputs = [ "out" "dev" "doc" ]; 76 + 74 77 src = srcs.toolbox; 75 78 76 79 patches = [ 80 + # Fix compile errors with json-c 81 + # https://github.com/shogun-toolbox/shogun/pull/4104 77 82 (fetchpatch { 78 - url = "https://github.com/awild82/shogun/commit/365ce4c4c700736d2eec8ba6c975327a5ac2cd9b.patch"; 83 + url = "https://github.com/shogun-toolbox/shogun/commit/365ce4c4c700736d2eec8ba6c975327a5ac2cd9b.patch"; 79 84 sha256 = "158hqv4xzw648pmjbwrhxjp7qcppqa7kvriif87gn3zdn711c49s"; 80 85 }) 86 + 87 + # Fix compile errors with GCC 9+ 88 + # https://github.com/shogun-toolbox/shogun/pull/4811 89 + (fetchpatch { 90 + url = "https://github.com/shogun-toolbox/shogun/commit/c8b670be4790e0f06804b048a6f3d77c17c3ee95.patch"; 91 + sha256 = "sha256-MxsR3Y2noFQevfqWK3nmX5iK4OVWeKBl5tfeDNgjcXk="; 92 + }) 93 + (fetchpatch { 94 + url = "https://github.com/shogun-toolbox/shogun/commit/5aceefd9fb0e2132c354b9a0c0ceb9160cc9b2f7.patch"; 95 + sha256 = "sha256-AgJJKQA8vc5oKaTQDqMdwBR4hT4sn9+uW0jLe7GteJw="; 96 + }) 97 + 81 98 ] ++ lib.optional (!withSvmLight) ./svmlight-scrubber.patch; 82 99 83 - nativeBuildInputs = [ cmake ]; 100 + nativeBuildInputs = [ cmake swig ctags ] 101 + ++ (with pythonPackages; [ python jinja2 ply ]); 84 102 85 103 buildInputs = [ 86 104 eigen ··· 100 118 nlopt 101 119 lp_solve 102 120 colpack 103 - ctags 104 - swig 105 - ] ++ lib.optionals pythonSupport (with pythonPackages; [ python ply numpy ]) 121 + ] ++ lib.optionals pythonSupport (with pythonPackages; [ python numpy ]) 106 122 ++ lib.optional opencvSupport opencv; 107 123 108 124 cmakeFlags = let 109 125 enableIf = cond: if cond then "ON" else "OFF"; 110 126 in [ 111 - "-DBUILD_META_EXAMPLES=${enableIf doCheck}" 112 - "-DCMAKE_VERBOSE_MAKEFILE=${enableIf doCheck}" 127 + "-DBUILD_META_EXAMPLES=ON" 128 + "-DCMAKE_DISABLE_FIND_PACKAGE_ARPACK=ON" 129 + "-DCMAKE_DISABLE_FIND_PACKAGE_ARPREC=ON" 130 + "-DCMAKE_DISABLE_FIND_PACKAGE_CPLEX=ON" 131 + "-DCMAKE_DISABLE_FIND_PACKAGE_Mosek=ON" 132 + "-DCMAKE_DISABLE_FIND_PACKAGE_TFLogger=ON" 133 + "-DCMAKE_DISABLE_FIND_PACKAGE_ViennaCL=ON" 134 + "-DCMAKE_SKIP_BUILD_RPATH=OFF" 135 + "-DCMAKE_CTEST_ARGUMENTS='--exclude-regex;TrainedModelSerialization'" # Sporadic segfault 113 136 "-DENABLE_TESTING=${enableIf doCheck}" 137 + "-DDISABLE_META_INTEGRATION_TESTS=ON" 138 + "-DTRAVIS_DISABLE_META_CPP=ON" 114 139 "-DPythonModular=${enableIf pythonSupport}" 115 140 "-DOpenCV=${enableIf opencvSupport}" 116 141 "-DUSE_SVMLIGHT=${enableIf withSvmLight}" 117 142 ]; 118 143 119 - CCACHE_DISABLE="1"; 120 - CCACHE_DIR=".ccache"; 144 + CXXFLAGS = "-faligned-new"; 121 145 122 - NIX_CFLAGS_COMPILE="-faligned-new"; 123 - 124 - # broken 125 - doCheck = false; 146 + doCheck = true; 126 147 127 148 postUnpack = '' 128 - mkdir -p $sourceRoot/third_party/{rxcpp,gtest} 149 + mkdir -p $sourceRoot/third_party/{rxcpp,GoogleMock} 129 150 ln -s ${srcs.rxcpp} $sourceRoot/third_party/rxcpp/v${rxcppVersion}.tar.gz 130 - ln -s ${srcs.gtest} $sourceRoot/third_party/gtest/release-${gtestVersion}.tar.gz 151 + ln -s ${srcs.gtest} $sourceRoot/third_party/GoogleMock/release-${gtestVersion}.tar.gz 131 152 ''; 132 153 133 154 postPatch = '' ··· 144 165 patchShebangs scripts/light-scrubber.sh 145 166 echo "removing SVMlight code" 146 167 ./scripts/light-scrubber.sh 168 + ''; 169 + 170 + postInstall = '' 171 + mkdir -p $doc/share/doc/shogun/examples 172 + mv $out/share/shogun/examples/cpp $doc/share/doc/shogun/examples 173 + cp ../examples/undocumented/libshogun/*.cpp $doc/share/doc/shogun/examples/cpp 174 + rm -r $out/share 147 175 ''; 148 176 149 177 meta = with lib; {
+1 -10
pkgs/top-level/all-packages.nix
··· 26918 26918 shotcut = libsForQt5.callPackage ../applications/video/shotcut { }; 26919 26919 26920 26920 shogun = callPackage ../applications/science/machine-learning/shogun { 26921 - stdenv = gcc8Stdenv; 26922 - 26923 - # Workaround for the glibc abi version mismatch. 26924 - # Please note that opencv builds are by default disabled. 26925 - opencv = opencv3.override { 26926 - stdenv = gcc8Stdenv; 26927 - openexr = openexr.override { 26928 - stdenv = gcc8Stdenv; 26929 - }; 26930 - }; 26921 + opencv = opencv3; 26931 26922 }; 26932 26923 26933 26924 smplayer = libsForQt5.callPackage ../applications/video/smplayer { };