mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2026-02-07 11:33:38 -05:00
Otherwise face `KeyError: 'default_dependencies'` in `stanza`: ``` libretranslate ``` <details> <summary>Output:</summary> ``` /home/benjamin_loison/venv/lib/python3.13/site-packages/apscheduler/__init__.py:1: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81. from pkg_resources import get_distribution, DistributionNotFound Running on http://127.0.0.1:5000 WARNING:waitress.queue:Task queue depth is 1 WARNING:waitress.queue:Task queue depth is 2 WARNING:waitress.queue:Task queue depth is 2 WARNING:waitress.queue:Task queue depth is 2 WARNING:waitress.queue:Task queue depth is 2 ERROR:libretranslate.app:Exception on /translate [POST] Traceback (most recent call last): File "/home/benjamin_loison/venv/lib/python3.13/site-packages/flask/app.py", line 2529, in wsgi_app response = self.full_dispatch_request() File "/home/benjamin_loison/venv/lib/python3.13/site-packages/flask/app.py", line 1825, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/benjamin_loison/venv/lib/python3.13/site-packages/flask/app.py", line 1823, in full_dispatch_request rv = self.dispatch_request() File "/home/benjamin_loison/venv/lib/python3.13/site-packages/flask/app.py", line 1799, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^ File "/home/benjamin_loison/venv/lib/python3.13/site-packages/libretranslate/app.py", line 404, in time_func return func(*a, **kw) File "/home/benjamin_loison/venv/lib/python3.13/site-packages/libretranslate/app.py", line 378, in func return f(*a, **kw) File "/home/benjamin_loison/venv/lib/python3.13/site-packages/libretranslate/app.py", line 831, in translate raise e File "/home/benjamin_loison/venv/lib/python3.13/site-packages/libretranslate/app.py", line 815, in translate hypotheses = translator.hypotheses(q, num_alternatives + 1) File "/home/benjamin_loison/venv/lib/python3.13/site-packages/argostranslate/translate.py", line 296, in hypotheses translated_paragraph = self.underlying.hypotheses( paragraph, num_hypotheses ) File "/home/benjamin_loison/venv/lib/python3.13/site-packages/argostranslate/translate.py", line 173, in hypotheses apply_packaged_translation( ~~~~~~~~~~~~~~~~~~~~~~~~~~^ self.pkg, paragraph, self.translator, num_hypotheses ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "/home/benjamin_loison/venv/lib/python3.13/site-packages/argostranslate/translate.py", line 418, in apply_packaged_translation stanza_pipeline = stanza.Pipeline( lang=pkg.from_code, ...<3 lines>... logging_level="WARNING", ) File "/home/benjamin_loison/venv/lib/python3.13/site-packages/stanza/pipeline/core.py", line 83, in __init__ self.load_list = add_dependencies(resources, lang, self.load_list) if lang in resources else [] ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/benjamin_loison/venv/lib/python3.13/site-packages/stanza/resources/common.py", line 213, in add_dependencies default_dependencies = resources[lang]['default_dependencies'] ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^ KeyError: 'default_dependencies' ``` </details>
145 lines
3.5 KiB
TOML
145 lines
3.5 KiB
TOML
[build-system]
|
|
requires = ["hatchling"]
|
|
build-backend = "hatchling.build"
|
|
|
|
[project]
|
|
requires-python = ">=3.8"
|
|
name = "libretranslate"
|
|
description = "Free and Open Source Machine Translation API. Self-hosted, no limits, no ties to proprietary services."
|
|
readme = "README.md"
|
|
license = { file = "LICENSE" }
|
|
authors = [
|
|
{ name = "Piero Toffanin", email = "pt@uav4geo.com" },
|
|
{ name = "LibreTranslate Authors" },
|
|
]
|
|
maintainers = [
|
|
{ name = "Piero Toffanin", email = "pt@uav4geo.com" },
|
|
{ name = "LibreTranslate Authors" },
|
|
]
|
|
keywords = [
|
|
"Python",
|
|
"Translate",
|
|
"Translation",
|
|
"API",
|
|
]
|
|
classifiers = [
|
|
"Operating System :: OS Independent",
|
|
"License :: OSI Approved :: GNU Affero General Public License v3",
|
|
"Programming Language :: Python :: 3",
|
|
"Programming Language :: Python :: 3.8",
|
|
"Programming Language :: Python :: 3.9",
|
|
"Programming Language :: Python :: 3.10",
|
|
"Programming Language :: Python :: 3.11",
|
|
"Programming Language :: Python :: 3.12",
|
|
"Programming Language :: Python :: 3.13",
|
|
]
|
|
dynamic = ["version"]
|
|
|
|
dependencies = [
|
|
"argostranslate ==1.10.0",
|
|
"Flask ==2.2.5",
|
|
"flask-swagger ==0.2.14",
|
|
"flask-swagger-ui ==4.11.1",
|
|
"Flask-Limiter ==2.6.3",
|
|
"Flask-Babel ==3.1.0",
|
|
"Flask-Session ==0.4.0",
|
|
"waitress ==2.1.2",
|
|
"expiringdict ==1.2.2",
|
|
"langdetect==1.0.9",
|
|
"lexilang==1.0.6",
|
|
"morfessor ==2.0.6",
|
|
"appdirs ==1.4.4",
|
|
"APScheduler ==3.9.1",
|
|
"translatehtml ==1.5.2",
|
|
"argos-translate-files ==1.4.0",
|
|
"itsdangerous ==2.1.2",
|
|
"Werkzeug ==2.3.8",
|
|
"requests ==2.31.0",
|
|
"redis ==4.4.4",
|
|
"numpy <2",
|
|
"prometheus-client ==0.15.0",
|
|
"polib ==1.1.1",
|
|
"packaging ==23.1",
|
|
"torch ==2.4.0;python_version<'3.9'",
|
|
"torch ==2.5.0;python_version>='3.9'",
|
|
]
|
|
|
|
[project.scripts]
|
|
libretranslate = "libretranslate.main:main"
|
|
ltmanage = "libretranslate.manage:manage"
|
|
|
|
|
|
[project.optional-dependencies]
|
|
test = [
|
|
"pytest >=7.2.0",
|
|
"pytest-cov",
|
|
"pre-commit >=3.0.0",
|
|
"types-requests",
|
|
"pip-audit"
|
|
]
|
|
|
|
|
|
[project.urls]
|
|
Homepage = "https://libretranslate.com"
|
|
Source = "https://github.com/LibreTranslate/LibreTranslate"
|
|
Documentation = "https://github.com/LibreTranslate/LibreTranslate"
|
|
Tracker = "https://github.com/LibreTranslate/LibreTranslate/issues"
|
|
History = "https://github.com/LibreTranslate/LibreTranslate/releases"
|
|
|
|
[tool.hatch.build]
|
|
artifacts = ["*.mo"]
|
|
|
|
# ENVIRONMENTS AND SCRIPTS
|
|
[tool.hatch.envs.default]
|
|
features = [
|
|
"test",
|
|
]
|
|
post-install-commands = [
|
|
"pre-commit install",
|
|
]
|
|
|
|
|
|
[tool.hatch.envs.default.scripts]
|
|
dev = "python main.py {args}"
|
|
locales = "python scripts/compile_locales.py"
|
|
fmt = [
|
|
"pre-commit run --all --all-files",
|
|
]
|
|
test = [
|
|
"fmt",
|
|
"pytest {args}",
|
|
]
|
|
cov = [
|
|
"pytest --cov-report html {args}",
|
|
"python -c 'import webbrowser; webbrowser.open(\"http://0.0.0.0:3000\")'",
|
|
"python -m http.server 3000 --directory ./htmlcov",
|
|
]
|
|
|
|
|
|
[[tool.hatch.envs.all.matrix]]
|
|
python = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
|
|
|
|
# TOOLS
|
|
[tool.hatch.version]
|
|
path = "VERSION"
|
|
pattern = "^(?P<version>[0-9]*.[0-9]*.[0-9]*)$"
|
|
|
|
|
|
[tool.pytest.ini_options]
|
|
addopts = [
|
|
"-v",
|
|
"--cov=libretranslate",
|
|
"--color=yes",
|
|
"--cov-report=term-missing",
|
|
]
|
|
|
|
ignore = [
|
|
"E501", # line too long
|
|
"A003", # Class attribute is shadowing a python builtin
|
|
"S101", # Use of `assert` detected
|
|
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
|
|
"T201", "T203", # remove print and pprint
|
|
"E402", # Module level import not at top of file
|
|
]
|