build_wheel.sh 1.87 KB
Newer Older
1
2
3
4
5
6
#!/bin/bash
set -ex

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

7
export BUILD_TYPE=wheel
8
setup_env 0.12.0
Edward Z. Yang's avatar
Edward Z. Yang committed
9
setup_wheel_python
peterjc123's avatar
peterjc123 committed
10
pip_install numpy pyyaml future ninja
11
pip_install --upgrade setuptools
12
13
setup_pip_pytorch_version
python setup.py clean
14
15
16
17
18
19
20

# Copy binaries to be included in the wheel distribution
if [[ "$(uname)" == Darwin || "$OSTYPE" == "msys" ]]; then
    python_exec="$(which python)"
    bin_path=$(dirname $python_exec)
    env_path=$(dirname $bin_path)
    if [[ "$(uname)" == Darwin ]]; then
21
        # Install delocate to relocate the required binaries
22
        pip_install "delocate>=0.9"
23
24
    else
        cp "$bin_path/Library/bin/libpng16.dll" torchvision
25
        cp "$bin_path/Library/bin/libjpeg.dll" torchvision
26
27
    fi
else
28
29
30
31
32
33
34
    # Install auditwheel to get some inspection utilities
    pip_install auditwheel

    # Point to custom libraries
    export LD_LIBRARY_PATH=$(pwd)/ext_libraries/lib:$LD_LIBRARY_PATH
    export TORCHVISION_INCLUDE=$(pwd)/ext_libraries/include
    export TORCHVISION_LIBRARY=$(pwd)/ext_libraries/lib
35
36
fi

37
38
download_copy_ffmpeg

39
40
41
42
43
if [[ "$OSTYPE" == "msys" ]]; then
    IS_WHEEL=1 "$script_dir/windows/internal/vc_env_helper.bat" python setup.py bdist_wheel
else
    IS_WHEEL=1 python setup.py bdist_wheel
fi
44
45
46
47
48
49
50
51


if [[ "$(uname)" == Darwin ]]; then
    pushd dist/
    python_exec="$(which python)"
    bin_path=$(dirname $python_exec)
    env_path=$(dirname $bin_path)
    for whl in *.whl; do
52
        DYLD_FALLBACK_LIBRARY_PATH="$env_path/lib/:$DYLD_FALLBACK_LIBRARY_PATH" delocate-wheel -v --ignore-missing-dependencies $whl
53
54
55
56
57
    done
else
    if [[ "$OSTYPE" == "msys" ]]; then
        "$script_dir/windows/internal/vc_env_helper.bat" python $script_dir/wheel/relocate.py
    else
58
        LD_LIBRARY_PATH="/usr/local/lib:$CUDA_HOME/lib64:$LD_LIBRARY_PATH" python $script_dir/wheel/relocate.py
59
60
    fi
fi