build_wheel.sh 1.77 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.9.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
12
setup_pip_pytorch_version
python setup.py clean
13
14
15
16
17
18
19

# 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
20
21
        # Install delocate to relocate the required binaries
        pip_install delocate
22
23
    else
        cp "$bin_path/Library/bin/libpng16.dll" torchvision
24
        cp "$bin_path/Library/bin/libjpeg.dll" torchvision
25
26
    fi
else
27
28
29
30
31
32
33
    # 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
34
35
fi

36
37
download_copy_ffmpeg

38
39
40
41
42
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59


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
        DYLD_LIBRARY_PATH="$env_path/lib/:$DYLD_LIBRARY_PATH" delocate-wheel -v $whl
    done
else
    if [[ "$OSTYPE" == "msys" ]]; then
        "$script_dir/windows/internal/vc_env_helper.bat" python $script_dir/wheel/relocate.py
    else
        LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" python $script_dir/wheel/relocate.py
    fi
fi