Skip to content

Commit

Permalink
Merge pull request #283178 from natsukium/sudachi-rs/update
Browse files Browse the repository at this point in the history
sudachi-rs: 0.6.7 -> 0.6.8; add updateScript
  • Loading branch information
natsukium authored Jan 25, 2024
2 parents d968b24 + 39d2a72 commit a89664f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 9 deletions.
27 changes: 19 additions & 8 deletions pkgs/by-name/su/sudachi-rs/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,49 @@
, sudachidict
, runCommand
, sudachi-rs
, writeScript
}:

rustPlatform.buildRustPackage rec {
pname = "sudachi-rs";
version = "0.6.7";
version = "0.6.8";

src = fetchFromGitHub {
owner = "WorksApplications";
repo = "sudachi.rs";
rev = "refs/tags/v${version}";
hash = "sha256-VzNOI6PP9sKBsNfB5yIxAI8jI8TEdM4tD49Jl/2tkSE=";
hash = "sha256-9GXU+YDPuQ+roqQfUE5q17Hl6AopsvGhRPjZ+Ui+n24=";
};

postPatch = ''
substituteInPlace sudachi/src/config.rs \
--replace '"resources"' '"${placeholder "out"}/share/resources"'
'';

cargoHash = "sha256-b2NtgHcMkimzFFuqohAo9KdSaIq6oi3qo/k8/VugyFs=";
cargoHash = "sha256-Ufo3dB2KGDDNiebp7hLhQrUMLsefO8wRpJQDz57Yb8Y=";

# prepare the resources before the build so that the binary can find sudachidict
preBuild = ''
install -Dm644 ${sudachidict}/share/system.dic resources/system.dic
install -Dm644 resources/* -t $out/share/resources
'';

passthru.tests = {
# detects an error that sudachidict is not found
cli = runCommand "${pname}-cli-test" { } ''
mkdir $out
echo "高輪ゲートウェイ駅" | ${lib.getExe sudachi-rs} > $out/result
passthru = {
updateScript = writeScript "update.sh" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p nix-update
set -eu -o pipefail
nix-update sudachi-rs
nix-update --version=skip python3Packages.sudachipy
'';
tests = {
# detects an error that sudachidict is not found
cli = runCommand "${pname}-cli-test" { } ''
mkdir $out
echo "高輪ゲートウェイ駅" | ${lib.getExe sudachi-rs} > $out/result
'';
};
};

meta = with lib; {
Expand Down
5 changes: 5 additions & 0 deletions pkgs/development/python-modules/sudachidict/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, fetchFromGitHub
, sudachidict
, setuptools
, sudachipy
}:

buildPythonPackage rec {
Expand Down Expand Up @@ -33,6 +34,10 @@ buildPythonPackage rec {
setuptools
];

propagatedBuildInputs = [
sudachipy
];

# we need to prepare some files before the build
# https://github.com/WorksApplications/SudachiDict/blob/develop/package_python.sh
preBuild = ''
Expand Down
20 changes: 19 additions & 1 deletion pkgs/development/python-modules/sudachipy/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
, pytestCheckHook
, sudachidict-core
, tokenizers
, sudachipy
}:

buildPythonPackage rec {
Expand All @@ -19,7 +20,7 @@ buildPythonPackage rec {
cargoDeps = rustPlatform.fetchCargoTarball {
inherit src;
name = "${pname}-${version}";
hash = "sha256-Am+ae2lgnndSDzf0GF8R1i6OPLdIlm2dLThqYqXbscA=";
hash = "sha256-ARwvThfATDdzBTjPFr9yjbE/0eYvp/TCZOEGbUupJmU=";
};

nativeBuildInputs = [
Expand All @@ -37,6 +38,9 @@ buildPythonPackage rec {
cd python
'';

# avoid infinite recursion due to sudachidict
doCheck = false;

nativeCheckInputs = [
pytestCheckHook
sudachidict-core
Expand All @@ -47,6 +51,20 @@ buildPythonPackage rec {
"sudachipy"
];

passthru = {
inherit (sudachi-rs) updateScript;
tests = {
pytest = sudachipy.overridePythonAttrs (
_: {
doCheck = true;
# avoid catchConflicts of sudachipy
# we don't need to install this package since it is just a test
dontInstall = true;
}
);
};
};

meta = sudachi-rs.meta // {
homepage = "https://github.com/WorksApplications/sudachi.rs/tree/develop/python";
mainProgram = "sudachipy";
Expand Down

0 comments on commit a89664f

Please sign in to comment.