Skip to content

Commit b2c73b6

Browse files
authored
Conda nightly packaging updates and Add missing build script. (#212)
1 parent bbfd041 commit b2c73b6

File tree

7 files changed

+40
-37
lines changed

7 files changed

+40
-37
lines changed

build_tools/packaging/conda/build_audio.sh

+11-11
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,38 @@ retry () {
1010
$* || (sleep 1 && $*) || (sleep 2 && $*) || (sleep 4 && $*) || (sleep 8 && $*)
1111
}
1212

13-
export TORCHAUDIO_BUILD_VERSION="0.2.0"
13+
export TORCHAUDIO_BUILD_VERSION="0.3.0"
1414
export TORCHAUDIO_BUILD_NUMBER=1
1515

1616
SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
1717

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

20+
if [[ "$BRANCH" == "" ]]; then
21+
BRANCH=master
22+
fi
23+
2024
if [[ ! -d "$audio_rootdir" ]]; then
2125
rm -rf "$audio_rootdir"
22-
git clone "https://github.com/pytorch/audio" "$audio_rootdir"
23-
pushd "$audio_rootdir"
24-
git checkout v$TORCHAUDIO_BUILD_VERSION
25-
popd
26+
git clone "https://github.com/pytorch/audio" "$audio_rootdir" -b "$BRANCH"
2627
fi
2728

29+
export TORCHAUDIO_GITHUB_ROOT_DIR="$audio_rootdir"
30+
2831
cd "$SOURCE_DIR"
2932

3033
ANACONDA_USER=pytorch
3134
conda config --set anaconda_upload no
3235

33-
# "$desired_cuda" == 'cpu'
34-
export TORCHAUDIO_PACKAGE_SUFFIX=""
3536
export CONDA_CUDATOOLKIT_CONSTRAINT=""
3637
export CUDA_VERSION="None"
37-
if [[ "$OSTYPE" != "darwin"* ]]; then
38-
export TORCHAUDIO_PACKAGE_SUFFIX="-cpu"
39-
else
38+
if [[ "$OSTYPE" == "darwin"* ]]; then
4039
export MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++
4140
fi
4241

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

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
PREFIX="$(pwd)"
5+
. build_tools/packaging/wheel/build_from_source.sh
6+
7+
IS_CONDA=1 python setup.py install --single-version-externally-managed --record=record.txt

build_tools/packaging/conda/torchaudio/meta.yaml

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package:
2-
name: torchaudio{{ environ.get('TORCHAUDIO_PACKAGE_SUFFIX') }}
2+
name: torchaudio
33
version: "{{ environ.get('TORCHAUDIO_BUILD_VERSION') }}"
44

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

98
requirements:
109
build:
@@ -14,20 +13,16 @@ requirements:
1413
host:
1514
- python
1615
- setuptools
17-
- pytorch{{ environ.get('TORCHAUDIO_PACKAGE_SUFFIX') }} >=1.1.0
18-
- sox
16+
- pytorch >=1.2.0
1917

2018
run:
2119
- python
22-
- pytorch{{ environ.get('TORCHAUDIO_PACKAGE_SUFFIX') }} >=1.1.0
23-
- librosa >=0.4.3
24-
- scipy
25-
- sox
20+
- typing
21+
- pytorch >=1.2.0
2622

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

3227
test:
3328
imports:
@@ -42,7 +37,8 @@ test:
4237

4338
requires:
4439
- pytest
45-
- librosa >=0.4.3
40+
# Ideally we would test this, but conda doesn't provide librosa
41+
# - librosa >=0.4.3
4642
- scipy
4743

4844
about:

build_tools/packaging/wheel/build_from_source.sh

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
rm -rf source_code
22
mkdir source_code
3-
cd source_code
3+
pushd source_code
44

55
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"
66
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
1515

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

2222
# build flac, statically
2323
pushd flac-1.3.2
24-
./configure --disable-shared --enable-static --prefix="$PREFIX/audio/third_party/flac" CFLAGS=-fPIC CXXFLAGS=-fPIC \
24+
./configure --disable-shared --enable-static --prefix="$PREFIX/third_party/flac" CFLAGS=-fPIC CXXFLAGS=-fPIC \
2525
--with-pic --disable-debug --disable-dependency-tracking
2626
make -s -j && make install
2727
popd
@@ -30,7 +30,7 @@ popd
3030
pushd libmad-0.15.1b
3131
# See https://stackoverflow.com/a/12864879/23845
3232
sed -i.bak 's/-march=i486//' configure
33-
./configure --disable-shared --enable-static --prefix="$PREFIX/audio/third_party/mad" CFLAGS=-fPIC CXXFLAGS=-fPIC \
33+
./configure --disable-shared --enable-static --prefix="$PREFIX/third_party/mad" CFLAGS=-fPIC CXXFLAGS=-fPIC \
3434
--with-pic --disable-debug --disable-dependency-tracking
3535
make -s -j && make install
3636
popd
@@ -40,9 +40,11 @@ popd
4040
# finds png and enables it. We don't want it; we'd need to package
4141
# it statically if we do.
4242
pushd sox-14.4.2
43-
./configure --disable-shared --enable-static --prefix="$PREFIX/audio/third_party/sox" \
44-
LDFLAGS="-L$PREFIX/audio/third_party/lame/lib -L$PREFIX/audio/third_party/flac/lib -L$PREFIX/audio/third_party/mad/lib" \
45-
CPPFLAGS="-I$PREFIX/audio/third_party/lame/include -I$PREFIX/audio/third_party/flac/include -I$PREFIX/audio/third_party/mad/include" \
43+
./configure --disable-shared --enable-static --prefix="$PREFIX/third_party/sox" \
44+
LDFLAGS="-L$PREFIX/third_party/lame/lib -L$PREFIX/third_party/flac/lib -L$PREFIX/third_party/mad/lib" \
45+
CPPFLAGS="-I$PREFIX/third_party/lame/include -I$PREFIX/third_party/flac/include -I$PREFIX/third_party/mad/include" \
4646
--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
4747
make -s -j && make install
4848
popd
49+
50+
popd

build_tools/packaging/wheel/linux_manywheel.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ rm -rf audio
2121
git clone https://github.com/pytorch/audio -b v${TORCHAUDIO_BUILD_VERSION}
2222
mkdir audio/third_party
2323

24-
export PREFIX="/tmp"
24+
export PREFIX="/tmp/audio"
2525
. /remote/wheel/build_from_source.sh
2626

2727
cd /tmp/audio

build_tools/packaging/wheel/osx_wheel.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ rm -rf audio
2626
git clone https://github.com/pytorch/audio -b v${TORCHAUDIO_BUILD_VERSION}
2727
mkdir audio/third_party
2828

29-
export PREFIX="/tmp"
29+
export PREFIX="/tmp/audio"
3030
. $CURR_PATH/build_from_source.sh
3131

3232
cd /tmp/audio

setup.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ def check_env_flag(name, default=''):
3131
include_dirs = []
3232
extra_objects = []
3333

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

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

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

5856
# Creating the version file
5957
cwd = os.path.dirname(os.path.abspath(__file__))

0 commit comments

Comments
 (0)