From d12c81b7730be92e8dd52a15d50edd9cc3d1fc59 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Tue, 26 Oct 2021 15:32:06 -0400 Subject: [PATCH] Add VERSION --- VERSION | 1 + app/app.py | 10 ++++++++-- setup.py | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 VERSION diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..3c43790 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.2.6 diff --git a/app/app.py b/app/app.py index f930842..cd16942 100644 --- a/app/app.py +++ b/app/app.py @@ -5,7 +5,6 @@ import uuid from functools import wraps import argostranslatefiles -import pkg_resources from argostranslatefiles import get_supported_formats from flask import Flask, abort, jsonify, render_template, request, url_for, send_file from flask_swagger import swagger @@ -19,6 +18,13 @@ from .api_keys import Database from .suggestions import Database as SuggestionsDatabase +def get_version(): + try: + with open("VERSION") as f: + return f.read().strip() + except: + return "?" + def get_upload_dir(): upload_dir = os.path.join(tempfile.gettempdir(), "libretranslate-files-translate") @@ -200,7 +206,7 @@ def create_app(args): frontendTimeout=args.frontend_timeout, api_keys=args.api_keys, web_version=os.environ.get("LT_WEB") is not None, - version=pkg_resources.require("LibreTranslate")[0].version + version=get_version() ) @app.route("/javascript-licenses", methods=["GET"]) diff --git a/setup.py b/setup.py index 7fd5dec..308b25b 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup, find_packages setup( - version='1.2.5', + version=open('VERSION').read().strip(), name='libretranslate', license='GNU Affero General Public License v3.0', description='Free and Open Source Machine Translation API. Self-hosted, no limits, no ties to proprietary services.',