Skip to content

Commit

Permalink
hooks: add hook for SudachiPy (#635)
Browse files Browse the repository at this point in the history
  • Loading branch information
BLKSerene authored Aug 22, 2023
1 parent 284ea37 commit d8aae14
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/635.new.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add hook for ``SudachiPy``.
4 changes: 4 additions & 0 deletions requirements-test-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ khmer-nltk==1.5
python-crfsuite==0.9.9
pymorphy3==1.2.0
pymorphy3-dicts-uk==2.4.1.1.1663094765
sudachipy==0.6.7
sudachidict-core==20230711
sudachidict-small==20230711
sudachidict-full==20230711

# ------------------- Platform (OS) specifics

Expand Down
23 changes: 23 additions & 0 deletions src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-sudachipy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# ------------------------------------------------------------------
# Copyright (c) 2023 PyInstaller Development Team.
#
# This file is distributed under the terms of the GNU General Public
# License (version 2.0 or later).
#
# The full license is available in LICENSE.GPL.txt, distributed with
# this software.
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ------------------------------------------------------------------

from PyInstaller.utils.hooks import can_import_module, collect_data_files

datas = collect_data_files('sudachipy')
hiddenimports = []

# Check which types of dictionary are installed
for sudachi_dict in ['sudachidict_small', 'sudachidict_core', 'sudachidict_full']:
if can_import_module(sudachi_dict):
datas += collect_data_files(sudachi_dict)

hiddenimports += [sudachi_dict]
11 changes: 11 additions & 0 deletions src/_pyinstaller_hooks_contrib/tests/test_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1813,3 +1813,14 @@ def test_pymorphy3(pyi_builder):
pymorphy3.MorphAnalyzer(lang='ru')
pymorphy3.MorphAnalyzer(lang='uk')
""")


@importorskip('sudachipy')
def test_sudachipy(pyi_builder):
pyi_builder.test_source("""
from sudachipy import Dictionary
Dictionary(dict_type='small').create()
Dictionary(dict_type='core').create()
Dictionary(dict_type='full').create()
""")

0 comments on commit d8aae14

Please sign in to comment.