Unverified Commit 4daf2fb7 authored by moto's avatar moto Committed by GitHub
Browse files

Add vorbis to binary build (#750)

parent 66f4cdf9
...@@ -20,4 +20,4 @@ printf "Installing PyTorch with %s\n" "${cudatoolkit}" ...@@ -20,4 +20,4 @@ printf "Installing PyTorch with %s\n" "${cudatoolkit}"
conda install -y -c pytorch-nightly pytorch "${cudatoolkit}" conda install -y -c pytorch-nightly pytorch "${cudatoolkit}"
printf "* Installing torchaudio\n" printf "* Installing torchaudio\n"
python setup.py develop BUILD_SOX=1 python setup.py develop
...@@ -6,4 +6,5 @@ eval "$(./conda/bin/conda shell.bash hook)" ...@@ -6,4 +6,5 @@ eval "$(./conda/bin/conda shell.bash hook)"
conda activate ./env conda activate ./env
python -m torch.utils.collect_env python -m torch.utils.collect_env
export PATH="${PWD}/third_party/build/bin/:${PATH}"
pytest --cov=torchaudio --junitxml=test-results/junit.xml -v --durations 20 test pytest --cov=torchaudio --junitxml=test-results/junit.xml -v --durations 20 test
...@@ -34,4 +34,4 @@ printf "* Installing dependencies (except PyTorch)\n" ...@@ -34,4 +34,4 @@ printf "* Installing dependencies (except PyTorch)\n"
conda env update --file "${this_dir}/environment.yml" --prune conda env update --file "${this_dir}/environment.yml" --prune
# 4. Build codecs # 4. Build codecs
# build_tools/setup_helpers/build_third_party.sh build_tools/setup_helpers/build_third_party.sh
...@@ -21,6 +21,20 @@ mkdir -p "${tmp_dir}" "${build_dir}" ...@@ -21,6 +21,20 @@ mkdir -p "${tmp_dir}" "${build_dir}"
. "${this_dir}/build_third_party_helper.sh" . "${this_dir}/build_third_party_helper.sh"
if ! found_ogg "${build_dir}" ; then
get_ogg "${tmp_dir}"
if [ "${download_only}" = "false" ]; then
build_ogg "${tmp_dir}" "${build_dir}"
fi
fi
if ! found_vorbis "${build_dir}" ; then
get_vorbis "${tmp_dir}"
if [ "${download_only}" = "false" ]; then
build_vorbis "${tmp_dir}" "${build_dir}"
fi
fi
if ! found_lame "${build_dir}" ; then if ! found_lame "${build_dir}" ; then
get_lame "${tmp_dir}" get_lame "${tmp_dir}"
if [ "${download_only}" = "false" ]; then if [ "${download_only}" = "false" ]; then
......
...@@ -24,6 +24,18 @@ all_found() { ...@@ -24,6 +24,18 @@ all_found() {
done done
} }
found_ogg() {
all_found "$1" 'include/ogg/ogg.h' 'lib/libogg.a'
}
found_vorbis() {
all_found "$1" \
'include/vorbis/vorbisenc.h' \
'include/vorbis/vorbisfile.h' \
'lib/libvorbis.a' \
'lib/libvorbisenc.a' \
'lib/libvorbisfile.a'
}
found_lame() { found_lame() {
all_found "$1" 'include/lame/lame.h' 'lib/libmp3lame.a' all_found "$1" 'include/lame/lame.h' 'lib/libmp3lame.a'
...@@ -57,6 +69,82 @@ found_sox() { ...@@ -57,6 +69,82 @@ found_sox() {
all_found "$1" 'include/sox.h' 'lib/libsox.a' all_found "$1" 'include/sox.h' 'lib/libsox.a'
} }
# libogg 1.3.4 has bug on mac OS.
# https://trac.macports.org/ticket/58924
OGG="libogg-1.3.3"
OGG_ARCHIVE="${OGG}.tar.gz"
get_ogg() {
work_dir="$1"
url="https://ftp.osuosl.org/pub/xiph/releases/ogg/${OGG_ARCHIVE}"
(
cd "${work_dir}"
if [ ! -d "${OGG}" ]; then
if [ ! -f "${OGG_ARCHIVE}" ]; then
printf "Fetching libogg from %s\n" "${url}"
curl $CURL_OPTS -O "${url}"
fi
fi
)
}
build_ogg() {
work_dir="$1"
install_dir="$2"
(
cd "${work_dir}"
if [ ! -d "${OGG}" ]; then
tar xfp "${OGG_ARCHIVE}"
fi
cd "${OGG}"
printf "Building libogg\n"
if [ ! -f Makefile ]; then
./configure ${CONFIG_OPTS} \
--disable-shared --enable-static --prefix="${install_dir}" CFLAGS=-fPIC CXXFLAGS=-fPIC \
--with-pic --disable-dependency-tracking
fi
make ${MAKE_OPTS} > make.log 2>&1
make install
)
}
VORBIS="libvorbis-1.3.6"
VORBIS_ARCHIVE="${VORBIS}.tar.gz"
get_vorbis() {
work_dir="$1"
url="https://ftp.osuosl.org/pub/xiph/releases/vorbis/${VORBIS_ARCHIVE}"
(
cd "${work_dir}"
if [ ! -d "${VORBIS}" ]; then
if [ ! -f "${VORBIS_ARCHIVE}" ]; then
printf "Fetching libvorbis from %s\n" "${url}"
curl $CURL_OPTS -O "${url}"
fi
fi
)
}
build_vorbis() {
work_dir="$1"
install_dir="$2"
(
cd "${work_dir}"
if [ ! -d "${VORBIS}" ]; then
tar xfp "${VORBIS_ARCHIVE}"
fi
cd "${VORBIS}"
printf "Building libvorbis\n"
if [ ! -f Makefile ]; then
./configure ${CONFIG_OPTS} \
--disable-shared --enable-static --prefix="${install_dir}" CFLAGS=-fPIC CXXFLAGS=-fPIC \
--with-pic --disable-dependency-tracking
fi
make ${MAKE_OPTS} > make.log 2>&1
make install
)
}
LAME="lame-3.99.5" LAME="lame-3.99.5"
LAME_ARCHIVE="${LAME}.tar.gz" LAME_ARCHIVE="${LAME}.tar.gz"
...@@ -126,7 +214,7 @@ build_flac() { ...@@ -126,7 +214,7 @@ build_flac() {
if [ ! -f Makefile ]; then if [ ! -f Makefile ]; then
./configure ${CONFIG_OPTS} \ ./configure ${CONFIG_OPTS} \
--disable-shared --enable-static --prefix="${install_dir}" CFLAGS=-fPIC CXXFLAGS=-fPIC \ --disable-shared --enable-static --prefix="${install_dir}" CFLAGS=-fPIC CXXFLAGS=-fPIC \
--with-pic --disable-debug --disable-dependency-tracking --with-pic --with-ogg="${install_dir}" --disable-debug --disable-dependency-tracking
fi fi
make ${MAKE_OPTS} > make.log 2>&1 make ${MAKE_OPTS} > make.log 2>&1
make ${MAKE_OPTS} install make ${MAKE_OPTS} install
...@@ -207,8 +295,8 @@ build_sox() { ...@@ -207,8 +295,8 @@ build_sox() {
# it statically if we do. # it statically if we do.
./configure ${CONFIG_OPTS} --disable-shared --enable-static --prefix="${install_dir}" \ ./configure ${CONFIG_OPTS} --disable-shared --enable-static --prefix="${install_dir}" \
LDFLAGS="-L${install_dir}/lib" CPPFLAGS="-I${install_dir}/include" \ LDFLAGS="-L${install_dir}/lib" CPPFLAGS="-I${install_dir}/include" \
--with-lame --with-flac --with-mad --without-alsa --without-coreaudio \ --with-lame --with-flac --with-mad --with-oggvorbis --without-alsa --without-coreaudio \
--without-png --without-oggvorbis --without-oss --without-sndfile \ --without-png --without-oss --without-sndfile \
CFLAGS=-fPIC CXXFLAGS=-fPIC --with-pic --disable-debug --disable-dependency-tracking CFLAGS=-fPIC CXXFLAGS=-fPIC --with-pic --disable-debug --disable-dependency-tracking
fi fi
make ${MAKE_OPTS} > make.log 2>&1 make ${MAKE_OPTS} > make.log 2>&1
......
...@@ -76,8 +76,18 @@ def _get_extra_objects(): ...@@ -76,8 +76,18 @@ def _get_extra_objects():
# NOTE: The order of the library listed bellow matters. # NOTE: The order of the library listed bellow matters.
# #
# (the most important thing is that dependencies come after a library # (the most important thing is that dependencies come after a library
# e.g., sox comes first) # e.g., sox comes first, flac/vorbis comes before ogg, and
libs = ['libsox.a', 'libmad.a', 'libFLAC.a', 'libmp3lame.a'] # vorbisenc/vorbisfile comes before vorbis
libs = [
'libsox.a',
'libmad.a',
'libFLAC.a',
'libmp3lame.a',
'libvorbisenc.a',
'libvorbisfile.a',
'libvorbis.a',
'libogg.a',
]
for lib in libs: for lib in libs:
objs.append(str(_TP_INSTALL_DIR / 'lib' / lib)) objs.append(str(_TP_INSTALL_DIR / 'lib' / lib))
return objs return objs
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment