Add VERSION

This commit is contained in:
Piero Toffanin 2021-10-26 15:32:06 -04:00
parent 42c44a2ba1
commit d12c81b773
3 changed files with 10 additions and 3 deletions

1
VERSION Normal file
View file

@ -0,0 +1 @@
1.2.6

View file

@ -5,7 +5,6 @@ import uuid
from functools import wraps from functools import wraps
import argostranslatefiles import argostranslatefiles
import pkg_resources
from argostranslatefiles import get_supported_formats from argostranslatefiles import get_supported_formats
from flask import Flask, abort, jsonify, render_template, request, url_for, send_file from flask import Flask, abort, jsonify, render_template, request, url_for, send_file
from flask_swagger import swagger from flask_swagger import swagger
@ -19,6 +18,13 @@ from .api_keys import Database
from .suggestions import Database as SuggestionsDatabase 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(): def get_upload_dir():
upload_dir = os.path.join(tempfile.gettempdir(), "libretranslate-files-translate") upload_dir = os.path.join(tempfile.gettempdir(), "libretranslate-files-translate")
@ -200,7 +206,7 @@ def create_app(args):
frontendTimeout=args.frontend_timeout, frontendTimeout=args.frontend_timeout,
api_keys=args.api_keys, api_keys=args.api_keys,
web_version=os.environ.get("LT_WEB") is not None, 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"]) @app.route("/javascript-licenses", methods=["GET"])

View file

@ -3,7 +3,7 @@
from setuptools import setup, find_packages from setuptools import setup, find_packages
setup( setup(
version='1.2.5', version=open('VERSION').read().strip(),
name='libretranslate', name='libretranslate',
license='GNU Affero General Public License v3.0', 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.', description='Free and Open Source Machine Translation API. Self-hosted, no limits, no ties to proprietary services.',