From 0d84d722b8ce39e49e6e98ec557f95ade16614c4 Mon Sep 17 00:00:00 2001 From: HALX99 Date: Wed, 7 Oct 2020 22:45:05 +0800 Subject: [PATCH] Use pyenv manage python version for travis-ci (#229) --- .travis.yml | 11 +++------- download-deps.py | 6 +++++ setup.py | 6 +++++ tools/appveyor-scripts/setup_android.py | 6 +++++ tools/travis-scripts/before-install.sh | 29 ++++++++++++++++++++----- 5 files changed, 44 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index ce08b0f896..30cd9d5214 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,4 @@ language: cpp -python: - - "2.7.12" -android: - licenses: - - android-sdk-preview-license-.+ - - android-sdk-license-.+ - - google-gdk-license-.+ jobs: include: # osx @@ -19,7 +12,9 @@ jobs: # android - os: linux dist: xenial - env: BUILD_TARGET=android + env: + - BUILD_TARGET=android + - PYENV_VERSION=2.7.18 language: android # linux - os: linux diff --git a/download-deps.py b/download-deps.py index 800bc3dcbe..067b9c07e5 100755 --- a/download-deps.py +++ b/download-deps.py @@ -44,6 +44,7 @@ import traceback import distutils import fileinput import json +import ssl from optparse import OptionParser from time import time @@ -350,6 +351,11 @@ def _check_python_version(): 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__)) if not _check_python_version(): diff --git a/setup.py b/setup.py index ebc01264b9..d2788a4796 100755 --- a/setup.py +++ b/setup.py @@ -53,6 +53,12 @@ import sys import fileinput import shutil 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 COCOS_CONSOLE_ROOT = 'COCOS_CONSOLE_ROOT' diff --git a/tools/appveyor-scripts/setup_android.py b/tools/appveyor-scripts/setup_android.py index f0d89e2ce1..cc01d30d20 100644 --- a/tools/appveyor-scripts/setup_android.py +++ b/tools/appveyor-scripts/setup_android.py @@ -10,6 +10,12 @@ import sys import subprocess import tempfile 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 DIR_PATH = os.path.dirname(os.path.realpath(__file__)) diff --git a/tools/travis-scripts/before-install.sh b/tools/travis-scripts/before-install.sh index 417ae81b7a..757e311259 100755 --- a/tools/travis-scripts/before-install.sh +++ b/tools/travis-scripts/before-install.sh @@ -10,9 +10,13 @@ CURL="curl --retry 999 --retry-max-time 0" function install_android_ndk() { - sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py - sudo python get-pip.py - sudo python -m pip install retry + echo "Installing android ndk ..." + # sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + # sudo python get-pip.py + # sudo python -m pip install retry + which python + which pip + pip install retry if [ "$BUILD_TARGET" == "android" ]\ || [ "$BUILD_TARGET" == "android_lua" ] ; then 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 install ninja-build ninja --version + if [ "$BUILD_TARGET" == "linux" ]; then install_linux_environment fi @@ -78,15 +83,27 @@ function install_environement_for_after_merge() 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 +cmake --version if [ "$BUILD_TARGET" == "android_cocos_new_test" ]; then sudo apt-get update sudo apt-get install ninja-build ninja --version download_deps - sudo python -m pip install retry + sudo pip install retry python $COCOS2DX_ROOT/tools/appveyor-scripts/setup_android.py exit 0 fi @@ -95,7 +112,7 @@ if [ "$BUILD_TARGET" == "linux_cocos_new_test" ]; then download_deps install_linux_environment # 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 exit 0 fi