Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows用実行バイナリの自動ビルドを追加 (#85) #107

Merged
merged 63 commits into from
Sep 21, 2021
Merged
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
e994c59
windows workflow: prepare cache
aoirint Sep 19, 2021
87673f6
windows workflow
aoirint Sep 19, 2021
371e02c
copy libtorch/lib
aoirint Sep 19, 2021
80f7bd5
fix core cache path
aoirint Sep 19, 2021
963d0c8
fix site-packages path
aoirint Sep 19, 2021
1e05300
quote path
aoirint Sep 19, 2021
f611189
skip unnecessary os check
aoirint Sep 19, 2021
ca1cc01
rm cudnn url from cpu matrix
aoirint Sep 19, 2021
cded7a4
use bin dir to search cuda dlls
aoirint Sep 19, 2021
df36946
install voicevox core python package
aoirint Sep 19, 2021
5b89aa1
fix version spec
aoirint Sep 19, 2021
a892aa3
makelib
aoirint Sep 19, 2021
e4b24d7
cmd /C instead cmd
aoirint Sep 19, 2021
7b2cdcf
call directly makelib.bat
aoirint Sep 19, 2021
ecb5400
call bat with relative path
aoirint Sep 19, 2021
12f055a
install ccache
aoirint Sep 19, 2021
ace2e93
rm voicevox core url dump file
aoirint Sep 19, 2021
143a380
fix ccache_url ref
aoirint Sep 19, 2021
f7bd2f3
copy core dll
aoirint Sep 19, 2021
b966be5
nuitka assume yes for download
aoirint Sep 19, 2021
4c5964e
generic site-packages dir path
aoirint Sep 20, 2021
d683cd6
extract cuda dll only (reduce disk usage)
aoirint Sep 20, 2021
85bbfc4
fix cuda dll path
aoirint Sep 20, 2021
6ffac40
fix mkdir cuda dll dir
aoirint Sep 20, 2021
1d73c1e
setup-python outputs.python-version
aoirint Sep 20, 2021
052f5d4
use windows-2019
aoirint Sep 20, 2021
d79e30b
replace bashslash to slash in cp
aoirint Sep 20, 2021
e4b9314
set nuitka cache dir env
aoirint Sep 20, 2021
e5fa884
nuitka cache dir as env in step
aoirint Sep 20, 2021
6c30ba3
fix cuda path escaping
aoirint Sep 20, 2021
d8ac103
use cuda slash path to rm
aoirint Sep 20, 2021
e8d89d1
use shell variable for cuda slash path
aoirint Sep 20, 2021
7d9bf78
fix command substitution
aoirint Sep 20, 2021
8aeae71
fix quote
aoirint Sep 20, 2021
f843b4b
fix command substitution
aoirint Sep 20, 2021
a4e49d5
use [] instead - in yaml
aoirint Sep 20, 2021
8ebf329
fix step order (save temporal capacity)
aoirint Sep 20, 2021
4dc34e4
libtorch extract only dlls
aoirint Sep 20, 2021
49f0d28
cudnn extract only dlls
aoirint Sep 20, 2021
f9f12c8
show disk space before nuitka build for debug
aoirint Sep 20, 2021
06f6246
fix shell name
aoirint Sep 20, 2021
4b9fa0e
merge dlls with upload-artifact (save storage space)
aoirint Sep 20, 2021
70dfe30
add disk space log
aoirint Sep 20, 2021
0c6ead3
disk space log as step
aoirint Sep 20, 2021
110a398
fix cache step id (-dll-)
aoirint Sep 20, 2021
06859f7
use symlink to pack artifact
aoirint Sep 20, 2021
c16b8db
fix env to create symlink
aoirint Sep 20, 2021
2c0b488
ref matirx.device
aoirint Sep 20, 2021
3a31028
log symlinks
aoirint Sep 20, 2021
b056984
fix windows nuitka cache key; rm target
aoirint Sep 20, 2021
d4d653a
unquote asterisk
aoirint Sep 20, 2021
87be034
create symlink instead of copy (Git Bash)
aoirint Sep 20, 2021
d1b255f
use step env for MSYS env var
aoirint Sep 20, 2021
61ba1b7
overwrite symlink
aoirint Sep 20, 2021
7fdf71b
remove CUDA/cuDNN download (included in LibTorch)
aoirint Sep 20, 2021
f7f2024
remove CUDA/cuDNN download commands (included in LibTorch)
aoirint Sep 20, 2021
8e1f151
use only include for matrix
aoirint Sep 20, 2021
184330b
fix libtorch step name
aoirint Sep 20, 2021
dd85263
reorder steps; libtorch former
aoirint Sep 20, 2021
fca3dab
run build.yml on master push
aoirint Sep 20, 2021
3ad9e8b
download openjtalk dic (with retry)
aoirint Sep 20, 2021
b0fc7a4
fail workflow if openjtalk dic download fail
aoirint Sep 20, 2021
31b4a42
follow core 0.6.0 (windows)
aoirint Sep 20, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
254 changes: 254 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,257 @@ jobs:
with:
name: ${{ matrix.artifact_name }}
path: build/run.dist/


build-windows:
strategy:
matrix:
include:
# Windows CPU
- os: windows-2019
python: '3.7'
python_architecture: 'x64'
voicevox_core_version: '0.6.0'
voicevox_core_dll_name: core_cpu.dll
voicevox_core_example_version: '0.6.0'
libtorch_url: https://download.pytorch.org/libtorch/cpu/libtorch-win-shared-with-deps-1.9.0%2Bcpu.zip
ccache_url: https://github.com/ccache/ccache/releases/download/v4.4.1/ccache-4.4.1-windows-64.zip
artifact_name: windows-cpu
nuitka_cache_path: nuitka_cache
pip_cache_path: ~\AppData\Local\pip\Cache
# Windows NVIDIA GPU
- os: windows-2019
python: '3.7'
python_architecture: 'x64'
voicevox_core_version: '0.6.0'
voicevox_core_dll_name: core.dll
voicevox_core_example_version: '0.6.0'
libtorch_url: https://download.pytorch.org/libtorch/cu111/libtorch-win-shared-with-deps-1.9.0%2Bcu111.zip
ccache_url: https://github.com/ccache/ccache/releases/download/v4.4.1/ccache-4.4.1-windows-64.zip
artifact_name: windows-nvidia
nuitka_cache_path: nuitka_cache
pip_cache_path: ~\AppData\Local\pip\Cache

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1

# Python install path: C:/hostedtoolcache/windows/Python
- name: Setup Python
id: setup-python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.python_architecture }}

# Install Python dependencies
- name: Prepare Python dependencies cache
uses: actions/cache@v2
id: pip-cache
with:
path: ${{ matrix.pip_cache_path }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/requirements-dev.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install Python dependencies
shell: bash
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements-dev.txt

# Download pyopenjtalk dictionary
# try 5 times, sleep 5 seconds before retry
for i in $(seq 5); do
EXIT_CODE=0
python3 -c "import pyopenjtalk; pyopenjtalk._lazy_init()" || EXIT_CODE=$?

if [ "$EXIT_CODE" = "0" ]; then
break
fi

sleep 5
done

if [ "$EXIT_CODE" != "0" ]; then
exit "$EXIT_CODE"
fi

- name: Create download directory
shell: bash
run: mkdir -p download/

# Install Ccache
- name: Export Ccache url to calc hash
shell: bash
run: echo "${{ matrix.ccache_url }}" > download/ccache_url.txt

- name: Prepare Ccache
uses: actions/cache@v2
id: ccache-cache
with:
key: ${{ matrix.os }}-ccache-${{ hashFiles('download/ccache_url.txt') }}
path: download/ccache

- name: Download Ccache
if: steps.ccache-cache.outputs.cache-hit != 'true'
shell: bash
run: |
curl -L "${{ matrix.ccache_url }}" > download/ccache.zip
unzip download/ccache.zip -d download/
rm download/ccache.zip
mv download/ccache-*/ download/ccache

- name: Install Ccache
shell: bash
run: |
echo "$HOME/download/ccache" >> $GITHUB_PATH

# Download LibTorch
# Included:
# - CUDA
# - cuDNN
- name: Export LibTorch url to calc hash
shell: bash
run: echo "${{ matrix.libtorch_url }}" > download/libtorch_url.txt

- name: Prepare LibTorch cache
uses: actions/cache@v2
id: libtorch-dll-cache
with:
key: ${{ matrix.os }}-libtorch-dll-${{ hashFiles('download/libtorch_url.txt') }}
path: download/libtorch

- name: Download LibTorch (CUDA, cuDNN included)
if: steps.libtorch-dll-cache.outputs.cache-hit != 'true'
shell: bash
run: |
curl -L "${{ matrix.libtorch_url }}" > download/libtorch.zip
# extract only dlls
unzip download/libtorch.zip libtorch/lib/*.dll -d download/
rm download/libtorch.zip

- name: Show disk space (debug info)
shell: bash
run: |
df -h

# Download VOICEVOX Core
- name: Prepare VOICEVOX Core cache
uses: actions/cache@v2
id: voicevox-core-cache
with:
key: ${{ matrix.os }}-voicevox-core-${{ matrix.voicevox_core_version }}
path: download/core

- name: Download VOICEVOX Core
if: steps.voicevox-core-cache.outputs.cache-hit != 'true'
shell: bash
run: |
curl -L "https://github.com/Hiroshiba/voicevox_core/releases/download/${{ matrix.voicevox_core_version }}/core.zip" > download/core.zip
unzip download/core.zip -d download/
rm download/core.zip

# Install VOICEVOX Core example
- name: Prepare VOICEVOX Core example cache
uses: actions/cache@v2
id: voicevox-core-example-cache
with:
key: ${{ matrix.os }}-voicevox-core-example-${{ matrix.voicevox_core_example_version }}
path: download/voicevox_core_example

- name: Clone VOICEVOX Core example
if: steps.voicevox-core-example-cache.outputs.cache-hit != 'true'
shell: bash
run: |
git clone -b "${{ matrix.voicevox_core_example_version }}" --depth 1 "https://github.com/Hiroshiba/voicevox_core.git" download/voicevox_core_example

- name: Install VOICEVOX Core Python package
shell: bash
run: |
cp download/core/${{ matrix.voicevox_core_dll_name }} download/voicevox_core_example/example/python/core.dll
cp download/voicevox_core_example/core.h download/voicevox_core_example/example/python/

cd download/voicevox_core_example/example/python
./makelib.bat core

pip install .

- name: Cache Nuitka (ccache, module-cache)
uses: actions/cache@v2
id: nuitka-cache
with:
path: ${{ matrix.nuitka_cache_path }}
key: ${{ runner.os }}-nuitka-${{ github.sha }}
restore-keys: |
${{ runner.os }}-nuitka-

- name: Show disk space (debug info)
shell: bash
run: |
df -h

- name: Build run.py with Nuitka
shell: bash
env:
NUITKA_CACHE_DIR: ${{ matrix.nuitka_cache_path }}
run:
python -m nuitka
--standalone
--assume-yes-for-downloads
--plugin-enable=numpy
--follow-import-to=numpy
--follow-import-to=aiofiles
--include-package=uvicorn
--include-package-data=pyopenjtalk
--include-package-data=resampy
--include-data-file="VERSION.txt=./"
--msvc=14.2
--follow-imports
--no-prefer-source-code
run.py

- name: Show disk space (debug info)
shell: bash
run: |
df -h

- name: Create artifact directory with symlink
shell: bash
env:
PYTHON_SITE_PACKAGES_DIR: C:/hostedtoolcache/windows/python/${{ steps.setup-python.outputs.python-version }}/x64/lib/site-packages
# create symlink instead of copy (Git Bash)
# https://qiita.com/ucho/items/c5ea0beb8acf2f1e4772
MSYS: winsymlinks:nativestrict
run: |
set -eux

mkdir -p artifact
ln -sf "$(pwd)/run.dist"/* artifact/

ln -sf "$(pwd)/download/libtorch/lib"/*.dll artifact/
ln -sf "$(pwd)/download/core"/*.bin artifact/
ln -sf "$(pwd)/download/voicevox_core_example/example/python/"*.dll artifact/
ln -sf "$(pwd)/download/core/metas.json" artifact/

ln -sf "${{ env.PYTHON_SITE_PACKAGES_DIR }}/_soundfile_data" artifact/
ln -sf "${{ env.PYTHON_SITE_PACKAGES_DIR }}/llvmlite/binding/llvmlite.dll" artifact/

# FIXME: versioned name may be useful; but
# actions/download-artifact and dawidd6/download-artifact do not support
# wildcard / forward-matching yet.
# Currently, It is good to use static artifact name for future binary test workflow.
# https://github.com/actions/toolkit/blob/ea81280a4d48fb0308d40f8f12ae00d117f8acb9/packages/artifact/src/internal/artifact-client.ts#L147
# https://github.com/dawidd6/action-download-artifact/blob/af92a8455a59214b7b932932f2662fdefbd78126/main.js#L113
- uses: actions/upload-artifact@v2
# env:
# VERSIONED_ARTIFACT_NAME: |
# ${{ format('{0}-{1}', matrix.artifact_name, (github.event.release.tag_name != '' && github.event.release.tag_name) || github.sha) }}
with:
name: ${{ matrix.artifact_name }}
path: |
artifact/