Unverified Commit a9bee3ed authored by Edward Z. Yang's avatar Edward Z. Yang Committed by GitHub
Browse files

Conda nightly packaging updates. (#203)

Billing of changes:

* Can now toggle what branch is built using BRANCH envvar
* PyTorch nightly we were built against is hardcoded into conda meta.yaml
* Disable Conda Python 3.5 builds as we don't have nightlies for torch at the moment
* No more torchaudio-cpu or torchaudio-nightly suffix
* Remove librosa from testing stanza, so that conda build works with stock anaconda channel
* Change convention on PREFIX to be what we previously called $PREFIX/audio
* Make build_from_source.sh cd-neutral

Signed-off-by: Edward Z. Yang ezyang@fb.com
parent a424509d
......@@ -10,38 +10,40 @@ retry () {
$* || (sleep 1 && $*) || (sleep 2 && $*) || (sleep 4 && $*) || (sleep 8 && $*)
}
export TORCHAUDIO_BUILD_VERSION="0.2.0"
export TORCHAUDIO_BUILD_VERSION="0.4.0.dev$(date "+%Y%m%d")"
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=""
LATEST_PYTORCH_NIGHTLY_VERSION=$(conda search --json 'pytorch-nightly[channel=pytorch]' | python "$SOURCE_DIR/get-latest.py")
export CONDA_PYTORCH_CONSTRAINT=" - pytorch-nightly ==${LATEST_PYTORCH_NIGHTLY_VERSION}"
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
......
# Functionally equivalent to:
# jq -r '.["pytorch-nightly"][-1].version' | sed 's/+.*$//'
import sys
import json
import re
print(re.sub(r'\+.*$', '', json.load(sys.stdin)["pytorch-nightly"][-1]["version"]))
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:
......@@ -14,20 +13,16 @@ requirements:
host:
- python
- setuptools
- pytorch{{ environ.get('TORCHAUDIO_PACKAGE_SUFFIX') }} >=1.1.0
- sox
{{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
run:
- python
- pytorch{{ environ.get('TORCHAUDIO_PACKAGE_SUFFIX') }} >=1.1.0
- librosa >=0.4.3
- scipy
- sox
- typing
{{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
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:
......@@ -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:
......
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"
......@@ -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
......@@ -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
......@@ -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
......@@ -19,7 +19,7 @@ rm -rf audio
git clone https://github.com/pytorch/audio
mkdir audio/third_party
export PREFIX="/tmp"
export PREFIX="/tmp/audio"
. /remote/wheel/build_from_source.sh
cd /tmp/audio
......
......@@ -29,7 +29,7 @@ rm -rf audio
git clone https://github.com/pytorch/audio
mkdir audio/third_party
export PREFIX="/tmp"
export PREFIX="/tmp/audio"
. $CURR_PATH/build_from_source.sh
cd /tmp/audio
......
......@@ -31,7 +31,10 @@ libraries = []
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')]
......@@ -49,11 +52,6 @@ if IS_WHEEL:
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__))
......
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