Skip to content

Commit

Permalink
hooks: add hook for Lingua (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
BLKSerene authored Aug 19, 2023
1 parent 3cbfec0 commit d0af799
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/626.new.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add hook for ``Lingua``.
1 change: 1 addition & 0 deletions requirements-test-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ pydantic==2.1.1
jsonschema==4.19.0
psutil==5.9.5
litestar==2.0.0rc1
lingua-language-detector==1.3.2; python_version >= '3.8'

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

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

datas = collect_data_files('lingua')
12 changes: 12 additions & 0 deletions src/_pyinstaller_hooks_contrib/tests/test_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1723,3 +1723,15 @@ def sync_hello_world() -> Dict[str, Any]:
assert response.status_code == 200
assert response.json() == {"hello": "world"}
""")


@importorskip('lingua')
def test_lingua_language_detector(pyi_builder):
pyi_builder.test_source("""
from lingua import Language, LanguageDetectorBuilder
languages = [Language.ENGLISH, Language.FRENCH, Language.GERMAN, Language.SPANISH]
detector = LanguageDetectorBuilder.from_languages(*languages).build()
assert detector.detect_language_of("languages are awesome") == Language.ENGLISH
""")

0 comments on commit d0af799

Please sign in to comment.