nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix

sentencepiece: split into multiple outputs, optional gperftools

I am using sentencepiece in a downstream application where I want to
minimize the resulting closures. This commit makes changes to make
sentencepiece a leaner dependency:

- Split the outputs, so that the binaries/headers do not end up in the
transitive closure in a library dependency.

- Add the `withGPerfTools` option, which is enabled by default, to
make it possible to disable the gperftools dependency. According to
the sentencepiece README, this dependency gives a 10-40% performance
improvement. But in many cases this is overshadowed by the neural
networks that use piece identifiers as input anyway.

authored by danieldk.tngl.sh and committed by

Jon 27d0c5a0 24219f69

+11 -5
+6 -3
pkgs/development/libraries/sentencepiece/default.nix
··· 1 - { config 1 + { lib 2 2 , fetchFromGitHub 3 3 , stdenv 4 - , lib 5 4 , cmake 6 5 , gperftools 6 + 7 + , withGPerfTools ? true 7 8 }: 8 9 9 10 stdenv.mkDerivation rec { ··· 18 17 sha256 = "1ncvyw9ar0z7nd47cysxg5xrjm01y1shdlhp8l2pdpx059p3yx3w"; 19 18 }; 20 19 21 - nativeBuildInputs = [ cmake gperftools ]; 20 + nativeBuildInputs = [ cmake ] ++ lib.optional withGPerfTools gperftools; 21 + 22 + outputs = [ "bin" "dev" "out" ]; 22 23 23 24 meta = with stdenv.lib; { 24 25 homepage = "https://github.com/google/sentencepiece";
+5 -2
pkgs/development/python-modules/sentencepiece/default.nix
··· 6 6 7 7 buildPythonPackage rec { 8 8 pname = "sentencepiece"; 9 - inherit (sentencepiece) version src meta; 9 + inherit (sentencepiece) version src; 10 10 11 11 nativeBuildInputs = [ pkgconfig ]; 12 - buildInputs = [ sentencepiece ]; 12 + buildInputs = [ sentencepiece.dev ]; 13 13 14 14 sourceRoot = "source/python"; 15 + 16 + # sentencepiece installs 'bin' output. 17 + meta = builtins.removeAttrs sentencepiece.meta [ "outputsToInstall" ]; 15 18 }