Merge pull request #265689 from natsukium/sudachi/init
sudachi-rs: init at 0.6.7; python311Packages.sudachipy: init at 0.6.7; sudachidict: init at 20230927
This commit is contained in:
commit
6e7225fc50
49
pkgs/by-name/su/sudachi-rs/package.nix
Normal file
49
pkgs/by-name/su/sudachi-rs/package.nix
Normal file
@ -0,0 +1,49 @@
|
||||
{ lib
|
||||
, rustPlatform
|
||||
, fetchFromGitHub
|
||||
, sudachidict
|
||||
, runCommand
|
||||
, sudachi-rs
|
||||
}:
|
||||
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "sudachi-rs";
|
||||
version = "0.6.7";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "WorksApplications";
|
||||
repo = "sudachi.rs";
|
||||
rev = "refs/tags/v${version}";
|
||||
hash = "sha256-VzNOI6PP9sKBsNfB5yIxAI8jI8TEdM4tD49Jl/2tkSE=";
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace sudachi/src/config.rs \
|
||||
--replace '"resources"' '"${placeholder "out"}/share/resources"'
|
||||
'';
|
||||
|
||||
cargoHash = "sha256-b2NtgHcMkimzFFuqohAo9KdSaIq6oi3qo/k8/VugyFs=";
|
||||
|
||||
# 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
|
||||
'';
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
description = "A Japanese morphological analyzer";
|
||||
homepage = "https://github.com/WorksApplications/sudachi.rs";
|
||||
changelog = "https://github.com/WorksApplications/sudachi.rs/blob/${src.rev}/CHANGELOG.md";
|
||||
license = licenses.asl20;
|
||||
maintainers = with maintainers; [ natsukium ];
|
||||
mainProgram = "sudachi";
|
||||
};
|
||||
}
|
60
pkgs/by-name/su/sudachidict/package.nix
Normal file
60
pkgs/by-name/su/sudachidict/package.nix
Normal file
@ -0,0 +1,60 @@
|
||||
{ lib
|
||||
, stdenvNoCC
|
||||
, fetchzip
|
||||
, dict-type ? "core"
|
||||
}:
|
||||
|
||||
let
|
||||
pname = "sudachidict";
|
||||
version = "20230927";
|
||||
|
||||
srcs = {
|
||||
core = fetchzip {
|
||||
url = "https://github.com/WorksApplications/SudachiDict/releases/download/v${version}/sudachi-dictionary-${version}-core.zip";
|
||||
hash = "sha256-c88FfC03AU8eP37RVu9M3BAIlwFlTJqQJ60PK94mHOc=";
|
||||
};
|
||||
small = fetchzip {
|
||||
url = "https://github.com/WorksApplications/SudachiDict/releases/download/v${version}/sudachi-dictionary-${version}-small.zip";
|
||||
hash = "sha256-eaYD2C/qPeZJvmOeqH307a6OXtYfuksf6VZt+9kM7eM=";
|
||||
};
|
||||
full = fetchzip {
|
||||
url = "https://github.com/WorksApplications/SudachiDict/releases/download/v${version}/sudachi-dictionary-${version}-full.zip";
|
||||
hash = "sha256-yiO33UUQHcf6LvHJ1Is4MJtI5GSHuIP/tsE9m/KZ01o=";
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
lib.checkListOfEnum "${pname}: dict-type" [ "core" "full" "small" ] [ dict-type ]
|
||||
|
||||
stdenvNoCC.mkDerivation {
|
||||
inherit pname version;
|
||||
|
||||
src = srcs.${dict-type};
|
||||
|
||||
dontConfigure = true;
|
||||
|
||||
dontBuild = true;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dm644 system_${dict-type}.dic $out/share/system.dic
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
dict-type = dict-type;
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
description = "A lexicon for Sudachi";
|
||||
homepage = "https://github.com/WorksApplications/SudachiDict";
|
||||
changelog = "https://github.com/WorksApplications/SudachiDict/releases/tag/v${version}";
|
||||
license = licenses.asl20;
|
||||
maintainers = with maintainers; [ natsukium ];
|
||||
platforms = platforms.all;
|
||||
# it is a waste of space and time to build this package in hydra since it is just data
|
||||
hydraPlatforms = [];
|
||||
};
|
||||
}
|
42
pkgs/development/python-modules/sudachidict/default.nix
Normal file
42
pkgs/development/python-modules/sudachidict/default.nix
Normal file
@ -0,0 +1,42 @@
|
||||
{ buildPythonPackage
|
||||
, fetchFromGitHub
|
||||
, sudachidict
|
||||
, setuptools
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "sudachidict-${sudachidict.dict-type}";
|
||||
inherit (sudachidict) version meta;
|
||||
pyproject = true;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "WorksApplications";
|
||||
repo = "SudachiDict";
|
||||
rev = "refs/tags/v${version}";
|
||||
hash = "sha256-xJ/iPywOZA2kzHaVU43Bc8TUboj3OpDg1kLFMIc/T90=";
|
||||
};
|
||||
|
||||
sourceRoot = "source/python";
|
||||
|
||||
# setup script tries to get data from the network but we use the nixpkgs' one
|
||||
postPatch = ''
|
||||
substituteInPlace setup.py \
|
||||
--replace 'ZIP_NAME = urlparse(ZIP_URL).path.split("/")[-1]' "" \
|
||||
--replace "not os.path.exists(RESOURCE_DIR)" "False"
|
||||
substituteInPlace INFO.json \
|
||||
--replace "%%VERSION%%" ${version} \
|
||||
--replace "%%DICT_VERSION%%" ${version} \
|
||||
--replace "%%DICT_TYPE%%" ${sudachidict.dict-type}
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
setuptools
|
||||
];
|
||||
|
||||
# we need to prepare some files before the build
|
||||
# https://github.com/WorksApplications/SudachiDict/blob/develop/package_python.sh
|
||||
preBuild = ''
|
||||
install -Dm644 ${sudachidict}/share/system.dic -t sudachidict_${sudachidict.dict-type}/resources
|
||||
touch sudachidict_${sudachidict.dict-type}/__init__.py
|
||||
'';
|
||||
}
|
54
pkgs/development/python-modules/sudachipy/default.nix
Normal file
54
pkgs/development/python-modules/sudachipy/default.nix
Normal file
@ -0,0 +1,54 @@
|
||||
{ lib
|
||||
, stdenv
|
||||
, buildPythonPackage
|
||||
, cargo
|
||||
, libiconv
|
||||
, rustPlatform
|
||||
, rustc
|
||||
, sudachi-rs
|
||||
, setuptools-rust
|
||||
, pytestCheckHook
|
||||
, sudachidict-core
|
||||
, tokenizers
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "sudachipy";
|
||||
inherit (sudachi-rs) src version;
|
||||
|
||||
cargoDeps = rustPlatform.fetchCargoTarball {
|
||||
inherit src;
|
||||
name = "${pname}-${version}";
|
||||
hash = "sha256-Am+ae2lgnndSDzf0GF8R1i6OPLdIlm2dLThqYqXbscA=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
cargo
|
||||
rustPlatform.cargoSetupHook
|
||||
rustc
|
||||
setuptools-rust
|
||||
];
|
||||
|
||||
buildInputs = lib.optionals stdenv.isDarwin [
|
||||
libiconv
|
||||
];
|
||||
|
||||
preBuild = ''
|
||||
cd python
|
||||
'';
|
||||
|
||||
nativeCheckInputs = [
|
||||
pytestCheckHook
|
||||
sudachidict-core
|
||||
tokenizers
|
||||
];
|
||||
|
||||
pythonImportsCheck = [
|
||||
"sudachipy"
|
||||
];
|
||||
|
||||
meta = sudachi-rs.meta // {
|
||||
homepage = "https://github.com/WorksApplications/sudachi.rs/tree/develop/python";
|
||||
mainProgram = "sudachipy";
|
||||
};
|
||||
}
|
@ -13810,6 +13810,18 @@ self: super: with self; {
|
||||
|
||||
succulent = callPackage ../development/python-modules/succulent { };
|
||||
|
||||
sudachidict-core = callPackage ../development/python-modules/sudachidict { };
|
||||
|
||||
sudachidict-full = callPackage ../development/python-modules/sudachidict {
|
||||
sudachidict = pkgs.sudachidict.override { dict-type = "full"; };
|
||||
};
|
||||
|
||||
sudachidict-small = callPackage ../development/python-modules/sudachidict {
|
||||
sudachidict = pkgs.sudachidict.override { dict-type = "small"; };
|
||||
};
|
||||
|
||||
sudachipy = callPackage ../development/python-modules/sudachipy { };
|
||||
|
||||
sumo = callPackage ../development/python-modules/sumo { };
|
||||
|
||||
sumtypes = callPackage ../development/python-modules/sumtypes { };
|
||||
|
Loading…
Reference in New Issue
Block a user