Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 8 additions & 9 deletions build_tools/packaging/conda/build_audio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,25 @@ SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"

audio_rootdir="$(pwd)/torchaudio-src"

if [[ "$BRANCH" == "" ]]; then
BRANCH=master
fi

if [[ ! -d "$audio_rootdir" ]]; then
rm -rf "$audio_rootdir"
git clone "https://github.com/pytorch/audio" "$audio_rootdir"
pushd "$audio_rootdir"
git checkout v$TORCHAUDIO_BUILD_VERSION
popd
git clone "https://github.com/pytorch/audio" "$audio_rootdir" -b "$BRANCH"
fi

export TORCHAUDIO_GITHUB_ROOT_DIR="$audio_rootdir"

cd "$SOURCE_DIR"

ANACONDA_USER=pytorch
conda config --set anaconda_upload no

# "$desired_cuda" == 'cpu'
export TORCHAUDIO_PACKAGE_SUFFIX=""
export CONDA_CUDATOOLKIT_CONSTRAINT=""
export CUDA_VERSION="None"
if [[ "$OSTYPE" != "darwin"* ]]; then
export TORCHAUDIO_PACKAGE_SUFFIX="-cpu"
else
if [[ "$OSTYPE" == "darwin"* ]]; then
export MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++
fi

Expand Down
7 changes: 7 additions & 0 deletions build_tools/packaging/conda/torchaudio/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -ex

PREFIX="$(pwd)"
. build_tools/packaging/wheel/build_from_source.sh

IS_CONDA=1 python setup.py install --single-version-externally-managed --record=record.txt
18 changes: 7 additions & 11 deletions build_tools/packaging/conda/torchaudio/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package:
name: torchaudio{{ environ.get('TORCHAUDIO_PACKAGE_SUFFIX') }}
name: torchaudio
version: "{{ environ.get('TORCHAUDIO_BUILD_VERSION') }}"

source:
git_rev: v{{ environ.get('TORCHAUDIO_BUILD_VERSION') }}
git_url: https://github.com/pytorch/audio.git
path: "{{ environ.get('TORCHAUDIO_GITHUB_ROOT_DIR') }}"

requirements:
build:
Expand All @@ -14,20 +13,16 @@ requirements:
host:
- python
- setuptools
- pytorch{{ environ.get('TORCHAUDIO_PACKAGE_SUFFIX') }} >=1.1.0
- sox
- pytorch >=1.1.0

run:
- python
- pytorch{{ environ.get('TORCHAUDIO_PACKAGE_SUFFIX') }} >=1.1.0
- librosa >=0.4.3
- scipy
- sox
- typing
- pytorch >=1.1.0

build:
number: {{ environ.get('TORCHAUDIO_BUILD_NUMBER') }}
string: py{{py}}_{{environ.get('TORCHAUDIO_BUILD_NUMBER')}}
script: IS_CONDA=1 python setup.py install --single-version-externally-managed --record=record.txt # [not win]

test:
imports:
Expand All @@ -43,7 +38,8 @@ test:

requires:
- pytest
- librosa >=0.4.3
# Ideally we would test this, but conda doesn't provide librosa
# - librosa >=0.4.3
- scipy

about:
Expand Down
18 changes: 10 additions & 8 deletions build_tools/packaging/wheel/build_from_source.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
rm -rf source_code
mkdir source_code
cd source_code
pushd source_code

wget -q -O sox-14.4.2.tar.bz2 "http://downloads.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fsox%2Ffiles%2Fsox%2F14.4.2%2F&ts=1416316415&use_mirror=heanet"
wget -q -O lame-3.99.5.tar.gz "http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Flame%2Ffiles%2Flame%2F3.99%2F&ts=1416316457&use_mirror=kent"
Expand All @@ -15,13 +15,13 @@ tar xfp libmad-0.15.1b.tar.gz

# build lame, statically
pushd lame-3.99.5
./configure --disable-shared --enable-static --prefix="$PREFIX/audio/third_party/lame" CFLAGS=-fPIC CXXFLAGS=-fPIC --with-pic --disable-debug --disable-dependency-tracking --enable-nasm
./configure --disable-shared --enable-static --prefix="$PREFIX/third_party/lame" CFLAGS=-fPIC CXXFLAGS=-fPIC --with-pic --disable-debug --disable-dependency-tracking --enable-nasm
make -s -j && make install
popd

# build flac, statically
pushd flac-1.3.2
./configure --disable-shared --enable-static --prefix="$PREFIX/audio/third_party/flac" CFLAGS=-fPIC CXXFLAGS=-fPIC \
./configure --disable-shared --enable-static --prefix="$PREFIX/third_party/flac" CFLAGS=-fPIC CXXFLAGS=-fPIC \
--with-pic --disable-debug --disable-dependency-tracking
make -s -j && make install
popd
Expand All @@ -30,16 +30,18 @@ popd
pushd libmad-0.15.1b
# See https://stackoverflow.com/a/12864879/23845
sed -i.bak 's/-march=i486//' configure
./configure --disable-shared --enable-static --prefix="$PREFIX/audio/third_party/mad" CFLAGS=-fPIC CXXFLAGS=-fPIC \
./configure --disable-shared --enable-static --prefix="$PREFIX/third_party/mad" CFLAGS=-fPIC CXXFLAGS=-fPIC \
--with-pic --disable-debug --disable-dependency-tracking
make -s -j && make install
popd

# build sox, statically
pushd sox-14.4.2
./configure --disable-shared --enable-static --prefix="$PREFIX/audio/third_party/sox" \
LDFLAGS="-L$PREFIX/audio/third_party/lame/lib -L$PREFIX/audio/third_party/flac/lib -L$PREFIX/audio/third_party/mad/lib" \
CPPFLAGS="-I$PREFIX/audio/third_party/lame/include -I$PREFIX/audio/third_party/flac/include -I$PREFIX/audio/third_party/mad/include" \
--with-lame --with-flac --with-mad --without-oggvorbis --without-oss --without-sndfile CFLAGS=-fPIC CXXFLAGS=-fPIC --with-pic --disable-debug --disable-dependency-tracking
./configure --disable-shared --enable-static --prefix="$PREFIX/third_party/sox" \
LDFLAGS="-L$PREFIX/third_party/lame/lib -L$PREFIX/third_party/flac/lib -L$PREFIX/third_party/mad/lib" \
CPPFLAGS="-I$PREFIX/third_party/lame/include -I$PREFIX/third_party/flac/include -I$PREFIX/third_party/mad/include" \
--with-lame --with-flac --with-mad --without-png --without-oggvorbis --without-oss --without-sndfile CFLAGS=-fPIC CXXFLAGS=-fPIC --with-pic --disable-debug --disable-dependency-tracking
make -s -j && make install
popd

popd
2 changes: 1 addition & 1 deletion build_tools/packaging/wheel/linux_manywheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ rm -rf audio
git clone https://github.com/pytorch/audio -b v${TORCHAUDIO_BUILD_VERSION}
mkdir audio/third_party

export PREFIX="/tmp"
export PREFIX="/tmp/audio"
. /remote/wheel/build_from_source.sh

cd /tmp/audio
Expand Down
2 changes: 1 addition & 1 deletion build_tools/packaging/wheel/osx_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ rm -rf audio
git clone https://github.com/pytorch/audio -b v${TORCHAUDIO_BUILD_VERSION}
mkdir audio/third_party

export PREFIX="/tmp"
export PREFIX="/tmp/audio"
. $CURR_PATH/build_from_source.sh

cd /tmp/audio
Expand Down
10 changes: 4 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def check_env_flag(name, default=''):
include_dirs = []
extra_objects = []

if IS_WHEEL:
# Hypothetically, the conda distribution could rely on an external sox,
# but the library is pretty small and it is not available on the default
# anaconda channel. So we statically link it in, just as we do with wheels.
if IS_WHEEL or IS_CONDA:
audio_path = os.path.dirname(os.path.abspath(__file__))

include_dirs += [os.path.join(audio_path, 'third_party/flac/include')]
Expand All @@ -49,11 +52,6 @@ def check_env_flag(name, default=''):
else:
libraries += ['sox']

if IS_CONDA:
# We want $PREFIX/include for conda (for sox.h)
lib_path = os.path.dirname(sys.executable)
include_dirs += [os.path.join(os.path.dirname(lib_path), 'include')]


# Creating the version file
cwd = os.path.dirname(os.path.abspath(__file__))
Expand Down