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
parent 2da3815f99
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
# 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:
matrix:
@ -113,45 +113,37 @@ jobs:
- SWIGLANG: php
VER: '8.1'
- SWIGLANG: python
PY2: 2
- SWIGLANG: python
PY3: 3
VER: '3.2'
os: ubuntu-18.04 # Python < 3.5 not available for 20.04.
- SWIGLANG: python
PY3: 3
VER: '3.3'
os: ubuntu-18.04 # Python < 3.5 not available for 20.04.
- SWIGLANG: python
PY3: 3
VER: '3.4'
os: ubuntu-18.04 # Python < 3.5 not available for 20.04.
- SWIGLANG: python
PY3: 3
VER: '3.5'
- SWIGLANG: python
PY3: 3
VER: '3.6'
- SWIGLANG: python
PY3: 3
VER: '3.7'
- SWIGLANG: python
PY3: 3
VER: '3.8'
- SWIGLANG: python
PY3: 3
VER: '3.9'
- SWIGLANG: python
PY3: 3
VER: '3.10'
- SWIGLANG: python
PY2: 2
SWIG_FEATURES: -builtin
- SWIGLANG: python
PY2: 2
SWIG_FEATURES: -builtin -O
- SWIGLANG: python
PY3: 3
SWIG_FEATURES: -builtin
- SWIGLANG: python
PY3: 3
SWIG_FEATURES: -builtin -O
- SWIGLANG: r
- SWIGLANG: ruby
@ -210,7 +202,6 @@ jobs:
CSTD: gnu11
- SWIGLANG: python
CPPSTD: c++11
PY3: 3
- SWIGLANG: r
CPPSTD: c++11
- SWIGLANG: ruby
@ -245,7 +236,6 @@ jobs:
CSTD: gnu11
- SWIGLANG: python
CPPSTD: c++14
PY3: 3
- SWIGLANG: r
CPPSTD: c++14
- SWIGLANG: ruby
@ -290,7 +280,6 @@ jobs:
- SWIGLANG: python
CPPSTD: c++17
GCC: 11
PY3: 3
- SWIGLANG: r
CPPSTD: c++17
GCC: 11
@ -314,7 +303,7 @@ jobs:
env:
SWIGLANG: ${{ matrix.SWIGLANG }}
PY3: ${{ matrix.PY3 }}
PY2: ${{ matrix.PY2 }}
VER: ${{ matrix.VER }}
ENGINE: ${{ matrix.ENGINE }}
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)
===========================
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
[Go] #683 -intgosize is now optional - if not specified the
generated C/C++ wrapper code will use ptrdiff_t for intgo and

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
TOP = ../../..
LIBS =
ifeq (,$(PY3))
ifneq (,$(PY2))
PKG1DIR = "py2"
else
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>
For Python 3, set the environment variable <tt>PY3=1</tt>.
For Python 2, set the environment variable <tt>PY2=1</tt>.
<p>
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
#######################################################################
ifeq (,$(PY3))
ifneq (,$(PY2))
PYBIN = @PYTHON@
else
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.
You can run make with PY3=y to run test case with Python 3.x, eg.
$ make voidtest.cpptest PY3=y
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 PY2=1

View File

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

View File

@ -23,18 +23,18 @@ environment:
- SWIGLANG: python
VSVER: 14
VER: 27
PY2: 2
- SWIGLANG: python
VSVER: 15
VER: 38
PY3: 3
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- SWIGLANG: python
VSVER: 16
VER: 39
PY3: 3
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- SWIGLANG: python
OSVARIANT: cygwin
PY2: 2
- SWIGLANG: java
OSVARIANT: mingw
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
@ -42,7 +42,6 @@ environment:
OSVARIANT: mingw
WITHLANG: python
VER: 37
PY3: 3
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- BUILDSYSTEM: cmake
VSVER: 14
@ -51,6 +50,7 @@ matrix:
allow_failures:
- SWIGLANG: python
OSVARIANT: cygwin
PY2: 2
# Skip stale commits (pull requests only), see https://github.com/appveyor/ci/issues/38#issuecomment-70628826
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"
# 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 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%"
test_script: