linux_manywheel.sh 2.06 KB
Newer Older
1
2
3
4
#!/bin/bash

set -ex

5
6
7
8
9
10
if [[ -z "$TORCHAUDIO_BUILD_VERSION" ]]; then
  export TORCHAUDIO_BUILD_VERSION="0.4.0.dev$(date "+%Y%m%d")"
fi
if [[ -z "$TORCHAUDIO_BUILD_NUMBER" ]]; then
  export TORCHAUDIO_BUILD_NUMBER="1"
fi
11
export OUT_DIR="/remote/cpu"
12

13
14
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

15
16
17
18
19
20
cd /opt/python
DESIRED_PYTHON=(*/)
for desired_py in "${DESIRED_PYTHON[@]}"; do
    python_installations+=("/opt/python/$desired_py")
done

21
22
23
24
25
26
27
28
29
30
31
32
33
34
if [[ "$TARGET_COMMIT" == HEAD ]]; then
  # Assume that this script was called from a valid checkout
  WORKDIR="$(realpath "$script_dir/../../..")"
else
  WORKDIR="/tmp/audio"
  cd /tmp
  rm -rf audio
  git clone https://github.com/pytorch/audio
  cd audio
  git checkout "$TARGET_COMMIT"
  git submodule update --init --recursive
fi

mkdir "$WORKDIR/third_party"
35

36
37
export PREFIX="$WORKDIR"
. "$script_dir/build_from_source.sh"
38

39
cd "$WORKDIR"
40

41
42
43
ORIG_TORCHAUDIO_PYTORCH_DEPENDENCY_VERSION="$TORCHAUDIO_PYTORCH_DEPENDENCY_VERSION"

OLD_PATH=$PATH
44
for PYDIR in "${python_installations[@]}"; do
45
    export PATH="$PYDIR/bin:$OLD_PATH"
46
    pip install --upgrade pip
47

48
49
50
51
52
53
54
55
56
    if [[ -z "$ORIG_TORCHAUDIO_PYTORCH_DEPENDENCY_VERSION" ]]; then
      pip install --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
      # CPU/CUDA variants of PyTorch have ABI compatible PyTorch.  Therefore, we
      # strip off the local package qualifier.  Also, we choose to build against
      # the CPU build, because it takes less time to download.
      export TORCHAUDIO_PYTORCH_DEPENDENCY_VERSION="$(pip show torch | grep ^Version: | sed 's/Version: \+//' | sed 's/+.\+//')"
    else
      pip install "torch==$TORCHAUDIO_PYTORCH_DEPENDENCY_VERSION" -f https://download.pytorch.org/whl/torch_stable.html
    fi
57
58
    echo "Building against ${TORCHAUDIO_PYTORCH_DEPENDENCY_VERSION}"

59
60
61
    # NB: do not actually install requirements.txt; that is only needed for
    # testing
    pip install numpy future
62
63
64
65
66
    IS_WHEEL=1 python setup.py clean
    IS_WHEEL=1 python setup.py bdist_wheel
    mkdir -p $OUT_DIR
    cp dist/*.whl $OUT_DIR/
done