From c83fd4414c154503e596e5a06a06309a6a91d1fa Mon Sep 17 00:00:00 2001 From: 0dminnimda <0dminnimda@gmail.com> Date: Fri, 22 Oct 2021 21:44:11 +0300 Subject: Introduce new shell syntax for ci-run.sh to improve Windows support (GH-4400) --- Tools/ci-run.sh | 59 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/Tools/ci-run.sh b/Tools/ci-run.sh index 34519c793..e8d4c7a96 100644 --- a/Tools/ci-run.sh +++ b/Tools/ci-run.sh @@ -3,9 +3,9 @@ GCC_VERSION=${GCC_VERSION:=8} # Set up compilers -if [ "$TEST_CODE_STYLE" == "1" ]; then +if [[ $TEST_CODE_STYLE == "1" ]]; then echo "Skipping compiler setup" -elif [ "${OSTYPE##linux-gnu*}" == "" ]; then +elif [[ $OSTYPE == "linux-gnu"* ]]; then echo "Setting up linux compiler" echo "Installing requirements [apt]" sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test" @@ -13,7 +13,7 @@ elif [ "${OSTYPE##linux-gnu*}" == "" ]; then sudo apt install -y -q ccache gdb python-dbg python3-dbg gcc-$GCC_VERSION || exit 1 ALTERNATIVE_ARGS="" - if [ -z "${BACKEND##*cpp*}" ]; then + if [[ $BACKEND == *"cpp"* ]]; then sudo apt install -y -q g++-$GCC_VERSION || exit 1 ALTERNATIVE_ARGS="--slave /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION" fi @@ -23,11 +23,11 @@ elif [ "${OSTYPE##linux-gnu*}" == "" ]; then sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 60 $ALTERNATIVE_ARGS export CC="gcc" - if [ -z "${BACKEND##*cpp*}" ]; then + if [[ $BACKEND == *"cpp"* ]]; then sudo update-alternatives --set g++ /usr/bin/g++-$GCC_VERSION export CXX="g++" fi -elif [ "${OSTYPE##darwin*}" == "" ]; then +elif [[ $OSTYPE == "darwin"* ]]; then echo "Setting up macos compiler" export CC="clang -Wno-deprecated-declarations" export CXX="clang++ -stdlib=libc++ -Wno-deprecated-declarations" @@ -36,7 +36,7 @@ else fi # Set up miniconda -if [ "$STACKLESS" == "true" ]; then +if [[ $STACKLESS == "true" ]]; then echo "Installing stackless python" #conda install --quiet --yes nomkl --file=test-requirements.txt --file=test-requirements-cpython.txt conda config --add channels stackless @@ -50,11 +50,11 @@ echo "====================" echo "|VERSIONS INSTALLED|" echo "====================" echo "Python $PYTHON_SYS_VERSION" -if [ "$CC" ]; then +if [[ $CC ]]; then which ${CC%% *} ${CC%% *} --version fi -if [ "$CXX" ]; then +if [[ $CXX ]]; then which ${CXX%% *} ${CXX%% *} --version fi @@ -62,39 +62,39 @@ echo "====================" # Install python requirements echo "Installing requirements [python]" -if [ -z "${PYTHON_VERSION##2.7}" ]; then +if [[ $PYTHON_VERSION == "2.7"* ]]; then pip install wheel || exit 1 pip install -r test-requirements-27.txt || exit 1 -elif [ -z "${PYTHON_VERSION##3.[45]*}" ]; then +elif [[ $PYTHON_VERSION == "3."[45]* ]]; then python -m pip install wheel || exit 1 python -m pip install -r test-requirements-34.txt || exit 1 else python -m pip install -U pip setuptools wheel || exit 1 - if [ -n "${PYTHON_VERSION##*-dev}" -o "$COVERAGE" == "1" ]; then + if [[ $PYTHON_VERSION != *"-dev" || $COVERAGE == "1" ]]; then python -m pip install -r test-requirements.txt || exit 1 - if [ "${PYTHON_VERSION##pypy*}" -a "${PYTHON_VERSION##3.[4789]*}" ]; then + if [[ $PYTHON_VERSION != "pypy"* && $PYTHON_VERSION != "3."[4789]* ]]; then python -m pip install -r test-requirements-cpython.txt || exit 1 fi fi fi -if [ "$TEST_CODE_STYLE" == "1" ]; then - STYLE_ARGS="--no-unit --no-doctest --no-file --no-pyregr --no-examples"; +if [[ $TEST_CODE_STYLE == "1" ]]; then + STYLE_ARGS="--no-unit --no-doctest --no-file --no-pyregr --no-examples" python -m pip install -r doc-requirements.txt || exit 1 else STYLE_ARGS="--no-code-style" # Install more requirements - if [ -n "${PYTHON_VERSION##*-dev}" ]; then - if [ -z "${BACKEND##*cpp*}" ]; then + if [[ $PYTHON_VERSION != *"-dev" ]]; then + if [[ $BACKEND == *"cpp"* ]]; then echo "WARNING: Currently not installing pythran due to compatibility issues" # python -m pip install pythran==0.9.5 || exit 1 fi - if [ "$BACKEND" != "cpp" -a -n "${PYTHON_VERSION##pypy*}" -a - -n "${PYTHON_VERSION##2*}" -a -n "${PYTHON_VERSION##3.4*}" ]; then + if [[ $BACKEND != "cpp" && $PYTHON_VERSION != "pypy"* && + $PYTHON_VERSION != "2"* && $PYTHON_VERSION != "3.4"* ]]; then python -m pip install mypy || exit 1 fi fi @@ -110,7 +110,7 @@ export PATH="/usr/lib/ccache:$PATH" # This is true for the latest msvc, gcc and clang CFLAGS="-O0 -ggdb -Wall -Wextra" -if [ "$NO_CYTHON_COMPILE" != "1" -a -n "${PYTHON_VERSION##pypy*}" ]; then +if [[ $NO_CYTHON_COMPILE != "1" && $PYTHON_VERSION != "pypy"* ]]; then BUILD_CFLAGS="$CFLAGS -O2" if [[ $PYTHON_SYS_VERSION == "2"* ]]; then @@ -118,10 +118,10 @@ if [ "$NO_CYTHON_COMPILE" != "1" -a -n "${PYTHON_VERSION##pypy*}" ]; then fi SETUP_ARGS="" - if [ "$COVERAGE" == "1" ]; then + if [[ $COVERAGE == "1" ]]; then SETUP_ARGS="$SETUP_ARGS --cython-coverage" fi - if [ "$CYTHON_COMPILE_ALL" == "1" ]; then + if [[ $CYTHON_COMPILE_ALL == "1" ]]; then SETUP_ARGS="$SETUP_ARGS --cython-compile-all" fi SETUP_ARGS="$SETUP_ARGS @@ -130,15 +130,18 @@ if [ "$NO_CYTHON_COMPILE" != "1" -a -n "${PYTHON_VERSION##pypy*}" ]; then CFLAGS=$BUILD_CFLAGS \ python setup.py build_ext -i $SETUP_ARGS || exit 1 - if [ -z "$COVERAGE" -a -z "$STACKLESS" -a -n "${BACKEND//*cpp*}" -a - -z "$LIMITED_API" -a -z "$CYTHON_COMPILE_ALL" -a -z "$EXTRA_CFLAGS" ]; then + # COVERAGE can be either "" (empty or not set) or "1" (when we set it) + # STACKLESS can be either "" (empty or not set) or "true" (when we set it) + # CYTHON_COMPILE_ALL can be either "" (empty or not set) or "1" (when we set it) + if [[ $COVERAGE != "1" && $STACKLESS != "true" && $BACKEND != *"cpp"* && + $CYTHON_COMPILE_ALL != "1" && $LIMITED_API == "" && $EXTRA_CFLAGS == "" ]]; then python setup.py bdist_wheel || exit 1 fi fi -if [ "$TEST_CODE_STYLE" == "1" ]; then - make -C docs html || exit 1 -elif [ -n "${PYTHON_VERSION##pypy*}" ]; then +if [[ $TEST_CODE_STYLE == "1" ]]; then + make -C docs html || exit 1 +elif [[ $PYTHON_VERSION != "pypy"* ]]; then # Run the debugger tests in python-dbg if available # (but don't fail, because they currently do fail) PYTHON_DBG=$(python -c 'import sys; print("%d.%d" % sys.version_info[:2])') @@ -150,10 +153,10 @@ elif [ -n "${PYTHON_VERSION##pypy*}" ]; then fi RUNTESTS_ARGS="" -if [ "$COVERAGE" == "1" ]; then +if [[ $COVERAGE == "1" ]]; then RUNTESTS_ARGS="$RUNTESTS_ARGS --coverage --coverage-html --cython-only" fi -if [ -z "$TEST_CODE_STYLE" ]; then +if [[ $TEST_CODE_STYLE != "1" ]]; then RUNTESTS_ARGS="$RUNTESTS_ARGS -j7" fi -- cgit v1.2.1