From 8cf1de4a77572e028a75c54010694257f17724d2 Mon Sep 17 00:00:00 2001 From: is-shidian Date: Sun, 25 Sep 2022 08:29:33 +0800 Subject: [PATCH] fix pyenv python version,pyenv install,file location,file name,and compat for x86_64 and arm64 --- scripts/whl/macos/macos_build_whl.sh | 16 +++++++++++++--- scripts/whl/macos/macos_whl_env_prepare.sh | 16 ++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/scripts/whl/macos/macos_build_whl.sh b/scripts/whl/macos/macos_build_whl.sh index 33b34425a..33b696da2 100755 --- a/scripts/whl/macos/macos_build_whl.sh +++ b/scripts/whl/macos/macos_build_whl.sh @@ -38,7 +38,13 @@ SRC_DIR=$($READLINK -f "`dirname $0`/../../../") source ${SRC_DIR}/scripts/whl/utils/utils.sh ALL_PYTHON=${ALL_PYTHON} -FULL_PYTHON_VER="3.6.10 3.7.7 3.8.3 3.9.4" +platform=$(uname -m | awk '{print $0}') +if [ $platform = 'arm64' ];then + FULL_PYTHON_VER="3.8.10 3.9.4 3.10.1" +else + FULL_PYTHON_VER="3.6.10 3.7.7 3.8.3 3.9.4" +fi + if [[ -z ${ALL_PYTHON} ]] then ALL_PYTHON=${FULL_PYTHON_VER} @@ -76,7 +82,7 @@ function config_python_env() { elif [ "$1" = "3.7.7" ]; then PYTHON_INCLUDE_DIR=${PYTHON_DIR}include/python3.7m PYTHON_LIBRARY=${PYTHON_DIR}/lib/libpython3.7m.dylib - elif [ "$1" = "3.8.3" ]; then + elif [[ "$1" = "3.8.3" || "$1" = "3.8.10" ]]; then PYTHON_INCLUDE_DIR=${PYTHON_DIR}include/python3.8 PYTHON_LIBRARY=${PYTHON_DIR}/lib/libpython3.8.dylib elif [ "$1" = "3.9.4" ]; then @@ -220,7 +226,11 @@ function do_build() { cd ${BUILD_DIR}/staging/dist/ org_whl_name=`ls Meg*.whl` index=`awk -v a="${org_whl_name}" -v b="-macosx" 'BEGIN{print index(a,b)}'` - compat_whl_name=`echo ${org_whl_name} |cut -b -$index`macosx_10_14_x86_64.whl + if [ $platform = 'arm64' ];then + compat_whl_name=`echo ${org_whl_name} |cut -b -$index`macosx_10_14_universal2.whl + else + compat_whl_name=`echo ${org_whl_name} |cut -b -$index`macosx_10_14_x86_64.whl + fi echo "org whl name: ${org_whl_name}" echo "comapt whl name: ${compat_whl_name}" cp ${BUILD_DIR}/staging/dist/Meg*.whl ${MACOS_WHL_HOME}/${compat_whl_name} diff --git a/scripts/whl/macos/macos_whl_env_prepare.sh b/scripts/whl/macos/macos_whl_env_prepare.sh index 9b909cf69..18fcd07db 100755 --- a/scripts/whl/macos/macos_whl_env_prepare.sh +++ b/scripts/whl/macos/macos_whl_env_prepare.sh @@ -45,21 +45,29 @@ fi SRC_DIR=$($READLINK -f "`dirname $0`/../../../") echo ${SRC_DIR} -ALL_PYTHON="3.6.10 3.7.7 3.8.3 3.9.4 3.10.1" + +platform=$(uname -m | awk '{print $0}') +if [ $platform = 'arm64' ];then + ALL_PYTHON="3.8.10 3.9.4 3.10.1" +else + ALL_PYTHON="3.6.10 3.7.7 3.8.3 3.9.4 3.10.1" +fi + USER=$(whoami) function install_python_package() { for pak in ${ALL_PYTHON} do - echo "###### do command: env PYTHON_CONFIGURE_OPTS=\"--enable-shared\" pyenv install ${pak}" + echo "###### do command: env PYTHON_CONFIGURE_OPTS=\"--enable-shared\" PYTHON_CONFIGURE_OPTS=\"--enable-framework\" pyenv install ${pak}" if [ -e /Users/${USER}/.pyenv/versions/${pak} ];then echo "FOUND install /Users/${USER}/.pyenv/versions/${pak} strip it..." else os_ver=$(sw_vers -productVersion | awk '{print int($0)}') - if [ $os_ver -lt 11 ];then - env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install ${pak} + if [[ $os_ver -lt 11 || $platform = 'arm64' ];then + env PYTHON_CONFIGURE_OPTS="--enable-shared" PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install ${pak} else PYTHON_CONFIGURE_OPTS="--enable-shared" \ + PYTHON_CONFIGURE_OPTS="--enable-framework"\ CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include \ -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" \ LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" \ -- GitLab