Skip to content

Commit c83fd44

Browse files
authored
Introduce new shell syntax for ci-run.sh to improve Windows support (cythonGH-4400)
1 parent c8c9a12 commit c83fd44

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

Tools/ci-run.sh

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
GCC_VERSION=${GCC_VERSION:=8}
44

55
# Set up compilers
6-
if [ "$TEST_CODE_STYLE" == "1" ]; then
6+
if [[ $TEST_CODE_STYLE == "1" ]]; then
77
echo "Skipping compiler setup"
8-
elif [ "${OSTYPE##linux-gnu*}" == "" ]; then
8+
elif [[ $OSTYPE == "linux-gnu"* ]]; then
99
echo "Setting up linux compiler"
1010
echo "Installing requirements [apt]"
1111
sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
1212
sudo apt update -y -q
1313
sudo apt install -y -q ccache gdb python-dbg python3-dbg gcc-$GCC_VERSION || exit 1
1414

1515
ALTERNATIVE_ARGS=""
16-
if [ -z "${BACKEND##*cpp*}" ]; then
16+
if [[ $BACKEND == *"cpp"* ]]; then
1717
sudo apt install -y -q g++-$GCC_VERSION || exit 1
1818
ALTERNATIVE_ARGS="--slave /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION"
1919
fi
@@ -23,11 +23,11 @@ elif [ "${OSTYPE##linux-gnu*}" == "" ]; then
2323
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 60 $ALTERNATIVE_ARGS
2424

2525
export CC="gcc"
26-
if [ -z "${BACKEND##*cpp*}" ]; then
26+
if [[ $BACKEND == *"cpp"* ]]; then
2727
sudo update-alternatives --set g++ /usr/bin/g++-$GCC_VERSION
2828
export CXX="g++"
2929
fi
30-
elif [ "${OSTYPE##darwin*}" == "" ]; then
30+
elif [[ $OSTYPE == "darwin"* ]]; then
3131
echo "Setting up macos compiler"
3232
export CC="clang -Wno-deprecated-declarations"
3333
export CXX="clang++ -stdlib=libc++ -Wno-deprecated-declarations"
@@ -36,7 +36,7 @@ else
3636
fi
3737

3838
# Set up miniconda
39-
if [ "$STACKLESS" == "true" ]; then
39+
if [[ $STACKLESS == "true" ]]; then
4040
echo "Installing stackless python"
4141
#conda install --quiet --yes nomkl --file=test-requirements.txt --file=test-requirements-cpython.txt
4242
conda config --add channels stackless
@@ -50,51 +50,51 @@ echo "===================="
5050
echo "|VERSIONS INSTALLED|"
5151
echo "===================="
5252
echo "Python $PYTHON_SYS_VERSION"
53-
if [ "$CC" ]; then
53+
if [[ $CC ]]; then
5454
which ${CC%% *}
5555
${CC%% *} --version
5656
fi
57-
if [ "$CXX" ]; then
57+
if [[ $CXX ]]; then
5858
which ${CXX%% *}
5959
${CXX%% *} --version
6060
fi
6161
echo "===================="
6262

6363
# Install python requirements
6464
echo "Installing requirements [python]"
65-
if [ -z "${PYTHON_VERSION##2.7}" ]; then
65+
if [[ $PYTHON_VERSION == "2.7"* ]]; then
6666
pip install wheel || exit 1
6767
pip install -r test-requirements-27.txt || exit 1
68-
elif [ -z "${PYTHON_VERSION##3.[45]*}" ]; then
68+
elif [[ $PYTHON_VERSION == "3."[45]* ]]; then
6969
python -m pip install wheel || exit 1
7070
python -m pip install -r test-requirements-34.txt || exit 1
7171
else
7272
python -m pip install -U pip setuptools wheel || exit 1
7373

74-
if [ -n "${PYTHON_VERSION##*-dev}" -o "$COVERAGE" == "1" ]; then
74+
if [[ $PYTHON_VERSION != *"-dev" || $COVERAGE == "1" ]]; then
7575
python -m pip install -r test-requirements.txt || exit 1
7676

77-
if [ "${PYTHON_VERSION##pypy*}" -a "${PYTHON_VERSION##3.[4789]*}" ]; then
77+
if [[ $PYTHON_VERSION != "pypy"* && $PYTHON_VERSION != "3."[4789]* ]]; then
7878
python -m pip install -r test-requirements-cpython.txt || exit 1
7979
fi
8080
fi
8181
fi
8282

83-
if [ "$TEST_CODE_STYLE" == "1" ]; then
84-
STYLE_ARGS="--no-unit --no-doctest --no-file --no-pyregr --no-examples";
83+
if [[ $TEST_CODE_STYLE == "1" ]]; then
84+
STYLE_ARGS="--no-unit --no-doctest --no-file --no-pyregr --no-examples"
8585
python -m pip install -r doc-requirements.txt || exit 1
8686
else
8787
STYLE_ARGS="--no-code-style"
8888

8989
# Install more requirements
90-
if [ -n "${PYTHON_VERSION##*-dev}" ]; then
91-
if [ -z "${BACKEND##*cpp*}" ]; then
90+
if [[ $PYTHON_VERSION != *"-dev" ]]; then
91+
if [[ $BACKEND == *"cpp"* ]]; then
9292
echo "WARNING: Currently not installing pythran due to compatibility issues"
9393
# python -m pip install pythran==0.9.5 || exit 1
9494
fi
9595

96-
if [ "$BACKEND" != "cpp" -a -n "${PYTHON_VERSION##pypy*}" -a
97-
-n "${PYTHON_VERSION##2*}" -a -n "${PYTHON_VERSION##3.4*}" ]; then
96+
if [[ $BACKEND != "cpp" && $PYTHON_VERSION != "pypy"* &&
97+
$PYTHON_VERSION != "2"* && $PYTHON_VERSION != "3.4"* ]]; then
9898
python -m pip install mypy || exit 1
9999
fi
100100
fi
@@ -110,18 +110,18 @@ export PATH="/usr/lib/ccache:$PATH"
110110
# This is true for the latest msvc, gcc and clang
111111
CFLAGS="-O0 -ggdb -Wall -Wextra"
112112

113-
if [ "$NO_CYTHON_COMPILE" != "1" -a -n "${PYTHON_VERSION##pypy*}" ]; then
113+
if [[ $NO_CYTHON_COMPILE != "1" && $PYTHON_VERSION != "pypy"* ]]; then
114114

115115
BUILD_CFLAGS="$CFLAGS -O2"
116116
if [[ $PYTHON_SYS_VERSION == "2"* ]]; then
117117
BUILD_CFLAGS="$BUILD_CFLAGS -fno-strict-aliasing"
118118
fi
119119

120120
SETUP_ARGS=""
121-
if [ "$COVERAGE" == "1" ]; then
121+
if [[ $COVERAGE == "1" ]]; then
122122
SETUP_ARGS="$SETUP_ARGS --cython-coverage"
123123
fi
124-
if [ "$CYTHON_COMPILE_ALL" == "1" ]; then
124+
if [[ $CYTHON_COMPILE_ALL == "1" ]]; then
125125
SETUP_ARGS="$SETUP_ARGS --cython-compile-all"
126126
fi
127127
SETUP_ARGS="$SETUP_ARGS
@@ -130,15 +130,18 @@ if [ "$NO_CYTHON_COMPILE" != "1" -a -n "${PYTHON_VERSION##pypy*}" ]; then
130130
CFLAGS=$BUILD_CFLAGS \
131131
python setup.py build_ext -i $SETUP_ARGS || exit 1
132132

133-
if [ -z "$COVERAGE" -a -z "$STACKLESS" -a -n "${BACKEND//*cpp*}" -a
134-
-z "$LIMITED_API" -a -z "$CYTHON_COMPILE_ALL" -a -z "$EXTRA_CFLAGS" ]; then
133+
# COVERAGE can be either "" (empty or not set) or "1" (when we set it)
134+
# STACKLESS can be either "" (empty or not set) or "true" (when we set it)
135+
# CYTHON_COMPILE_ALL can be either "" (empty or not set) or "1" (when we set it)
136+
if [[ $COVERAGE != "1" && $STACKLESS != "true" && $BACKEND != *"cpp"* &&
137+
$CYTHON_COMPILE_ALL != "1" && $LIMITED_API == "" && $EXTRA_CFLAGS == "" ]]; then
135138
python setup.py bdist_wheel || exit 1
136139
fi
137140
fi
138141

139-
if [ "$TEST_CODE_STYLE" == "1" ]; then
140-
make -C docs html || exit 1
141-
elif [ -n "${PYTHON_VERSION##pypy*}" ]; then
142+
if [[ $TEST_CODE_STYLE == "1" ]]; then
143+
make -C docs html || exit 1
144+
elif [[ $PYTHON_VERSION != "pypy"* ]]; then
142145
# Run the debugger tests in python-dbg if available
143146
# (but don't fail, because they currently do fail)
144147
PYTHON_DBG=$(python -c 'import sys; print("%d.%d" % sys.version_info[:2])')
@@ -150,10 +153,10 @@ elif [ -n "${PYTHON_VERSION##pypy*}" ]; then
150153
fi
151154

152155
RUNTESTS_ARGS=""
153-
if [ "$COVERAGE" == "1" ]; then
156+
if [[ $COVERAGE == "1" ]]; then
154157
RUNTESTS_ARGS="$RUNTESTS_ARGS --coverage --coverage-html --cython-only"
155158
fi
156-
if [ -z "$TEST_CODE_STYLE" ]; then
159+
if [[ $TEST_CODE_STYLE != "1" ]]; then
157160
RUNTESTS_ARGS="$RUNTESTS_ARGS -j7"
158161
fi
159162

0 commit comments

Comments
 (0)