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 () { ...@@ -10,38 +10,40 @@ retry () {
$* || (sleep 1 && $*) || (sleep 2 && $*) || (sleep 4 && $*) || (sleep 8 && $*) $* || (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 export TORCHAUDIO_BUILD_NUMBER=1
SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
audio_rootdir="$(pwd)/torchaudio-src" audio_rootdir="$(pwd)/torchaudio-src"
if [[ "$BRANCH" == "" ]]; then
BRANCH=master
fi
if [[ ! -d "$audio_rootdir" ]]; then if [[ ! -d "$audio_rootdir" ]]; then
rm -rf "$audio_rootdir" rm -rf "$audio_rootdir"
git clone "https://github.com/pytorch/audio" "$audio_rootdir" git clone "https://github.com/pytorch/audio" "$audio_rootdir" -b "$BRANCH"
pushd "$audio_rootdir"
git checkout v$TORCHAUDIO_BUILD_VERSION
popd
fi fi
export TORCHAUDIO_GITHUB_ROOT_DIR="$audio_rootdir"
cd "$SOURCE_DIR" cd "$SOURCE_DIR"
ANACONDA_USER=pytorch ANACONDA_USER=pytorch
conda config --set anaconda_upload no conda config --set anaconda_upload no
# "$desired_cuda" == 'cpu' LATEST_PYTORCH_NIGHTLY_VERSION=$(conda search --json 'pytorch-nightly[channel=pytorch]' | python "$SOURCE_DIR/get-latest.py")
export TORCHAUDIO_PACKAGE_SUFFIX="" export CONDA_PYTORCH_CONSTRAINT=" - pytorch-nightly ==${LATEST_PYTORCH_NIGHTLY_VERSION}"
export CONDA_CUDATOOLKIT_CONSTRAINT="" export CONDA_CUDATOOLKIT_CONSTRAINT=""
export CUDA_VERSION="None" export CUDA_VERSION="None"
if [[ "$OSTYPE" != "darwin"* ]]; then if [[ "$OSTYPE" == "darwin"* ]]; then
export TORCHAUDIO_PACKAGE_SUFFIX="-cpu"
else
export MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ export MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++
fi fi
time conda build -c $ANACONDA_USER --no-anaconda-upload --python 2.7 torchaudio 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.6 torchaudio
time conda build -c $ANACONDA_USER --no-anaconda-upload --python 3.7 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: package:
name: torchaudio{{ environ.get('TORCHAUDIO_PACKAGE_SUFFIX') }} name: torchaudio
version: "{{ environ.get('TORCHAUDIO_BUILD_VERSION') }}" version: "{{ environ.get('TORCHAUDIO_BUILD_VERSION') }}"
source: source:
git_rev: v{{ environ.get('TORCHAUDIO_BUILD_VERSION') }} path: "{{ environ.get('TORCHAUDIO_GITHUB_ROOT_DIR') }}"
git_url: https://github.com/pytorch/audio.git
requirements: requirements:
build: build:
...@@ -14,20 +13,16 @@ requirements: ...@@ -14,20 +13,16 @@ requirements:
host: host:
- python - python
- setuptools - setuptools
- pytorch{{ environ.get('TORCHAUDIO_PACKAGE_SUFFIX') }} >=1.1.0 {{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
- sox
run: run:
- python - python
- pytorch{{ environ.get('TORCHAUDIO_PACKAGE_SUFFIX') }} >=1.1.0 - typing
- librosa >=0.4.3 {{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
- scipy
- sox
build: build:
number: {{ environ.get('TORCHAUDIO_BUILD_NUMBER') }} number: {{ environ.get('TORCHAUDIO_BUILD_NUMBER') }}
string: py{{py}}_{{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: test:
imports: imports:
...@@ -42,7 +37,8 @@ test: ...@@ -42,7 +37,8 @@ test:
requires: requires:
- pytest - pytest
- librosa >=0.4.3 # Ideally we would test this, but conda doesn't provide librosa
# - librosa >=0.4.3
- scipy - scipy
about: about:
......
rm -rf source_code rm -rf source_code
mkdir 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 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" 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 ...@@ -15,13 +15,13 @@ tar xfp libmad-0.15.1b.tar.gz
# build lame, statically # build lame, statically
pushd lame-3.99.5 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 make -s -j && make install
popd popd
# build flac, statically # build flac, statically
pushd flac-1.3.2 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 --with-pic --disable-debug --disable-dependency-tracking
make -s -j && make install make -s -j && make install
popd popd
...@@ -30,7 +30,7 @@ popd ...@@ -30,7 +30,7 @@ popd
pushd libmad-0.15.1b pushd libmad-0.15.1b
# See https://stackoverflow.com/a/12864879/23845 # See https://stackoverflow.com/a/12864879/23845
sed -i.bak 's/-march=i486//' configure 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 --with-pic --disable-debug --disable-dependency-tracking
make -s -j && make install make -s -j && make install
popd popd
...@@ -40,9 +40,11 @@ popd ...@@ -40,9 +40,11 @@ popd
# finds png and enables it. We don't want it; we'd need to package # finds png and enables it. We don't want it; we'd need to package
# it statically if we do. # it statically if we do.
pushd sox-14.4.2 pushd sox-14.4.2
./configure --disable-shared --enable-static --prefix="$PREFIX/audio/third_party/sox" \ ./configure --disable-shared --enable-static --prefix="$PREFIX/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" \ LDFLAGS="-L$PREFIX/third_party/lame/lib -L$PREFIX/third_party/flac/lib -L$PREFIX/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" \ 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 --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 make -s -j && make install
popd popd
popd
...@@ -19,7 +19,7 @@ rm -rf audio ...@@ -19,7 +19,7 @@ rm -rf audio
git clone https://github.com/pytorch/audio git clone https://github.com/pytorch/audio
mkdir audio/third_party mkdir audio/third_party
export PREFIX="/tmp" export PREFIX="/tmp/audio"
. /remote/wheel/build_from_source.sh . /remote/wheel/build_from_source.sh
cd /tmp/audio cd /tmp/audio
......
...@@ -29,7 +29,7 @@ rm -rf audio ...@@ -29,7 +29,7 @@ rm -rf audio
git clone https://github.com/pytorch/audio git clone https://github.com/pytorch/audio
mkdir audio/third_party mkdir audio/third_party
export PREFIX="/tmp" export PREFIX="/tmp/audio"
. $CURR_PATH/build_from_source.sh . $CURR_PATH/build_from_source.sh
cd /tmp/audio cd /tmp/audio
......
...@@ -31,7 +31,10 @@ libraries = [] ...@@ -31,7 +31,10 @@ libraries = []
include_dirs = [] include_dirs = []
extra_objects = [] 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__)) audio_path = os.path.dirname(os.path.abspath(__file__))
include_dirs += [os.path.join(audio_path, 'third_party/flac/include')] include_dirs += [os.path.join(audio_path, 'third_party/flac/include')]
...@@ -49,11 +52,6 @@ if IS_WHEEL: ...@@ -49,11 +52,6 @@ if IS_WHEEL:
else: else:
libraries += ['sox'] 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 # Creating the version file
cwd = os.path.dirname(os.path.abspath(__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