diff --git a/.travis.yml b/.travis.yml index 91d77aca954e6..ee531af5757cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,15 @@ matrix: - os: osx osx_image: xcode10.3 env: - - MATRIX_EVAL="CC=clang && CXX=clang++ && PYTHON=python3.7" + - MATRIX_EVAL="CC=clang && CXX=clang++ && PYTHON_VERSION=3.6.1 && PYTHON=python" + - os: osx + osx_image: xcode10.3 + env: + - MATRIX_EVAL="CC=clang && CXX=clang++ && PYTHON_VERSION=3.7.1 && PYTHON=python" + - os: osx + osx_image: xcode10.3 + env: + - MATRIX_EVAL="CC=clang && CXX=clang++ && PYTHON_VERSION=3.8.1 && PYTHON=python" before_install: - eval "${MATRIX_EVAL}" @@ -26,8 +34,12 @@ before_install: - cd .. - llvm-config --version +install: +- .travis/install.sh + script: - cd $TRAVIS_BUILD_DIR +- export PATH="$HOME/.pyenv/shims:$HOME/.pyenv/bin:$PATH" - $PYTHON ci_setup.py ci - export TAICHI_REPO_DIR=$TRAVIS_BUILD_DIR - export PYTHONPATH=$TAICHI_REPO_DIR/python diff --git a/.travis/install.sh b/.travis/install.sh new file mode 100755 index 0000000000000..5e1ea0571f20a --- /dev/null +++ b/.travis/install.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# use brew & pyenv to build specific python on osx +if [[ $TRAVIS_OS_NAME == 'osx' ]]; then + export PATH="$HOME/.pyenv/bin:$PATH" + eval "${MATRIX_EVAL}" + echo "python version: $PYTHON_VERSION" + brew update > /dev/null + brew upgrade pyenv + # use pyenv to build python + eval "$(pyenv init -)" + pyenv install $PYTHON_VERSION + pyenv global $PYTHON_VERSION + pyenv rehash +fi diff --git a/ci_setup.py b/ci_setup.py index 99a57716d26e5..cea8331237c88 100644 --- a/ci_setup.py +++ b/ci_setup.py @@ -70,7 +70,9 @@ def execute_command(line, allow_nonzero_output = 0): def get_os_name(): name = platform.platform() - if name.lower().startswith('darwin'): + # in python 3.8, platform.platform() uses mac_ver() on macOS + # it will return 'macOS-XXXX' instead of 'Darwin-XXXX' + if name.lower().startswith('darwin') or name.lower().startswith('macos'): return 'osx' elif name.lower().startswith('windows'): return 'win' diff --git a/python/build.py b/python/build.py index 6e84be6333d0e..75c9a848fd002 100644 --- a/python/build.py +++ b/python/build.py @@ -35,7 +35,9 @@ def get_os_name(): name = platform.platform() - if name.lower().startswith('darwin'): + # in python 3.8, platform.platform() uses mac_ver() on macOS + # it will return 'macOS-XXXX' instead of 'Darwin-XXXX' + if name.lower().startswith('darwin') or name.lower().startswith('macos'): return 'osx' elif name.lower().startswith('windows'): return 'win' diff --git a/python/taichi/misc/util.py b/python/taichi/misc/util.py index b79f9e2f1b492..d7f520b638726 100644 --- a/python/taichi/misc/util.py +++ b/python/taichi/misc/util.py @@ -6,7 +6,9 @@ def get_os_name(): name = platform.platform() - if name.lower().startswith('darwin'): + # in python 3.8, platform.platform() uses mac_ver() on macOS + # it will return 'macOS-XXXX' instead of 'Darwin-XXXX' + if name.lower().startswith('darwin') or name.lower().startswith('macos'): return 'osx' elif name.lower().startswith('windows'): return 'win'