From 50228ffa7e097ff909124290a576a3027e3c799c Mon Sep 17 00:00:00 2001 From: Hiroshiba Kazuyuki Date: Sat, 15 Jan 2022 23:15:54 +0900 Subject: [PATCH 1/3] =?UTF-8?q?VERSION.txt=E3=82=92=E6=B6=88=E5=8E=BB?= =?UTF-8?q?=E3=81=97=E3=80=81release=E3=83=93=E3=83=AB=E3=83=89=E6=99=82?= =?UTF-8?q?=E3=81=AB=E8=87=AA=E5=8B=95=E7=9A=84=E3=81=AB=E3=83=90=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=83=A7=E3=83=B3=E5=90=8D=E3=81=8C=E5=85=A5=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 60 ++++++++++++++++++++------------ Dockerfile | 7 ++-- README.md | 1 - VERSION.txt | 1 - run.py | 5 +-- voicevox_engine/__init__.py | 1 + voicevox_engine/dev/core/mock.py | 16 ++++----- 7 files changed, 52 insertions(+), 39 deletions(-) delete mode 100644 VERSION.txt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 866779aef..bd875074f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,6 +14,8 @@ env: VOICEVOX_RESOURCE_VERSION: '0.10.preview.2' VOICEVOX_CORE_VERSION: '0.10.preview.3' VOICEVOX_CORE_SOURCE_VERSION: '0.10.preview.3' + VOICEVOX_ENGINE_VERSION: |- # releaseのときはタグが、それ以外はlatestがバージョン名に + ${{ github.event.release.tag_name != '' && github.event.release.tag_name || 'latest' }} jobs: # Build Mac binary (x64 arch only) @@ -37,6 +39,13 @@ jobs: shell: bash run: brew install ccache + # NOTE: The default sed of macOS is BSD sed. + # There is a difference in specification between BSD sed and GNU sed, + # so you need to install GNU sed. + - name: Install GNU sed on macOS + shell: bash + run: brew install gnu-sed + - name: Create download and build directory run: mkdir download build @@ -199,6 +208,8 @@ jobs: run: | set -eux + gsed -i "s/__version__ = \"latest\"/__version__ = \"${{ env.VOICEVOX_ENGINE_VERSION }}\"/" ../voicevox_engine/__init__.py + # Nuitka does not copy grandchild dependencies. Explicitly copy libonnxruntime python -m nuitka \ --output-dir=./ \ @@ -211,7 +222,6 @@ jobs: --include-package=anyio \ --include-package-data=pyopenjtalk \ --include-package-data=scipy \ - --include-data-file=../VERSION.txt=./ \ --include-data-file=../licenses.json=./ \ --include-data-file=../presets.yaml=./ \ --include-data-file=../user.dic=./ \ @@ -339,6 +349,7 @@ jobs: BASE_IMAGE=${{ matrix.base_image }} BASE_RUNTIME_IMAGE=${{ matrix.base_runtime_image }} PYTHON_VERSION=${{ env.PYTHON_VERSION }} + VOICEVOX_ENGINE_VERSION=${{ env.VOICEVOX_ENGINE_VERSION }} VOICEVOX_CORE_VERSION=${{ env.VOICEVOX_CORE_VERSION }} VOICEVOX_CORE_SOURCE_VERSION=${{ env.VOICEVOX_CORE_SOURCE_VERSION }} VOICEVOX_CORE_LIBRARY_NAME=${{ matrix.voicevox_core_library_name }} @@ -703,28 +714,31 @@ jobs: shell: bash env: NUITKA_CACHE_DIR: ${{ matrix.nuitka_cache_path }} - run: - python -m nuitka - --standalone - --assume-yes-for-downloads - --plugin-enable=numpy - --plugin-enable=multiprocessing - --follow-import-to=numpy - --follow-import-to=aiofiles - --include-package=uvicorn - --include-package=anyio - --include-package-data=pyopenjtalk - --include-package-data=scipy - --include-data-file="VERSION.txt=./" - --include-data-file="licenses.json=./" - --include-data-file="user.dic=./" - --include-data-file="presets.yaml=./" - --include-data-file=download/core/*.bin=./ - --include-data-file="download/core/metas.json=./" - --include-data-dir="speaker_info=./speaker_info" - --msvc=14.2 - --follow-imports - --no-prefer-source-code + run: | + set -eux + + sed -i "s/__version__ = \"latest\"/__version__ = \"${{ env.VOICEVOX_ENGINE_VERSION }}\"/" voicevox_engine/__init__.py + + python -m nuitka \ + --standalone \ + --assume-yes-for-downloads \ + --plugin-enable=numpy \ + --plugin-enable=multiprocessing \ + --follow-import-to=numpy \ + --follow-import-to=aiofiles \ + --include-package=uvicorn \ + --include-package=anyio \ + --include-package-data=pyopenjtalk \ + --include-package-data=scipy \ + --include-data-file="licenses.json=./" \ + --include-data-file="user.dic=./" \ + --include-data-file="presets.yaml=./" \ + --include-data-file=download/core/*.bin=./ \ + --include-data-file="download/core/metas.json=./" \ + --include-data-dir="speaker_info=./speaker_info" \ + --msvc=14.2 \ + --follow-imports \ + --no-prefer-source-code \ run.py - name: Show disk space (debug info) diff --git a/Dockerfile b/Dockerfile index a950ea737..3c2c4aff9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -239,9 +239,13 @@ EOF # Add local files ADD ./voicevox_engine /opt/voicevox_engine/voicevox_engine ADD ./docs /opt/voicevox_engine/docs -ADD ./run.py ./generate_licenses.py ./check_tts.py ./presets.yaml ./VERSION.txt ./user.dic /opt/voicevox_engine/ +ADD ./run.py ./generate_licenses.py ./check_tts.py ./presets.yaml ./user.dic /opt/voicevox_engine/ ADD ./speaker_info /opt/voicevox_engine/speaker_info +# Replace version +ARG VOICEVOX_ENGINE_VERSION=latest +RUN sed -i "s/__version__ = \"latest\"/__version__ = \"${VOICEVOX_ENGINE_VERSION}\"/" /opt/voicevox_engine/voicevox_engine/__init__.py + # Generate licenses.json RUN < FastAPI: app = FastAPI( title="VOICEVOX ENGINE", description="VOICEVOXの音声合成エンジンです。", - version=(root_dir / "VERSION.txt").read_text().strip(), + version=__version__, ) app.add_middleware( @@ -422,7 +423,7 @@ def get_presets(): @app.get("/version", tags=["その他"]) def version() -> str: - return (root_dir / "VERSION.txt").read_text() + return __version__ @app.get("/speakers", response_model=List[Speaker], tags=["その他"]) def speakers(): diff --git a/voicevox_engine/__init__.py b/voicevox_engine/__init__.py index e69de29bb..ca7021040 100644 --- a/voicevox_engine/__init__.py +++ b/voicevox_engine/__init__.py @@ -0,0 +1 @@ +__version__ = "latest" diff --git a/voicevox_engine/dev/core/mock.py b/voicevox_engine/dev/core/mock.py index 87d52059f..d49964701 100644 --- a/voicevox_engine/dev/core/mock.py +++ b/voicevox_engine/dev/core/mock.py @@ -1,5 +1,5 @@ +import json from logging import getLogger -from pathlib import Path from typing import Any, Dict, List import numpy as np @@ -68,9 +68,7 @@ def decode_forward(length: int, **kwargs: Dict[str, Any]) -> np.ndarray: def metas() -> str: - mock_dir = Path(__file__).parent - version = (mock_dir / ".." / ".." / ".." / "VERSION.txt").read_text().strip() - return str( + return json.dumps( [ { "name": "dummy1", @@ -81,7 +79,7 @@ def metas() -> str: {"name": "style3", "id": 6}, ], "speaker_uuid": "7ffcb7ce-00ec-4bdc-82cd-45a8889e43ff", - "version": version, + "version": "mock", }, { "name": "dummy2", @@ -92,7 +90,7 @@ def metas() -> str: {"name": "style3", "id": 7}, ], "speaker_uuid": "388f246b-8c41-4ac1-8e2d-5d79f3ff56d9", - "version": version, + "version": "mock", }, { "name": "dummy3", @@ -100,7 +98,7 @@ def metas() -> str: {"name": "style0", "id": 8}, ], "speaker_uuid": "35b2c544-660e-401e-b503-0e14c635303a", - "version": version, + "version": "mock", }, { "name": "dummy4", @@ -108,9 +106,7 @@ def metas() -> str: {"name": "style0", "id": 9}, ], "speaker_uuid": "b1a81618-b27b-40d2-b0ea-27a9ad408c4b", - "version": version, + "version": "mock", }, ] - ).replace( - "'", '"' # ちゃんとJSONとして認識してもらうためにシングルクォーテーションを置き換える ) From 1753bf6746d23b7820c6d21a833d0823b118c673 Mon Sep 17 00:00:00 2001 From: Hiroshiba Kazuyuki Date: Sat, 15 Jan 2022 23:25:17 +0900 Subject: [PATCH 2/3] add comment --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bd875074f..e12391681 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -208,6 +208,7 @@ jobs: run: | set -eux + # Replace version gsed -i "s/__version__ = \"latest\"/__version__ = \"${{ env.VOICEVOX_ENGINE_VERSION }}\"/" ../voicevox_engine/__init__.py # Nuitka does not copy grandchild dependencies. Explicitly copy libonnxruntime @@ -717,6 +718,7 @@ jobs: run: | set -eux + # Replace version sed -i "s/__version__ = \"latest\"/__version__ = \"${{ env.VOICEVOX_ENGINE_VERSION }}\"/" voicevox_engine/__init__.py python -m nuitka \ From bcf6c125000a5c87c4a87bbb6d154d6dcc92b0c4 Mon Sep 17 00:00:00 2001 From: Hiroshiba Kazuyuki Date: Sat, 15 Jan 2022 23:42:22 +0900 Subject: [PATCH 3/3] =?UTF-8?q?build-docker=E3=81=AB=E3=81=AA=E3=81=8B?= =?UTF-8?q?=E3=81=A3=E3=81=9F=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-docker.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 5ee52fde9..827ddb93a 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -13,6 +13,8 @@ env: PYTHON_VERSION: '3.8.10' VOICEVOX_CORE_VERSION: '0.10.preview.3' VOICEVOX_CORE_SOURCE_VERSION: '0.10.preview.3' + VOICEVOX_ENGINE_VERSION: |- # releaseのときはタグが、それ以外はlatestがバージョン名に + ${{ github.event.release.tag_name != '' && github.event.release.tag_name || 'latest' }} jobs: build-docker: @@ -108,6 +110,7 @@ jobs: BASE_IMAGE=${{ matrix.base_image }} BASE_RUNTIME_IMAGE=${{ matrix.base_runtime_image }} PYTHON_VERSION=${{ env.PYTHON_VERSION }} + VOICEVOX_ENGINE_VERSION=${{ env.VOICEVOX_ENGINE_VERSION }} VOICEVOX_CORE_VERSION=${{ env.VOICEVOX_CORE_VERSION }} VOICEVOX_CORE_SOURCE_VERSION=${{ env.VOICEVOX_CORE_SOURCE_VERSION }} VOICEVOX_CORE_LIBRARY_NAME=${{ matrix.voicevox_core_library_name }}