Skip to content

Commit

Permalink
Taichi build on macOS with Python 3.6 to Python 3.8 covered #409 (#513)
Browse files Browse the repository at this point in the history
* try to fix python3.6-3.8 on macOS build

* fix missing env in .travis/install.sh

* try to cover python-3.8.1 build on osx (#409)

* try to cover python 3.8 build on osx, fix ci_setup.py

* fix python/build.py & python/taichi/misc/util.py, platform value issue when using python 3.8
  • Loading branch information
Detavern authored Feb 22, 2020
1 parent 0cc4f3c commit 993d9f4
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
14 changes: 13 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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
Expand Down
15 changes: 15 additions & 0 deletions .travis/install.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion ci_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 3 additions & 1 deletion python/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 3 additions & 1 deletion python/taichi/misc/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 993d9f4

Please sign in to comment.