Use pyenv manage python version for travis-ci (#229)

This commit is contained in:
HALX99 2020-10-07 22:45:05 +08:00 committed by GitHub
parent 7ae50f4cfd
commit 0d84d722b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 14 deletions

View File

@ -1,11 +1,4 @@
language: cpp language: cpp
python:
- "2.7.12"
android:
licenses:
- android-sdk-preview-license-.+
- android-sdk-license-.+
- google-gdk-license-.+
jobs: jobs:
include: include:
# osx # osx
@ -19,7 +12,9 @@ jobs:
# android # android
- os: linux - os: linux
dist: xenial dist: xenial
env: BUILD_TARGET=android env:
- BUILD_TARGET=android
- PYENV_VERSION=2.7.18
language: android language: android
# linux # linux
- os: linux - os: linux

View File

@ -44,6 +44,7 @@ import traceback
import distutils import distutils
import fileinput import fileinput
import json import json
import ssl
from optparse import OptionParser from optparse import OptionParser
from time import time from time import time
@ -350,6 +351,11 @@ def _check_python_version():
def main(): def main():
try:
ssl._create_default_https_context = ssl._create_unverified_context
print("==> set ssl context ok")
except Exception:
pass
workpath = os.path.dirname(os.path.realpath(__file__)) workpath = os.path.dirname(os.path.realpath(__file__))
if not _check_python_version(): if not _check_python_version():

View File

@ -53,6 +53,12 @@ import sys
import fileinput import fileinput
import shutil import shutil
import subprocess import subprocess
import ssl
try:
ssl._create_default_https_context = ssl._create_unverified_context
print("==> setup.py set ssl context ok")
except Exception:
pass
from optparse import OptionParser from optparse import OptionParser
COCOS_CONSOLE_ROOT = 'COCOS_CONSOLE_ROOT' COCOS_CONSOLE_ROOT = 'COCOS_CONSOLE_ROOT'

View File

@ -10,6 +10,12 @@ import sys
import subprocess import subprocess
import tempfile import tempfile
import argparse import argparse
import ssl
try:
ssl._create_default_https_context = ssl._create_unverified_context
print("==> setup_android.py set ssl context ok")
except Exception:
pass
from retry import retry from retry import retry
DIR_PATH = os.path.dirname(os.path.realpath(__file__)) DIR_PATH = os.path.dirname(os.path.realpath(__file__))

View File

@ -10,9 +10,13 @@ CURL="curl --retry 999 --retry-max-time 0"
function install_android_ndk() function install_android_ndk()
{ {
sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py echo "Installing android ndk ..."
sudo python get-pip.py # sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python -m pip install retry # sudo python get-pip.py
# sudo python -m pip install retry
which python
which pip
pip install retry
if [ "$BUILD_TARGET" == "android" ]\ if [ "$BUILD_TARGET" == "android" ]\
|| [ "$BUILD_TARGET" == "android_lua" ] ; then || [ "$BUILD_TARGET" == "android_lua" ] ; then
python $COCOS2DX_ROOT/tools/appveyor-scripts/setup_android.py python $COCOS2DX_ROOT/tools/appveyor-scripts/setup_android.py
@ -52,6 +56,7 @@ function install_environement_for_pull_request()
sudo apt-get update sudo apt-get update
sudo apt-get install ninja-build sudo apt-get install ninja-build
ninja --version ninja --version
if [ "$BUILD_TARGET" == "linux" ]; then if [ "$BUILD_TARGET" == "linux" ]; then
install_linux_environment install_linux_environment
fi fi
@ -78,15 +83,27 @@ function install_environement_for_after_merge()
download_deps download_deps
} }
cmake --version # install newer python for android for ssl connection
if [ "$BUILD_TARGET" == "android" ]; then
# upgrade pyenv
cd $(pyenv root) && git checkout master && git pull && cd -
pyenv install --list
pyenv install $PYENV_VERSION
pyenv versions
# pip install pyOpenSSL ndg-httpsclient pyasn1
# set by PYENV_VERSION environment variable implicit
# pyenv global $PYENV_VERSION
fi
python -V python -V
cmake --version
if [ "$BUILD_TARGET" == "android_cocos_new_test" ]; then if [ "$BUILD_TARGET" == "android_cocos_new_test" ]; then
sudo apt-get update sudo apt-get update
sudo apt-get install ninja-build sudo apt-get install ninja-build
ninja --version ninja --version
download_deps download_deps
sudo python -m pip install retry sudo pip install retry
python $COCOS2DX_ROOT/tools/appveyor-scripts/setup_android.py python $COCOS2DX_ROOT/tools/appveyor-scripts/setup_android.py
exit 0 exit 0
fi fi
@ -95,7 +112,7 @@ if [ "$BUILD_TARGET" == "linux_cocos_new_test" ]; then
download_deps download_deps
install_linux_environment install_linux_environment
# linux new lua project, so need to install # linux new lua project, so need to install
sudo python -m pip install retry sudo pip install retry
python $COCOS2DX_ROOT/tools/appveyor-scripts/setup_android.py --ndk_only python $COCOS2DX_ROOT/tools/appveyor-scripts/setup_android.py --ndk_only
exit 0 exit 0
fi fi