Skip to content

Commit

Permalink
Conda nightly packaging updates and Add missing build script. (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamarshon authored Aug 5, 2019
1 parent bbfd041 commit b2c73b6
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 37 deletions.
22 changes: 11 additions & 11 deletions build_tools/packaging/conda/build_audio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,38 @@ retry () {
$* || (sleep 1 && $*) || (sleep 2 && $*) || (sleep 4 && $*) || (sleep 8 && $*)
}

export TORCHAUDIO_BUILD_VERSION="0.2.0"
export TORCHAUDIO_BUILD_VERSION="0.3.0"
export TORCHAUDIO_BUILD_NUMBER=1

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

time conda build -c $ANACONDA_USER --no-anaconda-upload --python 2.7 torchaudio
time conda build -c $ANACONDA_USER --no-anaconda-upload --python 3.5 torchaudio
# Currently disabled, see https://github.com/pytorch/pytorch/issues/23738
# time conda build -c $ANACONDA_USER --no-anaconda-upload --python 3.5 torchaudio
time conda build -c $ANACONDA_USER --no-anaconda-upload --python 3.6 torchaudio
time conda build -c $ANACONDA_USER --no-anaconda-upload --python 3.7 torchaudio

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.2.0

run:
- python
- pytorch{{ environ.get('TORCHAUDIO_PACKAGE_SUFFIX') }} >=1.1.0
- librosa >=0.4.3
- scipy
- sox
- typing
- pytorch >=1.2.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 @@ -42,7 +37,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
16 changes: 9 additions & 7 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,7 +30,7 @@ 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
Expand All @@ -40,9 +40,11 @@ popd
# finds png and enables it. We don't want it; we'd need to package
# it statically if we do.
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" \
./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 @@ -26,7 +26,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

0 comments on commit b2c73b6

Please sign in to comment.