Skip to content

Commit 4542332

Browse files
authored
Packaging improvements for nightlies (#198)
* Packaging improvements for nightlies - Instructions for how to install stable and master binaries, without hardcoding wheel filenames - Turn on Python 2 build (numba is only needed for testing) - Make builds a little more hermetic - Prefer building against nightly CPU-only torch build - Don't install all of requirements.txt, it's not necessary - Updates for OS X too, including portability issues Signed-off-by: Edward Z. Yang <[email protected]>
1 parent 25504ad commit 4542332

File tree

4 files changed

+33
-22
lines changed

4 files changed

+33
-22
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,22 @@ Installation
4949

5050
### Binaries
5151

52-
To install pip wheels of 0.2.0, select the appropriate pip wheel for
53-
your version of Python:
52+
To install the latest pip wheels, run:
5453

5554
```
56-
# Wheels for Python 2 are NOT supported
55+
pip install torchaudio -f https://download.pytorch.org/whl/torch_stable.html
56+
```
5757

58-
# Python 3.5
59-
pip3 install http://download.pytorch.org/whl/torchaudio-0.2-cp35-cp35m-linux_x86_64.whl
58+
(If you do not have torch already installed, this will default to installing
59+
torch from PyPI. If you need a different torch configuration, preinstall torch
60+
before running this command.)
6061

61-
# Python 3.6
62-
pip3 install http://download.pytorch.org/whl/torchaudio-0.2-cp36-cp36m-linux_x86_64.whl
62+
At the moment, there is no automated nightly build process, but we occasionally
63+
build nightlies based on PyTorch nightlies by hand following the instructions in
64+
[build_tools/packaging](build_tools/packaging). To install the latest nightly, run:
6365

64-
# Python 3.7
65-
pip3 install http://download.pytorch.org/whl/torchaudio-0.2-cp37-cp37m-linux_x86_64.whl
66+
```
67+
pip install torchaudio_nightly -f https://download.pytorch.org/whl/nightly/torch_nightly.html
6668
```
6769

6870
### From Source

build_tools/packaging/wheel/build_from_source.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,21 @@ popd
2828

2929
# build mad, statically
3030
pushd libmad-0.15.1b
31+
# See https://stackoverflow.com/a/12864879/23845
32+
sed -i.bak 's/-march=i486//' configure
3133
./configure --disable-shared --enable-static --prefix="$PREFIX/audio/third_party/mad" CFLAGS=-fPIC CXXFLAGS=-fPIC \
3234
--with-pic --disable-debug --disable-dependency-tracking
3335
make -s -j && make install
3436
popd
3537

3638
# build sox, statically
39+
# --without-png makes OS X build less hazardous; somehow the build
40+
# finds png and enables it. We don't want it; we'd need to package
41+
# it statically if we do.
3742
pushd sox-14.4.2
3843
./configure --disable-shared --enable-static --prefix="$PREFIX/audio/third_party/sox" \
3944
LDFLAGS="-L$PREFIX/audio/third_party/lame/lib -L$PREFIX/audio/third_party/flac/lib -L$PREFIX/audio/third_party/mad/lib" \
4045
CPPFLAGS="-I$PREFIX/audio/third_party/lame/include -I$PREFIX/audio/third_party/flac/include -I$PREFIX/audio/third_party/mad/include" \
41-
--with-lame --with-flac --with-mad --without-oggvorbis --without-oss --without-sndfile CFLAGS=-fPIC CXXFLAGS=-fPIC --with-pic --disable-debug --disable-dependency-tracking
46+
--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
4247
make -s -j && make install
4348
popd

build_tools/packaging/wheel/linux_manywheel.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,26 @@ export PREFIX="/tmp"
2525
cd /tmp/audio
2626

2727
for PYDIR in "${python_installations[@]}"; do
28-
# wheels for numba does not work with python 2.7
29-
if [[ "$PYDIR" == "/opt/python/cp27-cp27m/" || "$PYDIR" == "/opt/python/cp27-cp27mu/" ]]; then
30-
continue;
31-
fi
3228
export PATH=$PYDIR/bin:$OLD_PATH
3329
pip install --upgrade pip
3430

31+
# For true hermetic builds, you ought to be constructing the docker
32+
# from scratch each time. But this makes things marginally safer if
33+
# you aren't doing this.
34+
pip uninstall -y torch || true
35+
pip uninstall -y torch_nightly || true
36+
3537
export TORCHAUDIO_PYTORCH_DEPENDENCY_NAME=torch_nightly
36-
pip install torch_nightly -f https://download.pytorch.org/whl/nightly/torch_nightly.html
38+
pip install torch_nightly -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
3739
# CPU/CUDA variants of PyTorch have ABI compatible PyTorch. Therefore, we
38-
# strip off the local package qualifier
40+
# strip off the local package qualifier. Also, we choose to build against
41+
# the CPU build, because it takes less time to download.
3942
export TORCHAUDIO_PYTORCH_DEPENDENCY_VERSION="$(pip show torch_nightly | grep ^Version: | sed 's/Version: \+//' | sed 's/+.\+//')"
4043
echo "Building against ${TORCHAUDIO_PYTORCH_DEPENDENCY_VERSION}"
4144

42-
pip install -r requirements.txt
45+
# NB: do not actually install requirements.txt; that is only needed for
46+
# testing
47+
pip install numpy future
4348
IS_WHEEL=1 python setup.py clean
4449
IS_WHEEL=1 python setup.py bdist_wheel
4550
mkdir -p $OUT_DIR

build_tools/packaging/wheel/osx_wheel.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,13 @@ do
4444
conda activate $env_name
4545

4646
export TORCHAUDIO_PYTORCH_DEPENDENCY_NAME=torch_nightly
47-
pip install torch_nightly -f https://download.pytorch.org/whl/nightly/torch_nightly.html
47+
pip install torch_nightly -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
4848
# NB: OS X builds don't have local package qualifiers
49-
export TORCHAUDIO_PYTORCH_DEPENDENCY_VERSION="$(pip show torch_nightly | grep ^Version: | sed 's/Version: \+//')"
49+
# NB: Don't use \+ here, it's not portable
50+
export TORCHAUDIO_PYTORCH_DEPENDENCY_VERSION="$(pip show torch_nightly | grep ^Version: | sed 's/Version: *//')"
5051
echo "Building against ${TORCHAUDIO_PYTORCH_DEPENDENCY_VERSION}"
5152

52-
# install torchaudio dependencies
53-
pip install -r requirements.txt
54-
53+
pip install numpy future
5554
IS_WHEEL=1 python setup.py clean
5655
IS_WHEEL=1 python setup.py bdist_wheel
5756
mkdir -p $OUT_DIR

0 commit comments

Comments
 (0)