travis_osx_steps.sh 1.84 KB
Newer Older
1
#!/bin/bash
2
# Wheel build, install, run test steps on OSX
3
4
set -e

5
6
7
8
9
10
11
12
13
function check_sdk_11 {
  ver="$(xcrun -show-sdk-version)"
  if [[ "${ver}" == "" || "${ver}" == 10.* ]]; then
    echo "not found"
  else
    echo "found"
  fi
}

14
if [ "$PLAT" == "arm64" ] || [ "$PLAT" == "universal2" ]; then
15
  if [[ "$(check_sdk_11)" == "not found"  ]]; then
Andrew Murray's avatar
Andrew Murray committed
16
17
18
    latestXcode=$(ls /Applications | grep Xcode[_0-9\.]*\.app | sort -V | tail -n 1)
    if ([ "$GITHUB_WORKFLOW" != "" ] || [ "$PIPELINE_WORKSPACE" != "" ]) && [ $latestXcode ]; then
      sudo xcode-select -switch /Applications/$latestXcode.app
19
    fi
20
    if [[ "$(check_sdk_11)" == "not found" ]]; then
21
22
23
24
25
      echo "Need SDK>=11 for arm64 builds. Please run xcode-select to select a newer SDK"
      exit 1
    fi
  fi
  export SDKROOT=${SDKROOT:-$(xcrun -show-sdk-path)}
26
27
fi

28
# Get needed utilities
29
MULTIBUILD_DIR=$(dirname "${BASH_SOURCE[0]}")
30
MB_PYTHON_VERSION=${MB_PYTHON_VERSION:-$TRAVIS_PYTHON_VERSION}
31
32
33

ENV_VARS_PATH=${ENV_VARS_PATH:-env_vars.sh}

34
# These load common_utils.sh
Matthew Brett's avatar
Matthew Brett committed
35
source $MULTIBUILD_DIR/osx_utils.sh
36
37
MB_PYTHON_OSX_VER=${MB_PYTHON_OSX_VER:-$(macpython_sdk_for_version $MB_PYTHON_VERSION)}

38
if [ -r "$ENV_VARS_PATH" ]; then source "$ENV_VARS_PATH"; fi
39
source $MULTIBUILD_DIR/configure_build.sh
40
source $MULTIBUILD_DIR/library_builders.sh
41

42
43
# NB - config.sh sourced at end of this function.
# config.sh can override any function defined here.
44
45
46
47

function before_install {
    export CC=clang
    export CXX=clang++
48

49
    get_macpython_environment $MB_PYTHON_VERSION venv
50
51
52
53
    source venv/bin/activate
    pip install --upgrade pip wheel
}

54
# build_wheel function defined in common_utils (via osx_utils)
55
# install_run function defined in common_utils
56
57

# Local configuration may define custom pre-build, source patching.
58
# It can also overwrite the functions above.
59
60
CONFIG_PATH=${CONFIG_PATH:-config.sh}
source "$CONFIG_PATH"