nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 unittestCheckHook,
6 rustPlatform,
7 fetchFromGitHub,
8 rustc,
9 cargo,
10 libiconv,
11 setuptools,
12 setuptools-rust,
13}:
14
15buildPythonPackage rec {
16 pname = "nlpo3";
17 version = "1.4.0";
18 pyproject = true;
19
20 src = fetchFromGitHub {
21 owner = "PyThaiNLP";
22 repo = "nlpo3";
23 tag = "nlpo3-python-v${version}";
24 hash = "sha256-GQwUKc6VXF1mDzvB2HBwHlaC0Eu3sZvlTuGe0CDrP4k=";
25 };
26
27 postPatch = ''
28 substituteInPlace tests/test_tokenize.py \
29 --replace-fail "data/test_dict.txt" "$src/nlpo3-python/tests/data/test_dict.txt"
30 '';
31
32 sourceRoot = "${src.name}/nlpo3-python";
33
34 cargoDeps = rustPlatform.fetchCargoVendor {
35 inherit src sourceRoot;
36 hash = "sha256-Kp2FL6GXb5g5jqvFWZxZUy7OuGaavN9DZkp9kdI4d/4=";
37 };
38
39 preCheck = ''
40 rm -r nlpo3
41 '';
42
43 nativeBuildInputs = [
44 rustPlatform.cargoSetupHook
45 rustc
46 cargo
47 ];
48
49 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ];
50
51 build-system = [
52 setuptools
53 setuptools-rust
54 ];
55
56 nativeCheckInputs = [ unittestCheckHook ];
57
58 unittestFlagsArray = [
59 "-s"
60 "tests"
61 "-v"
62 ];
63
64 pythonImportsCheck = [ "nlpo3" ];
65
66 meta = {
67 description = "Thai Natural Language Processing library in Rust, with Python and Node bindings";
68 homepage = "https://github.com/PyThaiNLP/nlpo3";
69 changelog = "https://github.com/PyThaiNLP/nlpo3/releases/tag/${src.tag}";
70 license = lib.licenses.asl20;
71 maintainers = with lib.maintainers; [ vizid ];
72 };
73}