Skip to content

Commit

Permalink
WindowsではPyInstallerのbootloaderをカスタマイズする (#596)
Browse files Browse the repository at this point in the history
Co-authored-by: Yuto Ashida <[email protected]>
Co-authored-by: Hiroshiba <[email protected]>
Resolves #502
  • Loading branch information
qryxip authored Jan 29, 2023
1 parent 462095b commit 35b53f2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ jobs:
run: |
python -m pip install -r requirements-dev.txt
if [ "$RUNNER_OS" = Windows ]; then
# Modify PyInstaller to enable NvOptimusEnablement and AmdPowerXpressRequestHighPerformance
./build_util/modify_pyinstaller.bash
fi
# Download pyopenjtalk dictionary
# try 5 times, sleep 5 seconds before retry
for i in $(seq 5); do
Expand Down
25 changes: 25 additions & 0 deletions build_util/modify_pyinstaller.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# PyInstallerをカスタマイズしてから再インストールする
# 良いGPUが自動的に選択されるようにしている
# https://github.com/VOICEVOX/voicevox_engine/issues/502

set -eux

pyinstaller_version=$(pyinstaller -v)
tempdir=$(mktemp -dt modify_pyinstaller.XXXXXXXX)
trap 'rm -rf "$tempdir"' EXIT
git clone https://github.com/pyinstaller/pyinstaller.git "$tempdir" -b "v$pyinstaller_version" --depth 1
cat > "$tempdir/bootloader/src/symbols.c" << EOF
#ifdef _WIN32
#include <windows.h>
// https://docs.nvidia.com/gameworks/content/technologies/desktop/optimus.htm
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
// https://gpuopen.com/learn/amdpowerxpressrequesthighperformance/
__declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001;
#endif
EOF
(cd "$tempdir/bootloader" && python ./waf all)
pip install -U "$tempdir"

0 comments on commit 35b53f2

Please sign in to comment.