Skip to content

Commit

Permalink
Merge fca016f into 0dec9dc
Browse files Browse the repository at this point in the history
  • Loading branch information
y-chan committed Nov 6, 2022
2 parents 0dec9dc + fca016f commit 159e2c4
Show file tree
Hide file tree
Showing 11 changed files with 263 additions and 803 deletions.
615 changes: 162 additions & 453 deletions .github/workflows/build.yml

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ share/python-wheels/
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt
Expand Down
125 changes: 0 additions & 125 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ COPY --from=compile-python-env /opt/python /opt/python
ADD ./requirements.txt /tmp/
RUN <<EOF
# Install requirements
# FIXME: Nuitka cannot build with setuptools>=60.7.0
# https://github.com/Nuitka/Nuitka/issues/1406
gosu user /opt/python/bin/python3 -m pip install --upgrade pip setuptools==60.6.0 wheel
gosu user /opt/python/bin/pip3 install -r /tmp/requirements.txt
EOF

Expand Down Expand Up @@ -272,125 +269,3 @@ CMD [ "gosu", "user", "/opt/python/bin/python3", "./run.py", "--voicelib_dir", "
# Enable use_gpu
FROM runtime-env AS runtime-nvidia-env
CMD [ "gosu", "user", "/opt/python/bin/python3", "./run.py", "--use_gpu", "--voicelib_dir", "/opt/voicevox_core/", "--runtime_dir", "/opt/onnxruntime/lib", "--host", "0.0.0.0" ]

# Binary build environment (common to CPU, GPU)
FROM runtime-env AS build-env

# Install ccache for Nuitka cache
# chrpath: required for nuitka build; 'RPATH' settings in used shared
RUN <<EOF
set -eux

apt-get update
apt-get install -y \
ccache \
chrpath \
patchelf
apt-get clean
rm -rf /var/lib/apt/lists/*
EOF

# Install Python build dependencies
ADD ./requirements-dev.txt /tmp/
RUN <<EOF
set -eux

gosu user /opt/python/bin/pip3 install -r /tmp/requirements-dev.txt
EOF

# Generate licenses.json with build dependencies
RUN <<EOF
set -eux

cd /opt/voicevox_engine

# Define temporary env vars
# /home/user/.local/bin is required to use the commands installed by pip
export PATH="/home/user/.local/bin:${PATH:-}"

gosu user /opt/python/bin/pip3 install pip-licenses
gosu user /opt/python/bin/python3 generate_licenses.py > /opt/voicevox_engine/engine_manifest_assets/dependency_licenses.json
# FIXME: VOICEVOX (editor) cannot build without licenses.json
cp /opt/voicevox_engine/engine_manifest_assets/dependency_licenses.json /opt/voicevox_engine/licenses.json
EOF

# Create build script
RUN <<EOF
set -eux

cat <<EOD > /build.sh
#!/bin/bash
set -eux

# chown general user c.z. mounted directory may be owned by root
mkdir -p /opt/voicevox_engine_build
chown -R user:user /opt/voicevox_engine_build

mkdir -p /home/user/.cache/Nuitka
chown -R user:user /home/user/.cache/Nuitka

cd /opt/voicevox_engine_build

gosu user /opt/python/bin/python3 -m nuitka \
--output-dir=/opt/voicevox_engine_build \
--standalone \
--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=/opt/voicevox_engine/licenses.json=./ \
--include-data-file=/opt/voicevox_engine/presets.yaml=./ \
--include-data-file=/opt/voicevox_engine/default.csv=./ \
--include-data-file=/opt/voicevox_engine/engine_manifest.json=./ \
--include-data-file=/opt/voicevox_core/*.so=./ \
--include-data-file=/opt/onnxruntime/lib/libonnxruntime.so=./ \
--include-data-dir=/opt/voicevox_engine/speaker_info=./speaker_info \
--include-data-dir=/opt/voicevox_engine/engine_manifest_assets=./engine_manifest_assets \
--follow-imports \
--no-prefer-source-code \
/opt/voicevox_engine/run.py

# Copy libonnxruntime_providers_cuda.so and dependencies (CUDA/cuDNN)
if [ -f "/opt/onnxruntime/lib/libonnxruntime_providers_cuda.so" ]; then
mkdir -p /tmp/coredeps

# Copy provider libraries (libonnxruntime.so.{version} is copied by Nuitka)
cd /opt/onnxruntime/lib
cp libonnxruntime_*.so /tmp/coredeps/
cd -

# assert nvidia/cuda base image
cd /usr/local/cuda/lib64
cp libcublas.so.* libcublasLt.so.* libcudart.so.* libcufft.so.* libcurand.so.* /tmp/coredeps/
cd -

# remove unneed full version libraries
cd /tmp/coredeps
rm -f libcublas.so.*.* libcublasLt.so.*.* libcufft.so.*.* libcurand.so.*.*
rm -f libcudart.so.*.*.*
cd -

# assert nvidia/cuda base image
cd /usr/lib/x86_64-linux-gnu
cp libcudnn.so.* libcudnn_*_infer.so.* /tmp/coredeps/
cd -

# remove unneed full version libraries
cd /tmp/coredeps
rm -f libcudnn.so.*.* libcudnn_*_infer.so.*.*
cd -

mv /tmp/coredeps/* /opt/voicevox_engine_build/run.dist/
rm -rf /tmp/coredeps
fi

chmod +x /opt/voicevox_engine_build/run.dist/run
EOD
chmod +x /build.sh
EOF

CMD [ "bash", "/build.sh" ]
Empty file.
93 changes: 0 additions & 93 deletions build_util/macos/build_util_macos/shlib_tools.py

This file was deleted.

54 changes: 0 additions & 54 deletions build_util/macos/copy_missing_dylibs.py

This file was deleted.

67 changes: 0 additions & 67 deletions build_util/macos/fix_rpaths.py

This file was deleted.

9 changes: 7 additions & 2 deletions generate_licenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,14 @@ def generate_licenses() -> List[License]:
if license.text == "UNKNOWN":
if license.name.lower() == "core" and license.version == "0.0.0":
continue
elif license.name.lower() == "nuitka":
elif license.name.lower() == "future":
with urllib.request.urlopen(
"https://raw.githubusercontent.com/Nuitka/Nuitka/develop/LICENSE.txt"
"https://raw.githubusercontent.com/PythonCharmers/python-future/master/LICENSE.txt" # noqa: B950
) as res:
license.text = res.read().decode()
elif license.name.lower() == "pefile":
with urllib.request.urlopen(
"https://raw.githubusercontent.com/erocarrera/pefile/master/LICENSE" # noqa: B950
) as res:
license.text = res.read().decode()
elif license.name.lower() == "pyopenjtalk":
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-r requirements.in
cython
nuitka
pyinstaller
pip-licenses
pip-tools
pre-commit
Expand Down
Loading

0 comments on commit 159e2c4

Please sign in to comment.