Skip to content

Commit d6c2193

Browse files
committed
Additional CI fixes (clang7 warnings, pypy pinning, travis shuffle)
- clang7: Suppress self-assign warnings; fix missing virtual dtors - pypy: - Keep old version (newer stuff breaks) - Pin packages to extra index for speed - travis: - Make docker explicit; remove docker if not needed - Make commands more verbose (for debugging / repro) - Make Ubuntu dist explicit per job
1 parent 90ad218 commit d6c2193

7 files changed

+132
-47
lines changed

.travis.yml

Lines changed: 104 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
language: cpp
2-
dist: trusty
32
matrix:
43
include:
54
# This config does a few things:
@@ -10,6 +9,7 @@ matrix:
109
# also tests the automatic discovery functions in CMake (Python version, C++ standard).
1110
- os: linux
1211
dist: xenial # Necessary to run doxygen 1.8.15
12+
# TODO(eric.cousineau): These aren't actually used, they're only for naming. Use "name" field instead?
1313
env: STYLE DOCS PIP
1414
cache: false
1515
before_install:
@@ -38,44 +38,69 @@ matrix:
3838
# The following are regular test configurations, including optional dependencies.
3939
# With regard to each other they differ in Python version, C++ standard and compiler.
4040
- os: linux
41+
dist: trusty
4142
env: PYTHON=2.7 CPP=11 GCC=4.8
4243
addons:
4344
apt:
44-
packages: [cmake=2.\*, cmake-data=2.\*]
45+
packages:
46+
- cmake=2.\*
47+
- cmake-data=2.\*
4548
- os: linux
49+
dist: trusty
4650
env: PYTHON=3.6 CPP=11 GCC=4.8
4751
addons:
4852
apt:
49-
sources: [deadsnakes]
50-
packages: [python3.6-dev python3.6-venv, cmake=2.\*, cmake-data=2.\*]
51-
- services: docker
53+
sources:
54+
- deadsnakes
55+
packages:
56+
- python3.6-dev
57+
- python3.6-venv
58+
- cmake=2.\*
59+
- cmake-data=2.\*
60+
- os: linux
61+
dist: trusty
5262
env: PYTHON=2.7 CPP=14 GCC=6 CMAKE=1
53-
- services: docker
54-
env: PYTHON=3.5 CPP=14 GCC=6 DEBUG=1
55-
- env: PYTHON=3.6 CPP=17 GCC=7
63+
addons:
64+
apt:
65+
sources:
66+
- ubuntu-toolchain-r-test
67+
packages:
68+
- g++-6
69+
- os: linux
70+
dist: trusty
71+
# N.B. `ensurepip` could be installed transitively by `python3.5-venv`, but
72+
# seems to have apt conflicts (at least for Trusty). Use Docker instead.
73+
services: docker
74+
env: DOCKER=debian:stretch PYTHON=3.5 CPP=14 GCC=6 DEBUG=1
75+
- os: linux
76+
dist: xenial
77+
env: PYTHON=3.6 CPP=17 GCC=7
5678
addons:
5779
apt:
5880
sources:
5981
- deadsnakes
6082
- ubuntu-toolchain-r-test
6183
packages:
84+
- g++-7
6285
- python3.6-dev
6386
- python3.6-venv
64-
- g++-7
6587
- os: linux
88+
dist: xenial
6689
env: PYTHON=3.6 CPP=17 CLANG=7
6790
addons:
6891
apt:
6992
sources:
7093
- deadsnakes
71-
- llvm-toolchain-trusty-7
94+
- llvm-toolchain-xenial-7
7295
packages:
7396
- python3.6-dev
7497
- python3.6-venv
7598
- clang-7
99+
- libclang-7-dev
76100
- llvm-7-dev
77101
- lld-7
78-
- libstdc++7
102+
- libc++-7-dev
103+
- libc++abi-7-dev # Why is this necessary???
79104
- os: osx
80105
osx_image: xcode7.3
81106
env: PYTHON=2.7 CPP=14 CLANG CMAKE=1
@@ -84,22 +109,32 @@ matrix:
84109
env: PYTHON=3.7 CPP=14 CLANG DEBUG=1
85110
# Test a PyPy 2.7 build
86111
- os: linux
87-
env: PYPY=7.1 PYTHON=2.7 CPP=11 GCC=4.8
112+
dist: trusty
113+
env: PYPY=5.8 PYTHON=2.7 CPP=11 GCC=4.8
88114
addons:
89115
apt:
90-
packages: [libblas-dev, liblapack-dev, gfortran]
116+
packages:
117+
- libblas-dev
118+
- liblapack-dev
119+
- gfortran
91120
# Build in 32-bit mode and tests against the CMake-installed version
92-
- services: docker
93-
env: ARCH=i386 PYTHON=3.5 CPP=14 GCC=6 INSTALL=1
121+
- os: linux
122+
dist: trusty
123+
services: docker
124+
env: DOCKER=i386/debian:stretch PYTHON=3.5 CPP=14 GCC=6 INSTALL=1
94125
script:
95126
- |
96-
$SCRIPT_RUN_PREFIX sh -c "set -e
97-
cmake ${CMAKE_EXTRA_ARGS} -DPYBIND11_INSTALL=1 -DPYBIND11_TEST=0 .
98-
make install
99-
cp -a tests /pybind11-tests
100-
mkdir /build-tests && cd /build-tests
101-
cmake ../pybind11-tests ${CMAKE_EXTRA_ARGS} -DPYBIND11_WERROR=ON
102-
make pytest -j 2"
127+
# Consolidated 32-bit Docker Build + Install
128+
set -ex
129+
$SCRIPT_RUN_PREFIX sh -c "
130+
set -ex
131+
cmake ${CMAKE_EXTRA_ARGS} -DPYBIND11_INSTALL=1 -DPYBIND11_TEST=0 .
132+
make install
133+
cp -a tests /pybind11-tests
134+
mkdir /build-tests && cd /build-tests
135+
cmake ../pybind11-tests ${CMAKE_EXTRA_ARGS} -DPYBIND11_WERROR=ON
136+
make pytest -j 2"
137+
set +ex
103138
cache:
104139
directories:
105140
- $HOME/.local/bin
@@ -109,6 +144,7 @@ cache:
109144
before_install:
110145
- |
111146
# Configure build variables
147+
set -ex
112148
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
113149
if [ -n "$CLANG" ]; then
114150
export CXX=clang++-$CLANG CC=clang-$CLANG
@@ -119,18 +155,16 @@ before_install:
119155
fi
120156
export CXX=g++-$GCC CC=gcc-$GCC
121157
fi
122-
if [ "$GCC" = "6" ]; then DOCKER=${ARCH:+$ARCH/}debian:stretch
123-
elif [ "$GCC" = "7" ]; then DOCKER=debian:buster EXTRA_PACKAGES+=" catch python3-distutils" DOWNLOAD_CATCH=OFF
124-
fi
125158
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
126159
export CXX=clang++ CC=clang;
127160
fi
128161
if [ -n "$CPP" ]; then CPP=-std=c++$CPP; fi
129162
if [ "${PYTHON:0:1}" = "3" ]; then PY=3; fi
130163
if [ -n "$DEBUG" ]; then CMAKE_EXTRA_ARGS+=" -DCMAKE_BUILD_TYPE=Debug"; fi
164+
set +ex
131165
- |
132166
# Initialize environment
133-
set -e
167+
set -ex
134168
if [ -n "$DOCKER" ]; then
135169
docker pull $DOCKER
136170
@@ -142,9 +176,9 @@ before_install:
142176
SCRIPT_RUN_PREFIX="docker exec --tty $containerid"
143177
$SCRIPT_RUN_PREFIX sh -c 'for s in 0 15; do sleep $s; apt-get update && apt-get -qy dist-upgrade && break; done'
144178
else
145-
if [ "$PYPY" = "7.1" ]; then
146-
curl -fSL https://bitbucket.org/pypy/pypy/downloads/pypy2.7-v7.1.0-linux64.tar.bz2 | tar xj
147-
PY_CMD=$(echo `pwd`/pypy2.7-v7.1.0-linux64/bin/pypy)
179+
if [ "$PYPY" = "5.8" ]; then
180+
curl -fSL https://bitbucket.org/pypy/pypy/downloads/pypy2-v5.8.0-linux64.tar.bz2 | tar xj
181+
PY_CMD=$(echo `pwd`/pypy2-v5.8.0-linux64/bin/pypy)
148182
CMAKE_EXTRA_ARGS+=" -DPYTHON_EXECUTABLE:FILEPATH=$PY_CMD"
149183
else
150184
PY_CMD=python$PYTHON
@@ -162,12 +196,12 @@ before_install:
162196
$PY_CMD --version
163197
$PY_CMD -m pip install --user --upgrade pip wheel
164198
fi
165-
set +e
199+
set +ex
166200
install:
167201
- |
168202
# Install dependencies
203+
set -ex
169204
cmake --version
170-
set -e
171205
if [ -n "$DOCKER" ]; then
172206
if [ -n "$DEBUG" ]; then
173207
PY_DEBUG="python$PYTHON-dbg python$PY-scipy-dbg"
@@ -185,26 +219,53 @@ install:
185219
186220
export NPY_NUM_BUILD_JOBS=2
187221
echo "Installing pytest, numpy, scipy..."
188-
${PYPY:+travis_wait 30} $PY_CMD -m pip install --user --upgrade pytest numpy scipy \
189-
${PYPY:+--extra-index-url https://imaginary.ca/trusty-pypi}
222+
local PIP_CMD=""
223+
if [ -n $PYPY ]; then
224+
# For expediency, install only versions that are available on the extra index.
225+
travis_wait 30 \
226+
$PY_CMD -m pip install --user --upgrade --extra-index-url https://imaginary.ca/trusty-pypi \
227+
pytest numpy==1.15.4 scipy==1.2.0
228+
else
229+
$PY_CMD -m pip install --user --upgrade pytest numpy scipy
230+
fi
190231
echo "done."
191232
192233
mkdir eigen
193234
curl -fsSL https://bitbucket.org/eigen/eigen/get/3.3.4.tar.bz2 | \
194235
tar --extract -j --directory=eigen --strip-components=1
195236
export CMAKE_INCLUDE_PATH="${CMAKE_INCLUDE_PATH:+$CMAKE_INCLUDE_PATH:}$PWD/eigen"
196237
fi
197-
set +e
238+
set +ex
198239
script:
199-
- $SCRIPT_RUN_PREFIX cmake ${CMAKE_EXTRA_ARGS}
200-
-DPYBIND11_PYTHON_VERSION=$PYTHON
201-
-DPYBIND11_CPP_STANDARD=$CPP
202-
-DPYBIND11_WERROR=${WERROR:-ON}
203-
-DDOWNLOAD_CATCH=${DOWNLOAD_CATCH:-ON}
240+
- |
241+
# CMake Configuration
242+
set -ex
243+
$SCRIPT_RUN_PREFIX cmake ${CMAKE_EXTRA_ARGS} \
244+
-DPYBIND11_PYTHON_VERSION=$PYTHON \
245+
-DPYBIND11_CPP_STANDARD=$CPP \
246+
-DPYBIND11_WERROR=${WERROR:-ON} \
247+
-DDOWNLOAD_CATCH=${DOWNLOAD_CATCH:-ON} \
204248
.
205-
- $SCRIPT_RUN_PREFIX make pytest -j 2
206-
- $SCRIPT_RUN_PREFIX make cpptest -j 2
207-
- if [ -n "$CMAKE" ]; then $SCRIPT_RUN_PREFIX make test_cmake_build; fi
249+
set +ex
250+
- |
251+
# pytest
252+
set -ex
253+
$SCRIPT_RUN_PREFIX make pytest -j 2 VERBOSE=1
254+
set +ex
255+
- |
256+
# cpptest
257+
set -ex
258+
$SCRIPT_RUN_PREFIX make cpptest -j 2
259+
set +ex
260+
- |
261+
# CMake Build Interface
262+
set -ex
263+
if [ -n "$CMAKE" ]; then $SCRIPT_RUN_PREFIX make test_cmake_build; fi
264+
set +ex
208265
after_failure: cat tests/test_cmake_build/*.log*
209266
after_script:
210-
- if [ -n "$DOCKER" ]; then docker stop "$containerid"; docker rm "$containerid"; fi
267+
- |
268+
# Cleanup (Docker)
269+
set -ex
270+
if [ -n "$DOCKER" ]; then docker stop "$containerid"; docker rm "$containerid"; fi
271+
set +ex

include/pybind11/numpy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,15 +1509,15 @@ struct vectorize_helper {
15091509
if (trivial == broadcast_trivial::f_trivial) result = array_t<Return, array::f_style>(shape);
15101510
else result = array_t<Return>(shape);
15111511

1512-
if (size == 0) return result;
1512+
if (size == 0) return std::move(result);
15131513

15141514
/* Call the function */
15151515
if (trivial == broadcast_trivial::non_trivial)
15161516
apply_broadcast(buffers, params, result, i_seq, vi_seq, bi_seq);
15171517
else
15181518
apply_trivial(buffers, params, result.mutable_data(), size, i_seq, vi_seq, bi_seq);
15191519

1520-
return result;
1520+
return std::move(result);
15211521
}
15221522

15231523
template <size_t... Index, size_t... VIndex, size_t... BIndex>

tests/test_gil_scoped.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
class VirtClass {
1515
public:
16+
virtual ~VirtClass() {}
1617
virtual void virtual_func() {}
1718
virtual void pure_virtual_func() = 0;
1819
};

tests/test_kwargs_and_defaults.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ TEST_SUBMODULE(kwargs_and_defaults, m) {
3434
m.def("kw_func_udl_z", kw_func, "x"_a, "y"_a=0);
3535

3636
// test_args_and_kwargs
37-
m.def("args_function", [](py::args args) -> py::tuple { return args; });
37+
m.def("args_function", [](py::args args) -> py::tuple {
38+
return std::move(args);
39+
});
3840
m.def("args_kwargs_function", [](py::args args, py::kwargs kwargs) {
3941
return py::make_tuple(args, kwargs);
4042
});

tests/test_operator_overloading.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,22 @@ namespace std {
6262
};
6363
}
6464

65+
#pragma GCC diagnostic push
66+
// clang 7.0.0 and Apple LLVM 10.0.1 introduce `-Wself-assign-overloaded` to
67+
// `-Wall`, which is used here for overloading (e.g. `py::self += py::self `).
68+
// Here, we suppress the warning using `#pragma diagnostic`.
69+
// Taken from: https://github.com/RobotLocomotion/drake/commit/aaf84b46
70+
// TODO(eric): This could be resolved using a function / functor (e.g. `py::self()`).
71+
#if (__APPLE__) && (__clang__)
72+
#if (__clang_major__ >= 10) && (__clang_minor__ >= 0) && (__clang_patchlevel__ >= 1)
73+
#pragma GCC diagnostic ignored "-Wself-assign-overloaded"
74+
#endif
75+
#elif (__clang__)
76+
#if (__clang_major__ >= 7)
77+
#pragma GCC diagnostic ignored "-Wself-assign-overloaded"
78+
#endif
79+
#endif
80+
6581
TEST_SUBMODULE(operators, m) {
6682

6783
// test_operator_overloading
@@ -144,3 +160,5 @@ TEST_SUBMODULE(operators, m) {
144160
.def_readwrite("b", &NestC::b);
145161
m.def("get_NestC", [](const NestC &c) { return c.value; });
146162
}
163+
164+
#pragma GCC diagnostic pop

tests/test_smart_ptr.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,9 @@ TEST_SUBMODULE(smart_ptr, m) {
336336

337337
// test_shared_ptr_gc
338338
// #187: issue involving std::shared_ptr<> return value policy & garbage collection
339-
struct ElementBase { virtual void foo() { } /* Force creation of virtual table */ };
339+
struct ElementBase {
340+
virtual ~ElementBase() { } /* Force creation of virtual table */
341+
};
340342
py::class_<ElementBase, std::shared_ptr<ElementBase>>(m, "ElementBase");
341343

342344
struct ElementA : ElementBase {

tests/test_virtual_functions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class Movable {
129129

130130
class NCVirt {
131131
public:
132+
virtual ~NCVirt() { }
132133
virtual NonCopyable get_noncopyable(int a, int b) { return NonCopyable(a, b); }
133134
virtual Movable get_movable(int a, int b) = 0;
134135

0 commit comments

Comments
 (0)