Skip to content

Commit

Permalink
hooks: add hook for pymorphy3 (#634)
Browse files Browse the repository at this point in the history
  • Loading branch information
BLKSerene authored Aug 22, 2023
1 parent f0ff362 commit 284ea37
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/634.new.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add hook for ``pymorphy3``.
2 changes: 2 additions & 0 deletions requirements-test-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ eng-to-ipa==0.0.2
python-mecab-ko==1.3.3
khmer-nltk==1.5
python-crfsuite==0.9.9
pymorphy3==1.2.0
pymorphy3-dicts-uk==2.4.1.1.1663094765

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

Expand Down
25 changes: 25 additions & 0 deletions src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-pymorphy3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# ------------------------------------------------------------------
# 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, copy_metadata, collect_data_files

datas = copy_metadata('pymorphy3_dicts_ru')
datas += collect_data_files('pymorphy3_dicts_ru')

hiddenimports = ['pymorphy3_dicts_ru']

# Check if the Ukrainian model is installed
if can_import_module('pymorphy3_dicts_uk'):
datas += copy_metadata('pymorphy3_dicts_uk')
datas += collect_data_files('pymorphy3_dicts_uk')

hiddenimports += ['pymorphy3_dicts_uk']
10 changes: 10 additions & 0 deletions src/_pyinstaller_hooks_contrib/tests/test_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1803,3 +1803,13 @@ def test_pycrfsuite(pyi_builder):
pyi_builder.test_source("""
import pycrfsuite
""")


@importorskip('pymorphy3')
def test_pymorphy3(pyi_builder):
pyi_builder.test_source("""
import pymorphy3
pymorphy3.MorphAnalyzer(lang='ru')
pymorphy3.MorphAnalyzer(lang='uk')
""")

0 comments on commit 284ea37

Please sign in to comment.