Skip to content

Commit e4e3745

Browse files
Merge pull request #29 from EricCousineau-TRI/feature/merge_20190508
Merge `upstream/master` (35045ee) from previous merge-base (f2bd883)
2 parents f2bd883 + 9c5ae30 commit e4e3745

12 files changed

+197
-87
lines changed

.appveyor.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ install:
4242
if ($env:PYTHON) {
4343
if ($env:PLATFORM -eq "x64") { $env:PYTHON = "$env:PYTHON-x64" }
4444
$env:PATH = "C:\Python$env:PYTHON\;C:\Python$env:PYTHON\Scripts\;$env:PATH"
45-
python -m pip install --upgrade pip wheel
46-
python -m pip install pytest numpy --no-warn-script-location
45+
python -W ignore -m pip install --upgrade pip wheel
46+
python -W ignore -m pip install pytest numpy --no-warn-script-location
4747
} elseif ($env:CONDA) {
4848
if ($env:CONDA -eq "27") { $env:CONDA = "" }
4949
if ($env:PLATFORM -eq "x64") { $env:CONDA = "$env:CONDA-x64" }
5050
$env:PATH = "C:\Miniconda$env:CONDA\;C:\Miniconda$env:CONDA\Scripts\;$env:PATH"
5151
$env:PYTHONHOME = "C:\Miniconda$env:CONDA"
52-
conda update -y -n base conda
52+
conda --version
5353
conda install -y -q pytest numpy scipy
5454
}
5555
- ps: |
@@ -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

Lines changed: 134 additions & 67 deletions
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,20 +9,21 @@ 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:
2523
- tools/check-style.sh
2624
- flake8
27-
- $PY_CMD -m sphinx -W -b html docs docs/.build
25+
# TODO(eric.cousineau): Re-enable doc build at some point once `breathe` is unbroken.
26+
# - $PY_CMD -m sphinx -W -b html docs docs/.build
2827
- |
2928
# Make sure setup.py distributes and installs all the headers
3029
$PY_CMD setup.py sdist
@@ -33,62 +32,119 @@ matrix:
3332
diff -rq $installed ./include/pybind11
3433
- |
3534
# Barebones build
36-
cmake -DCMAKE_BUILD_TYPE=Debug -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DPYTHON_EXECUTABLE=$(which $PY_CMD)
35+
cmake -DCMAKE_BUILD_TYPE=Debug -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DPYTHON_EXECUTABLE=$(which $PY_CMD) .
3736
make pytest -j 2
3837
make cpptest -j 2
3938
# The following are regular test configurations, including optional dependencies.
4039
# With regard to each other they differ in Python version, C++ standard and compiler.
4140
- os: linux
41+
dist: trusty
42+
name: Python 2.7, c++11, gcc 4.8
4243
env: PYTHON=2.7 CPP=11 GCC=4.8
4344
addons:
4445
apt:
45-
packages: [cmake=2.\*, cmake-data=2.\*]
46+
packages:
47+
- cmake=2.\*
48+
- cmake-data=2.\*
4649
- os: linux
50+
dist: trusty
51+
name: Python 3.6, c++11, gcc 4.8
4752
env: PYTHON=3.6 CPP=11 GCC=4.8
4853
addons:
4954
apt:
50-
sources: [deadsnakes]
51-
packages: [python3.6-dev python3.6-venv, cmake=2.\*, cmake-data=2.\*]
52-
- sudo: true
53-
services: docker
55+
sources:
56+
- deadsnakes
57+
packages:
58+
- python3.6-dev
59+
- python3.6-venv
60+
- cmake=2.\*
61+
- cmake-data=2.\*
62+
- os: linux
63+
dist: trusty
5464
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
65+
name: Python 2.7, c++14, gcc 4.8, CMake test
66+
addons:
67+
apt:
68+
sources:
69+
- ubuntu-toolchain-r-test
70+
packages:
71+
- g++-6
72+
- os: linux
73+
dist: trusty
74+
name: Python 3.5, c++14, gcc 6, Debug build
75+
# N.B. `ensurepip` could be installed transitively by `python3.5-venv`, but
76+
# seems to have apt conflicts (at least for Trusty). Use Docker instead.
5977
services: docker
78+
env: DOCKER=debian:stretch PYTHON=3.5 CPP=14 GCC=6 DEBUG=1
79+
- os: linux
80+
dist: xenial
6081
env: PYTHON=3.6 CPP=17 GCC=7
82+
name: Python 3.6, c++17, gcc 7
83+
addons:
84+
apt:
85+
sources:
86+
- deadsnakes
87+
- ubuntu-toolchain-r-test
88+
packages:
89+
- g++-7
90+
- python3.6-dev
91+
- python3.6-venv
6192
- os: linux
62-
env: PYTHON=3.6 CPP=17 CLANG=5.0
93+
dist: xenial
94+
env: PYTHON=3.6 CPP=17 CLANG=7
95+
name: Python 3.6, c++17, Clang 7
6396
addons:
6497
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]
98+
sources:
99+
- deadsnakes
100+
- llvm-toolchain-xenial-7
101+
packages:
102+
- python3.6-dev
103+
- python3.6-venv
104+
- clang-7
105+
- libclang-7-dev
106+
- llvm-7-dev
107+
- lld-7
108+
- libc++-7-dev
109+
- libc++abi-7-dev # Why is this necessary???
67110
- os: osx
111+
name: Python 2.7, c++14, AppleClang 7.3, CMake test
68112
osx_image: xcode7.3
69113
env: PYTHON=2.7 CPP=14 CLANG CMAKE=1
70114
- os: osx
115+
name: Python 3.7, c++14, AppleClang 9, Debug build
71116
osx_image: xcode9
72117
env: PYTHON=3.7 CPP=14 CLANG DEBUG=1
73118
# Test a PyPy 2.7 build
74119
- os: linux
120+
dist: trusty
75121
env: PYPY=5.8 PYTHON=2.7 CPP=11 GCC=4.8
122+
name: PyPy 5.8, Python 2.7, c++11, gcc 4.8
76123
addons:
77124
apt:
78-
packages: [libblas-dev, liblapack-dev, gfortran]
125+
packages:
126+
- libblas-dev
127+
- liblapack-dev
128+
- gfortran
79129
# Build in 32-bit mode and tests against the CMake-installed version
80-
- sudo: true
130+
- os: linux
131+
dist: trusty
81132
services: docker
82-
env: ARCH=i386 PYTHON=3.5 CPP=14 GCC=6 INSTALL=1
133+
env: DOCKER=i386/debian:stretch PYTHON=3.5 CPP=14 GCC=6 INSTALL=1
134+
name: Python 3.4, c++14, gcc 6, 32-bit
83135
script:
84136
- |
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"
137+
# Consolidated 32-bit Docker Build + Install
138+
set -ex
139+
$SCRIPT_RUN_PREFIX sh -c "
140+
set -ex
141+
cmake ${CMAKE_EXTRA_ARGS} -DPYBIND11_INSTALL=1 -DPYBIND11_TEST=0 .
142+
make install
143+
cp -a tests /pybind11-tests
144+
mkdir /build-tests && cd /build-tests
145+
cmake ../pybind11-tests ${CMAKE_EXTRA_ARGS} -DPYBIND11_WERROR=ON
146+
make pytest -j 2"
147+
set +ex
92148
cache:
93149
directories:
94150
- $HOME/.local/bin
@@ -98,6 +154,7 @@ cache:
98154
before_install:
99155
- |
100156
# Configure build variables
157+
set -ex
101158
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
102159
if [ -n "$CLANG" ]; then
103160
export CXX=clang++-$CLANG CC=clang-$CLANG
@@ -108,18 +165,16 @@ before_install:
108165
fi
109166
export CXX=g++-$GCC CC=gcc-$GCC
110167
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
114168
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
115169
export CXX=clang++ CC=clang;
116170
fi
117171
if [ -n "$CPP" ]; then CPP=-std=c++$CPP; fi
118172
if [ "${PYTHON:0:1}" = "3" ]; then PY=3; fi
119173
if [ -n "$DEBUG" ]; then CMAKE_EXTRA_ARGS+=" -DCMAKE_BUILD_TYPE=Debug"; fi
174+
set +ex
120175
- |
121176
# Initialize environment
122-
set -e
177+
set -ex
123178
if [ -n "$DOCKER" ]; then
124179
docker pull $DOCKER
125180
@@ -148,13 +203,15 @@ before_install:
148203
if [ "$PY" = 3 ] || [ -n "$PYPY" ]; then
149204
$PY_CMD -m ensurepip --user
150205
fi
206+
$PY_CMD --version
151207
$PY_CMD -m pip install --user --upgrade pip wheel
152208
fi
153-
set +e
209+
set +ex
154210
install:
155211
- |
156212
# Install dependencies
157-
set -e
213+
set -ex
214+
cmake --version
158215
if [ -n "$DOCKER" ]; then
159216
if [ -n "$DEBUG" ]; then
160217
PY_DEBUG="python$PYTHON-dbg python$PY-scipy-dbg"
@@ -166,49 +223,59 @@ install:
166223
libeigen3-dev libboost-dev cmake make ${EXTRA_PACKAGES} && break; done"
167224
else
168225
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
226+
if [ "$CLANG" = "7" ]; then
227+
export CXXFLAGS="-stdlib=libc++"
189228
fi
190229
191230
export NPY_NUM_BUILD_JOBS=2
192231
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}
232+
local PIP_CMD=""
233+
if [ -n $PYPY ]; then
234+
# For expediency, install only versions that are available on the extra index.
235+
travis_wait 30 \
236+
$PY_CMD -m pip install --user --upgrade --extra-index-url https://imaginary.ca/trusty-pypi \
237+
pytest numpy==1.15.4 scipy==1.2.0
238+
else
239+
$PY_CMD -m pip install --user --upgrade pytest numpy scipy
240+
fi
195241
echo "done."
196242
197243
mkdir eigen
198244
curl -fsSL https://bitbucket.org/eigen/eigen/get/3.3.4.tar.bz2 | \
199245
tar --extract -j --directory=eigen --strip-components=1
200246
export CMAKE_INCLUDE_PATH="${CMAKE_INCLUDE_PATH:+$CMAKE_INCLUDE_PATH:}$PWD/eigen"
201247
fi
202-
set +e
248+
set +ex
203249
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
250+
- |
251+
# CMake Configuration
252+
set -ex
253+
$SCRIPT_RUN_PREFIX cmake ${CMAKE_EXTRA_ARGS} \
254+
-DPYBIND11_PYTHON_VERSION=$PYTHON \
255+
-DPYBIND11_CPP_STANDARD=$CPP \
256+
-DPYBIND11_WERROR=${WERROR:-ON} \
257+
-DDOWNLOAD_CATCH=${DOWNLOAD_CATCH:-ON} \
258+
.
259+
set +ex
260+
- |
261+
# pytest
262+
set -ex
263+
$SCRIPT_RUN_PREFIX make pytest -j 2 VERBOSE=1
264+
set +ex
265+
- |
266+
# cpptest
267+
set -ex
268+
$SCRIPT_RUN_PREFIX make cpptest -j 2
269+
set +ex
270+
- |
271+
# CMake Build Interface
272+
set -ex
273+
if [ -n "$CMAKE" ]; then $SCRIPT_RUN_PREFIX make test_cmake_build; fi
274+
set +ex
212275
after_failure: cat tests/test_cmake_build/*.log*
213276
after_script:
214-
- if [ -n "$DOCKER" ]; then docker stop "$containerid"; docker rm "$containerid"; fi
277+
- |
278+
# Cleanup (Docker)
279+
set -ex
280+
if [ -n "$DOCKER" ]; then docker stop "$containerid"; docker rm "$containerid"; fi
281+
set +ex

include/pybind11/numpy.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -855,14 +855,14 @@ template <typename T, int ExtraFlags = array::forcecast> class array_t : public
855855

856856
// Reference to element at a given index
857857
template<typename... Ix> const T& at(Ix... index) const {
858-
if (sizeof...(index) != ndim())
858+
if ((ssize_t) sizeof...(index) != ndim())
859859
fail_dim_check(sizeof...(index), "index dimension mismatch");
860860
return *(static_cast<const T*>(array::data()) + byte_offset(ssize_t(index)...) / itemsize());
861861
}
862862

863863
// Mutable reference to element at a given index
864864
template<typename... Ix> T& mutable_at(Ix... index) {
865-
if (sizeof...(index) != ndim())
865+
if ((ssize_t) sizeof...(index) != ndim())
866866
fail_dim_check(sizeof...(index), "index dimension mismatch");
867867
return *(static_cast<T*>(array::mutable_data()) + byte_offset(ssize_t(index)...) / itemsize());
868868
}
@@ -1527,15 +1527,15 @@ struct vectorize_helper {
15271527
if (trivial == broadcast_trivial::f_trivial) result = array_t<Return, array::f_style>(shape);
15281528
else result = array_t<Return>(shape);
15291529

1530-
if (size == 0) return result;
1530+
if (size == 0) return std::move(result);
15311531

15321532
/* Call the function */
15331533
if (trivial == broadcast_trivial::non_trivial)
15341534
apply_broadcast(buffers, params, result, i_seq, vi_seq, bi_seq);
15351535
else
15361536
apply_trivial(buffers, params, result.mutable_data(), size, i_seq, vi_seq, bi_seq);
15371537

1538-
return result;
1538+
return std::move(result);
15391539
}
15401540

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

include/pybind11/pybind11.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,12 +2380,12 @@ class gil_scoped_release { };
23802380
#endif
23812381

23822382
error_already_set::~error_already_set() {
2383-
if (type) {
2383+
if (m_type) {
23842384
error_scope scope;
23852385
gil_scoped_acquire gil;
2386-
type.release().dec_ref();
2387-
value.release().dec_ref();
2388-
trace.release().dec_ref();
2386+
m_type.release().dec_ref();
2387+
m_value.release().dec_ref();
2388+
m_trace.release().dec_ref();
23892389
}
23902390
}
23912391

0 commit comments

Comments
 (0)