Skip to content

Commit ae951ca

Browse files
henryiiiwjakob
authored andcommitted
CI fixes (pybind#1744)
* Fix warning that not including a cmake source or build dir will be a fatal error (it is now on newest CMakes) * Fixes appveyor * Travis uses CMake 3.9 for more than a year now * Travis dropped sudo: false in December * Dropping Sphinx 2 - 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 - Fix Windows - Add names to travis
1 parent 25abf7e commit ae951ca

8 files changed

+166
-70
lines changed

.appveyor.yml

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ build_script:
6262
-DPYBIND11_WERROR=ON
6363
-DDOWNLOAD_CATCH=ON
6464
-DCMAKE_SUPPRESS_REGENERATION=1
65+
.
6566
- set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
6667
- cmake --build . --config %CONFIG% --target pytest -- /m /v:m /logger:%MSBuildLogger%
6768
- cmake --build . --config %CONFIG% --target cpptest -- /m /v:m /logger:%MSBuildLogger%

.travis.yml

+132-66
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
language: cpp
2-
dist: trusty
3-
sudo: false
42
matrix:
53
include:
64
# This config does a few things:
@@ -11,14 +9,14 @@ matrix:
119
# also tests the automatic discovery functions in CMake (Python version, C++ standard).
1210
- os: linux
1311
dist: xenial # Necessary to run doxygen 1.8.15
14-
env: STYLE DOCS PIP
12+
name: Style, docs, and pip
1513
cache: false
1614
before_install:
1715
- pyenv global $(pyenv whence 2to3) # activate all python versions
1816
- PY_CMD=python3
1917
- $PY_CMD -m pip install --user --upgrade pip wheel setuptools
20-
install:
21-
- $PY_CMD -m pip install --user --upgrade sphinx sphinx_rtd_theme breathe flake8 pep8-naming pytest
18+
install: # Breathe does not yet support Sphinx 2
19+
- $PY_CMD -m pip install --user --upgrade "sphinx<2" sphinx_rtd_theme breathe flake8 pep8-naming pytest
2220
- curl -fsSL https://sourceforge.net/projects/doxygen/files/rel-1.8.15/doxygen-1.8.15.linux.bin.tar.gz/download | tar xz
2321
- export PATH="$PWD/doxygen-1.8.15/bin:$PATH"
2422
script:
@@ -33,62 +31,119 @@ matrix:
3331
diff -rq $installed ./include/pybind11
3432
- |
3533
# Barebones build
36-
cmake -DCMAKE_BUILD_TYPE=Debug -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DPYTHON_EXECUTABLE=$(which $PY_CMD)
34+
cmake -DCMAKE_BUILD_TYPE=Debug -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DPYTHON_EXECUTABLE=$(which $PY_CMD) .
3735
make pytest -j 2
3836
make cpptest -j 2
3937
# The following are regular test configurations, including optional dependencies.
4038
# With regard to each other they differ in Python version, C++ standard and compiler.
4139
- os: linux
40+
dist: trusty
41+
name: Python 2.7, c++11, gcc 4.8
4242
env: PYTHON=2.7 CPP=11 GCC=4.8
4343
addons:
4444
apt:
45-
packages: [cmake=2.\*, cmake-data=2.\*]
45+
packages:
46+
- cmake=2.\*
47+
- cmake-data=2.\*
4648
- os: linux
49+
dist: trusty
50+
name: Python 3.6, c++11, gcc 4.8
4751
env: PYTHON=3.6 CPP=11 GCC=4.8
4852
addons:
4953
apt:
50-
sources: [deadsnakes]
51-
packages: [python3.6-dev python3.6-venv, cmake=2.\*, cmake-data=2.\*]
52-
- sudo: true
53-
services: docker
54+
sources:
55+
- deadsnakes
56+
packages:
57+
- python3.6-dev
58+
- python3.6-venv
59+
- cmake=2.\*
60+
- cmake-data=2.\*
61+
- os: linux
62+
dist: trusty
5463
env: PYTHON=2.7 CPP=14 GCC=6 CMAKE=1
55-
- sudo: true
56-
services: docker
57-
env: PYTHON=3.5 CPP=14 GCC=6 DEBUG=1
58-
- sudo: true
64+
name: Python 2.7, c++14, gcc 4.8, CMake test
65+
addons:
66+
apt:
67+
sources:
68+
- ubuntu-toolchain-r-test
69+
packages:
70+
- g++-6
71+
- os: linux
72+
dist: trusty
73+
name: Python 3.5, c++14, gcc 6, Debug build
74+
# N.B. `ensurepip` could be installed transitively by `python3.5-venv`, but
75+
# seems to have apt conflicts (at least for Trusty). Use Docker instead.
5976
services: docker
77+
env: DOCKER=debian:stretch PYTHON=3.5 CPP=14 GCC=6 DEBUG=1
78+
- os: linux
79+
dist: xenial
6080
env: PYTHON=3.6 CPP=17 GCC=7
81+
name: Python 3.6, c++17, gcc 7
82+
addons:
83+
apt:
84+
sources:
85+
- deadsnakes
86+
- ubuntu-toolchain-r-test
87+
packages:
88+
- g++-7
89+
- python3.6-dev
90+
- python3.6-venv
6191
- os: linux
62-
env: PYTHON=3.6 CPP=17 CLANG=5.0
92+
dist: xenial
93+
env: PYTHON=3.6 CPP=17 CLANG=7
94+
name: Python 3.6, c++17, Clang 7
6395
addons:
6496
apt:
65-
sources: [deadsnakes, llvm-toolchain-trusty-5.0, ubuntu-toolchain-r-test]
66-
packages: [python3.6-dev python3.6-venv clang-5.0 llvm-5.0-dev, lld-5.0]
97+
sources:
98+
- deadsnakes
99+
- llvm-toolchain-xenial-7
100+
packages:
101+
- python3.6-dev
102+
- python3.6-venv
103+
- clang-7
104+
- libclang-7-dev
105+
- llvm-7-dev
106+
- lld-7
107+
- libc++-7-dev
108+
- libc++abi-7-dev # Why is this necessary???
67109
- os: osx
110+
name: Python 2.7, c++14, AppleClang 7.3, CMake test
68111
osx_image: xcode7.3
69112
env: PYTHON=2.7 CPP=14 CLANG CMAKE=1
70113
- os: osx
114+
name: Python 3.7, c++14, AppleClang 9, Debug build
71115
osx_image: xcode9
72116
env: PYTHON=3.7 CPP=14 CLANG DEBUG=1
73117
# Test a PyPy 2.7 build
74118
- os: linux
119+
dist: trusty
75120
env: PYPY=5.8 PYTHON=2.7 CPP=11 GCC=4.8
121+
name: PyPy 5.8, Python 2.7, c++11, gcc 4.8
76122
addons:
77123
apt:
78-
packages: [libblas-dev, liblapack-dev, gfortran]
124+
packages:
125+
- libblas-dev
126+
- liblapack-dev
127+
- gfortran
79128
# Build in 32-bit mode and tests against the CMake-installed version
80-
- sudo: true
129+
- os: linux
130+
dist: trusty
81131
services: docker
82-
env: ARCH=i386 PYTHON=3.5 CPP=14 GCC=6 INSTALL=1
132+
env: DOCKER=i386/debian:stretch PYTHON=3.5 CPP=14 GCC=6 INSTALL=1
133+
name: Python 3.4, c++14, gcc 6, 32-bit
83134
script:
84135
- |
85-
$SCRIPT_RUN_PREFIX sh -c "set -e
86-
cmake ${CMAKE_EXTRA_ARGS} -DPYBIND11_INSTALL=1 -DPYBIND11_TEST=0
87-
make install
88-
cp -a tests /pybind11-tests
89-
mkdir /build-tests && cd /build-tests
90-
cmake ../pybind11-tests ${CMAKE_EXTRA_ARGS} -DPYBIND11_WERROR=ON
91-
make pytest -j 2"
136+
# Consolidated 32-bit Docker Build + Install
137+
set -ex
138+
$SCRIPT_RUN_PREFIX sh -c "
139+
set -ex
140+
cmake ${CMAKE_EXTRA_ARGS} -DPYBIND11_INSTALL=1 -DPYBIND11_TEST=0 .
141+
make install
142+
cp -a tests /pybind11-tests
143+
mkdir /build-tests && cd /build-tests
144+
cmake ../pybind11-tests ${CMAKE_EXTRA_ARGS} -DPYBIND11_WERROR=ON
145+
make pytest -j 2"
146+
set +ex
92147
cache:
93148
directories:
94149
- $HOME/.local/bin
@@ -98,6 +153,7 @@ cache:
98153
before_install:
99154
- |
100155
# Configure build variables
156+
set -ex
101157
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
102158
if [ -n "$CLANG" ]; then
103159
export CXX=clang++-$CLANG CC=clang-$CLANG
@@ -108,18 +164,16 @@ before_install:
108164
fi
109165
export CXX=g++-$GCC CC=gcc-$GCC
110166
fi
111-
if [ "$GCC" = "6" ]; then DOCKER=${ARCH:+$ARCH/}debian:stretch
112-
elif [ "$GCC" = "7" ]; then DOCKER=debian:buster EXTRA_PACKAGES+=" catch python3-distutils" DOWNLOAD_CATCH=OFF
113-
fi
114167
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
115168
export CXX=clang++ CC=clang;
116169
fi
117170
if [ -n "$CPP" ]; then CPP=-std=c++$CPP; fi
118171
if [ "${PYTHON:0:1}" = "3" ]; then PY=3; fi
119172
if [ -n "$DEBUG" ]; then CMAKE_EXTRA_ARGS+=" -DCMAKE_BUILD_TYPE=Debug"; fi
173+
set +ex
120174
- |
121175
# Initialize environment
122-
set -e
176+
set -ex
123177
if [ -n "$DOCKER" ]; then
124178
docker pull $DOCKER
125179
@@ -148,13 +202,15 @@ before_install:
148202
if [ "$PY" = 3 ] || [ -n "$PYPY" ]; then
149203
$PY_CMD -m ensurepip --user
150204
fi
205+
$PY_CMD --version
151206
$PY_CMD -m pip install --user --upgrade pip wheel
152207
fi
153-
set +e
208+
set +ex
154209
install:
155210
- |
156211
# Install dependencies
157-
set -e
212+
set -ex
213+
cmake --version
158214
if [ -n "$DOCKER" ]; then
159215
if [ -n "$DEBUG" ]; then
160216
PY_DEBUG="python$PYTHON-dbg python$PY-scipy-dbg"
@@ -166,49 +222,59 @@ install:
166222
libeigen3-dev libboost-dev cmake make ${EXTRA_PACKAGES} && break; done"
167223
else
168224
169-
if [ "$CLANG" = "5.0" ]; then
170-
if ! [ -d ~/.local/include/c++/v1 ]; then
171-
# Neither debian nor llvm provide a libc++ 5.0 deb; luckily it's fairly quick
172-
# to build, install (and cache), so do it ourselves:
173-
git clone --depth=1 https://github.com/llvm-mirror/llvm.git llvm-source
174-
git clone https://github.com/llvm-mirror/libcxx.git llvm-source/projects/libcxx -b release_50
175-
git clone https://github.com/llvm-mirror/libcxxabi.git llvm-source/projects/libcxxabi -b release_50
176-
mkdir llvm-build && cd llvm-build
177-
# Building llvm requires a newer cmake than is provided by the trusty container:
178-
CMAKE_VER=cmake-3.8.0-Linux-x86_64
179-
curl https://cmake.org/files/v3.8/$CMAKE_VER.tar.gz | tar xz
180-
./$CMAKE_VER/bin/cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/.local ../llvm-source
181-
make -j2 install-cxxabi install-cxx
182-
cp -a include/c++/v1/*cxxabi*.h ~/.local/include/c++/v1
183-
cd ..
184-
fi
185-
export CXXFLAGS="-isystem $HOME/.local/include/c++/v1 -stdlib=libc++"
186-
export LDFLAGS="-L$HOME/.local/lib -fuse-ld=lld-$CLANG"
187-
export LD_LIBRARY_PATH="$HOME/.local/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
188-
if [ "$CPP" = "-std=c++17" ]; then CPP="-std=c++1z"; fi
225+
if [ "$CLANG" = "7" ]; then
226+
export CXXFLAGS="-stdlib=libc++"
189227
fi
190228
191229
export NPY_NUM_BUILD_JOBS=2
192230
echo "Installing pytest, numpy, scipy..."
193-
${PYPY:+travis_wait 30} $PY_CMD -m pip install --user --upgrade pytest numpy scipy \
194-
${PYPY:+--extra-index-url https://imaginary.ca/trusty-pypi}
231+
local PIP_CMD=""
232+
if [ -n $PYPY ]; then
233+
# For expediency, install only versions that are available on the extra index.
234+
travis_wait 30 \
235+
$PY_CMD -m pip install --user --upgrade --extra-index-url https://imaginary.ca/trusty-pypi \
236+
pytest numpy==1.15.4 scipy==1.2.0
237+
else
238+
$PY_CMD -m pip install --user --upgrade pytest numpy scipy
239+
fi
195240
echo "done."
196241
197242
mkdir eigen
198243
curl -fsSL https://bitbucket.org/eigen/eigen/get/3.3.4.tar.bz2 | \
199244
tar --extract -j --directory=eigen --strip-components=1
200245
export CMAKE_INCLUDE_PATH="${CMAKE_INCLUDE_PATH:+$CMAKE_INCLUDE_PATH:}$PWD/eigen"
201246
fi
202-
set +e
247+
set +ex
203248
script:
204-
- $SCRIPT_RUN_PREFIX cmake ${CMAKE_EXTRA_ARGS}
205-
-DPYBIND11_PYTHON_VERSION=$PYTHON
206-
-DPYBIND11_CPP_STANDARD=$CPP
207-
-DPYBIND11_WERROR=${WERROR:-ON}
208-
-DDOWNLOAD_CATCH=${DOWNLOAD_CATCH:-ON}
209-
- $SCRIPT_RUN_PREFIX make pytest -j 2
210-
- $SCRIPT_RUN_PREFIX make cpptest -j 2
211-
- if [ -n "$CMAKE" ]; then $SCRIPT_RUN_PREFIX make test_cmake_build; fi
249+
- |
250+
# CMake Configuration
251+
set -ex
252+
$SCRIPT_RUN_PREFIX cmake ${CMAKE_EXTRA_ARGS} \
253+
-DPYBIND11_PYTHON_VERSION=$PYTHON \
254+
-DPYBIND11_CPP_STANDARD=$CPP \
255+
-DPYBIND11_WERROR=${WERROR:-ON} \
256+
-DDOWNLOAD_CATCH=${DOWNLOAD_CATCH:-ON} \
257+
.
258+
set +ex
259+
- |
260+
# pytest
261+
set -ex
262+
$SCRIPT_RUN_PREFIX make pytest -j 2 VERBOSE=1
263+
set +ex
264+
- |
265+
# cpptest
266+
set -ex
267+
$SCRIPT_RUN_PREFIX make cpptest -j 2
268+
set +ex
269+
- |
270+
# CMake Build Interface
271+
set -ex
272+
if [ -n "$CMAKE" ]; then $SCRIPT_RUN_PREFIX make test_cmake_build; fi
273+
set +ex
212274
after_failure: cat tests/test_cmake_build/*.log*
213275
after_script:
214-
- if [ -n "$DOCKER" ]; then docker stop "$containerid"; docker rm "$containerid"; fi
276+
- |
277+
# Cleanup (Docker)
278+
set -ex
279+
if [ -n "$DOCKER" ]; then docker stop "$containerid"; docker rm "$containerid"; fi
280+
set +ex

include/pybind11/numpy.h

+2-2
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

+1
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

+3-1
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

+23
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,25 @@ namespace std {
6262
};
6363
}
6464

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

6786
// test_operator_overloading
@@ -144,3 +163,7 @@ TEST_SUBMODULE(operators, m) {
144163
.def_readwrite("b", &NestC::b);
145164
m.def("get_NestC", [](const NestC &c) { return c.value; });
146165
}
166+
167+
#ifndef _MSC_VER
168+
#pragma GCC diagnostic pop
169+
#endif

tests/test_smart_ptr.cpp

+3-1
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 {

0 commit comments

Comments
 (0)