Skip to content

Commit

Permalink
Fixes to mac wheel test logic
Browse files Browse the repository at this point in the history
  • Loading branch information
pjh5 authored and Jenkins committed Sep 12, 2018
1 parent b77dda2 commit 7a7cac8
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions wheel/build_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export PYTORCH_BUILD_NUMBER=$build_number
if [[ -z "$TORCH_PACKAGE_NAME" ]]; then
TORCH_PACKAGE_NAME='torch'
fi
TORCH_PACKAGE_NAME="$(echo $TORCH_PACKAGE_NAME | tr '-' '_')"
if [[ -z "$PYTORCH_REPO" ]]; then
PYTORCH_REPO='pytorch'
fi
Expand All @@ -96,13 +97,16 @@ if [[ -z "$MAC_PACKAGE_WORK_DIR" ]]; then
fi
mkdir -p "$MAC_PACKAGE_WORK_DIR" || true
pytorch_rootdir="${MAC_PACKAGE_WORK_DIR}/pytorch"
whl_tmp_dir="${MAC_PACKAGE_WORK_DIR}/dist"

# Python 2.7 and 3.5 build against macOS 10.6, others build against 10.7
if [[ "$desired_python" == 2.7 || "$desired_python" == 3.5 ]]; then
mac_version='macosx_10_6_x86_64'
else
mac_version='macosx_10_7_x86_64'
fi

# Determine the wheel package name so that we can rename it later
wheel_filename_gen="${TORCH_PACKAGE_NAME}-${build_version}${build_number_prefix}-cp${python_nodot}-cp${python_nodot}m-${mac_version}.whl"
wheel_filename_new="${TORCH_PACKAGE_NAME}-${build_version}${build_number_prefix}-cp${python_nodot}-none-${mac_version}.whl"

Expand Down Expand Up @@ -139,6 +143,10 @@ conda create -n "$CONDA_ENVNAME" python="$desired_python" -y
source activate "$CONDA_ENVNAME"
export PREFIX="$CONDA_ROOT_PREFIX/envs/$CONDA_ENVNAME"
# now $PREFIX should point to your conda env
echo "Conda root: $CONDA_ROOT_PREFIX"
echo "Env root: $PREFIX"
echo "Python Version:"
python --version


# Have a separate Pytorch repo clone
Expand All @@ -150,43 +158,41 @@ if [[ ! -d "$pytorch_rootdir" ]]; then
git checkout tags/v${build_version}
fi
git submodule update --init --recursive
popd
fi

##########################
# now build the binary

echo "Conda root: $CONDA_ROOT_PREFIX"
echo "Env root: $PREFIX"

export TH_BINARY_BUILD=1

echo "Python Version:"
python --version

export MACOSX_DEPLOYMENT_TARGET=10.10

conda install -n $CONDA_ENVNAME -y cmake numpy==1.11.3 nomkl setuptools pyyaml cffi typing ninja
pip install -r "$(pwd)/requirements.txt" || true
pip install -r "${pytorch_rootdir}/requirements.txt" || true

python setup.py bdist_wheel
pushd "$pytorch_rootdir"
python setup.py bdist_wheel -d "$whl_tmp_dir"
popd

if [[ -z "$BUILD_PYTHONLESS" ]];
then
# Copy the whl to a final destination before tests are run
echo "Wheel file: $wheel_filename_gen $wheel_filename_new"
mkdir -p "$MAC_PACKAGE_FINAL_FOLDER" || true
cp "$whl_tmp_dir/$wheel_filename_gen" "$MAC_PACKAGE_FINAL_FOLDER/$wheel_filename_new"

if [[ -z "$BUILD_PYTHONLESS" ]]; then
##########################
# now test the binary
pip uninstall -y torch || true
pip uninstall -y torch || true
pip uninstall -y "$TORCH_PACKAGE_NAME" || true
pip uninstall -y "$TORCH_PACKAGE_NAME" || true

pip install "$(pwd)/dist/$wheel_filename_gen"
pushd test
# Only one binary is built, so it's safe to just specify the whl directory
pip install "$TORCH_PACKAGE_NAME" --no-index -f "$whl_tmp_dir"
pushd "${pytorch_rootdir}/test"
python run_test.py ${RUN_TEST_PARAMS[@]} || true
popd

# N.B. this is hardcoded to match wheel/upload.sh, which uploads from whl/
echo "Wheel file: $wheel_filename_gen $wheel_filename_new"
mkdir -p "$MAC_PACKAGE_FINAL_FOLDER" || true
cp "$(pwd)/dist/$wheel_filename_gen" "$MAC_PACKAGE_FINAL_FOLDER/$wheel_filename_new"
else
pushd "$pytorch_rootdir"
mkdir -p build
pushd build
python ../tools/build_libtorch.py
Expand Down

0 comments on commit 7a7cac8

Please sign in to comment.