Default to running tests with Python 3

Specify PY2=1 to use Python 2.

See #1779
Closes #2235
This commit is contained in:
Olly Betts 2022-03-17 15:30:21 +13:00
commit c7af8eabb3
14 changed files with 39 additions and 36 deletions

View file

@ -24,7 +24,7 @@ jobs:
# By default, the name of the build is the language used and SWIG options, but matrix entries # By default, the name of the build is the language used and SWIG options, but matrix entries
# can define the additional "desc" field with any additional information to include in the name. # can define the additional "desc" field with any additional information to include in the name.
name: ${{ matrix.SWIGLANG || 'none' }}${{ matrix.PY3 }} ${{ matrix.ENGINE}} ${{ matrix.VER }} ${{ matrix.SWIG_FEATURES }} ${{ (matrix.compiler || 'gcc') }}${{ matrix.GCC }} ${{ matrix.CPPSTD }} ${{ matrix.CSTD }} ${{ matrix.desc }} ${{ matrix.continue-on-error && '(can fail)' }} name: ${{ matrix.SWIGLANG || 'none' }}${{ matrix.PY2 }} ${{ matrix.ENGINE}} ${{ matrix.VER }} ${{ matrix.SWIG_FEATURES }} ${{ (matrix.compiler || 'gcc') }}${{ matrix.GCC }} ${{ matrix.CPPSTD }} ${{ matrix.CSTD }} ${{ matrix.desc }} ${{ matrix.continue-on-error && '(can fail)' }}
strategy: strategy:
matrix: matrix:
@ -113,45 +113,37 @@ jobs:
- SWIGLANG: php - SWIGLANG: php
VER: '8.1' VER: '8.1'
- SWIGLANG: python - SWIGLANG: python
PY2: 2
- SWIGLANG: python - SWIGLANG: python
PY3: 3
VER: '3.2' VER: '3.2'
os: ubuntu-18.04 # Python < 3.5 not available for 20.04. os: ubuntu-18.04 # Python < 3.5 not available for 20.04.
- SWIGLANG: python - SWIGLANG: python
PY3: 3
VER: '3.3' VER: '3.3'
os: ubuntu-18.04 # Python < 3.5 not available for 20.04. os: ubuntu-18.04 # Python < 3.5 not available for 20.04.
- SWIGLANG: python - SWIGLANG: python
PY3: 3
VER: '3.4' VER: '3.4'
os: ubuntu-18.04 # Python < 3.5 not available for 20.04. os: ubuntu-18.04 # Python < 3.5 not available for 20.04.
- SWIGLANG: python - SWIGLANG: python
PY3: 3
VER: '3.5' VER: '3.5'
- SWIGLANG: python - SWIGLANG: python
PY3: 3
VER: '3.6' VER: '3.6'
- SWIGLANG: python - SWIGLANG: python
PY3: 3
VER: '3.7' VER: '3.7'
- SWIGLANG: python - SWIGLANG: python
PY3: 3
VER: '3.8' VER: '3.8'
- SWIGLANG: python - SWIGLANG: python
PY3: 3
VER: '3.9' VER: '3.9'
- SWIGLANG: python - SWIGLANG: python
PY3: 3
VER: '3.10' VER: '3.10'
- SWIGLANG: python - SWIGLANG: python
PY2: 2
SWIG_FEATURES: -builtin SWIG_FEATURES: -builtin
- SWIGLANG: python - SWIGLANG: python
PY2: 2
SWIG_FEATURES: -builtin -O SWIG_FEATURES: -builtin -O
- SWIGLANG: python - SWIGLANG: python
PY3: 3
SWIG_FEATURES: -builtin SWIG_FEATURES: -builtin
- SWIGLANG: python - SWIGLANG: python
PY3: 3
SWIG_FEATURES: -builtin -O SWIG_FEATURES: -builtin -O
- SWIGLANG: r - SWIGLANG: r
- SWIGLANG: ruby - SWIGLANG: ruby
@ -210,7 +202,6 @@ jobs:
CSTD: gnu11 CSTD: gnu11
- SWIGLANG: python - SWIGLANG: python
CPPSTD: c++11 CPPSTD: c++11
PY3: 3
- SWIGLANG: r - SWIGLANG: r
CPPSTD: c++11 CPPSTD: c++11
- SWIGLANG: ruby - SWIGLANG: ruby
@ -245,7 +236,6 @@ jobs:
CSTD: gnu11 CSTD: gnu11
- SWIGLANG: python - SWIGLANG: python
CPPSTD: c++14 CPPSTD: c++14
PY3: 3
- SWIGLANG: r - SWIGLANG: r
CPPSTD: c++14 CPPSTD: c++14
- SWIGLANG: ruby - SWIGLANG: ruby
@ -290,7 +280,6 @@ jobs:
- SWIGLANG: python - SWIGLANG: python
CPPSTD: c++17 CPPSTD: c++17
GCC: 11 GCC: 11
PY3: 3
- SWIGLANG: r - SWIGLANG: r
CPPSTD: c++17 CPPSTD: c++17
GCC: 11 GCC: 11
@ -314,7 +303,7 @@ jobs:
env: env:
SWIGLANG: ${{ matrix.SWIGLANG }} SWIGLANG: ${{ matrix.SWIGLANG }}
PY3: ${{ matrix.PY3 }} PY2: ${{ matrix.PY2 }}
VER: ${{ matrix.VER }} VER: ${{ matrix.VER }}
ENGINE: ${{ matrix.ENGINE }} ENGINE: ${{ matrix.ENGINE }}
SWIG_FEATURES: ${{ matrix.SWIG_FEATURES }} SWIG_FEATURES: ${{ matrix.SWIG_FEATURES }}

View file

@ -7,6 +7,13 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.1.0 (in progress) Version 4.1.0 (in progress)
=========================== ===========================
2022-03-17: olly
[Python] #1779 SWIG's Python test-suite and examples are now
run with Python 3 by default. To run them with Python 2, set
PY2 to a non-empty value, e.g.:
make check-python-test-suite PY2=1
2022-03-16: olly 2022-03-16: olly
[Go] #683 -intgosize is now optional - if not specified the [Go] #683 -intgosize is now optional - if not specified the
generated C/C++ wrapper code will use ptrdiff_t for intgo and generated C/C++ wrapper code will use ptrdiff_t for intgo and

View file

@ -309,7 +309,7 @@ perl5_clean:
PYTHON_FLAGS = PYTHON_FLAGS =
# Make sure these locate your Python installation # Make sure these locate your Python installation
ifeq (,$(PY3)) ifneq (,$(PY2))
PYTHON_INCLUDE= $(DEFS) @PYINCLUDE@ PYTHON_INCLUDE= $(DEFS) @PYINCLUDE@
PYTHON_LIB = @PYLIB@ PYTHON_LIB = @PYLIB@
PYTHON = @PYTHON@ $(PYTHON_FLAGS) PYTHON = @PYTHON@ $(PYTHON_FLAGS)
@ -320,7 +320,7 @@ else
endif endif
# Extra Python specific linking options # Extra Python specific linking options
ifeq (,$(PY3)) ifneq (,$(PY2))
PYTHON_DLNK = @PYTHONDYNAMICLINKING@ PYTHON_DLNK = @PYTHONDYNAMICLINKING@
PYTHON_LINK = @PYLINK@ PYTHON_LINK = @PYLINK@
else else
@ -330,7 +330,7 @@ endif
PYTHON_SO = @PYTHON_SO@ PYTHON_SO = @PYTHON_SO@
# SWIG option for Python3 # SWIG option for Python3
ifeq (,$(PY3)) ifneq (,$(PY2))
SWIGOPTPY3 = SWIGOPTPY3 =
else else
SWIGOPTPY3 = -py3 SWIGOPTPY3 = -py3

View file

@ -1,7 +1,7 @@
TOP = ../../.. TOP = ../../..
LIBS = LIBS =
ifeq (,$(PY3)) ifneq (,$(PY2))
PKG1DIR = "py2" PKG1DIR = "py2"
else else
PKG1DIR = "py3" PKG1DIR = "py3"

View file

@ -1,7 +1,7 @@
TOP = ../../.. TOP = ../../..
LIBS = LIBS =
ifeq (,$(PY3)) ifneq (,$(PY2))
PKG1DIR = "py2" PKG1DIR = "py2"
else else
PKG1DIR = "py3" PKG1DIR = "py3"

View file

@ -1,7 +1,7 @@
TOP = ../../.. TOP = ../../..
LIBS = LIBS =
ifeq (,$(PY3)) ifneq (,$(PY2))
PKG1DIR = "py2" PKG1DIR = "py2"
else else
PKG1DIR = "py3" PKG1DIR = "py3"

View file

@ -1,7 +1,7 @@
TOP = ../../.. TOP = ../../..
LIBS = LIBS =
ifeq (,$(PY3)) ifneq (,$(PY2))
PKG1DIR = "py2" PKG1DIR = "py2"
else else
PKG1DIR = "py3" PKG1DIR = "py3"

View file

@ -1,7 +1,7 @@
TOP = ../../.. TOP = ../../..
LIBS = LIBS =
ifeq (,$(PY3)) ifneq (,$(PY2))
PKG1DIR = "py2" PKG1DIR = "py2"
else else
PKG1DIR = "py3" PKG1DIR = "py3"

View file

@ -1,7 +1,7 @@
TOP = ../../.. TOP = ../../..
LIBS = LIBS =
ifeq (,$(PY3)) ifneq (,$(PY2))
PKG1DIR = "py2" PKG1DIR = "py2"
else else
PKG1DIR = "py3" PKG1DIR = "py3"

View file

@ -88,7 +88,7 @@ to look at the <a href="http://www.python.org/sigs/distutils-sig/">distutils</a>
<h2>Compatibility</h2> <h2>Compatibility</h2>
For Python 3, set the environment variable <tt>PY3=1</tt>. For Python 2, set the environment variable <tt>PY2=1</tt>.
<p> <p>
Your mileage may vary. If you experience a problem, please let us know by Your mileage may vary. If you experience a problem, please let us know by

View file

@ -2,7 +2,7 @@
# Makefile for python test-suite # Makefile for python test-suite
####################################################################### #######################################################################
ifeq (,$(PY3)) ifneq (,$(PY2))
PYBIN = @PYTHON@ PYBIN = @PYTHON@
else else
PYBIN = @PYTHON3@ PYBIN = @PYTHON3@

View file

@ -4,5 +4,6 @@ Any testcases which have _runme.py appended after the testcase name will be dete
The _runme.py files needs to work for both Python 2.x and 3.x. The _runme.py files needs to work for both Python 2.x and 3.x.
You can run make with PY3=y to run test case with Python 3.x, eg. By default testcases are run with Python 3. You can run make with PY2=1 to run test case with Python 2, eg.
$ make voidtest.cpptest PY3=y
$ make voidtest.cpptest PY2=1

View file

@ -98,14 +98,20 @@ case "$SWIGLANG" in
;; ;;
"python") "python")
pip install --user pycodestyle pip install --user pycodestyle
if [[ "$PY2" ]]; then
WITHLANG=$SWIGLANG
else
WITHLANG=${SWIGLANG}3
fi
if [[ "$VER" ]]; then if [[ "$VER" ]]; then
$RETRY sudo add-apt-repository -y ppa:deadsnakes/ppa $RETRY sudo add-apt-repository -y ppa:deadsnakes/ppa
$RETRY sudo apt-get -qq update $RETRY sudo apt-get -qq update
$RETRY sudo apt-get -qq install python${VER}-dev $RETRY sudo apt-get -qq install python${VER}-dev
WITHLANG=$SWIGLANG$PY3=$SWIGLANG$VER WITHLANG=$WITHLANG=$SWIGLANG$VER
elif [[ "$PY2" ]]; then
$RETRY sudo apt-get install -qq python-dev
else else
$RETRY sudo apt-get install -qq python${PY3}-dev $RETRY sudo apt-get install -qq python3-dev
WITHLANG=$SWIGLANG$PY3
fi fi
;; ;;
"r") "r")

View file

@ -23,18 +23,18 @@ environment:
- SWIGLANG: python - SWIGLANG: python
VSVER: 14 VSVER: 14
VER: 27 VER: 27
PY2: 2
- SWIGLANG: python - SWIGLANG: python
VSVER: 15 VSVER: 15
VER: 38 VER: 38
PY3: 3
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- SWIGLANG: python - SWIGLANG: python
VSVER: 16 VSVER: 16
VER: 39 VER: 39
PY3: 3
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- SWIGLANG: python - SWIGLANG: python
OSVARIANT: cygwin OSVARIANT: cygwin
PY2: 2
- SWIGLANG: java - SWIGLANG: java
OSVARIANT: mingw OSVARIANT: mingw
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
@ -42,7 +42,6 @@ environment:
OSVARIANT: mingw OSVARIANT: mingw
WITHLANG: python WITHLANG: python
VER: 37 VER: 37
PY3: 3
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- BUILDSYSTEM: cmake - BUILDSYSTEM: cmake
VSVER: 14 VSVER: 14
@ -51,6 +50,7 @@ matrix:
allow_failures: allow_failures:
- SWIGLANG: python - SWIGLANG: python
OSVARIANT: cygwin OSVARIANT: cygwin
PY2: 2
# Skip stale commits (pull requests only), see https://github.com/appveyor/ci/issues/38#issuecomment-70628826 # Skip stale commits (pull requests only), see https://github.com/appveyor/ci/issues/38#issuecomment-70628826
init: init:
@ -154,7 +154,7 @@ build_script:
- if "%OSVARIANT%"=="" bash -c "exec 0</dev/null && cd pcre2-pcre2-10.39 && ./autogen.sh && ./configure CC=$CC CXX=$CXX CFLAGS='-O2' LDFLAGS='--cccl-link /LTCG' --prefix=%PCRE_ROOT% --disable-shared && time make -s -j%MAKEJOBS% LN_S=cp && make install && cd .. && cp -v %PCRE_ROOT%/lib/libpcre2-8.lib %PCRE_ROOT%/lib/pcre2-8.lib" - if "%OSVARIANT%"=="" bash -c "exec 0</dev/null && cd pcre2-pcre2-10.39 && ./autogen.sh && ./configure CC=$CC CXX=$CXX CFLAGS='-O2' LDFLAGS='--cccl-link /LTCG' --prefix=%PCRE_ROOT% --disable-shared && time make -s -j%MAKEJOBS% LN_S=cp && make install && cd .. && cp -v %PCRE_ROOT%/lib/libpcre2-8.lib %PCRE_ROOT%/lib/pcre2-8.lib"
# Open dummy file descriptor to fix error on cygwin: ./configure: line 560: 0: Bad file descriptor # Open dummy file descriptor to fix error on cygwin: ./configure: line 560: 0: Bad file descriptor
- if "%OSVARIANT%"=="" bash -c "exec 0</dev/null && ./autogen.sh && time ./configure --disable-dependency-tracking --disable-ccache --enable-cpp11-testing CC=$CC CXX=$CXX CFLAGS='-O2' CXXFLAGS='-O2' LDFLAGS='--cccl-link /LTCG' PCRE2_CFLAGS='-I%PCRE_ROOT%/include -DPCRE2_STATIC' PCRE2_LIBS='-L%PCRE_ROOT%/lib/ -lpcre2-8' --without-perl5 --without-go --with-boost=%BOOSTROOT% || cat config.log" - if "%OSVARIANT%"=="" bash -c "exec 0</dev/null && ./autogen.sh && time ./configure --disable-dependency-tracking --disable-ccache --enable-cpp11-testing CC=$CC CXX=$CXX CFLAGS='-O2' CXXFLAGS='-O2' LDFLAGS='--cccl-link /LTCG' PCRE2_CFLAGS='-I%PCRE_ROOT%/include -DPCRE2_STATIC' PCRE2_LIBS='-L%PCRE_ROOT%/lib/ -lpcre2-8' --without-perl5 --without-go --with-boost=%BOOSTROOT% || cat config.log"
- if not "%OSVARIANT%"=="" bash -c "exec 0</dev/null && ./autogen.sh && time ./configure CC=%CC% CXX=%CXX% --without-alllang --with-$SWIGLANG$PY3$SWIGWITHLANG --enable-cpp11-testing || cat config.log" - if not "%OSVARIANT%"=="" bash -c "exec 0</dev/null && ./autogen.sh && x=${PY2:-x3} && PY3=${x:1} && time ./configure CC=%CC% CXX=%CXX% --without-alllang --with-$SWIGLANG$PY3$SWIGWITHLANG --enable-cpp11-testing || cat config.log"
- bash -c "time make -s -j%MAKEJOBS%" - bash -c "time make -s -j%MAKEJOBS%"
test_script: test_script: