Skip to content

Commit defaee7

Browse files
authored
fix: pybind11 update, support PyPy / Python 3.9 / cleanup (#443)
* feat: pybind11 2.6 dev * chore: update to newer pybind11 * chore: use vector void impl * fix: update requirements * docs: update CHANGELOG * chore: missing constructor now present * chore: update pybind11 to 2.6.0rc1, use get_pointer() cibuildwheel too * ci: bump to pybind11 2.6.0 rc 2 * chore: another pybind11 update, should fix pypy3 on windows * ci(wheels): use latest MSVC on PyPy * fix: tighten strides constructor for PyPy on Windows * chore: update to 2.6.0
1 parent 7fad3a4 commit defaee7

24 files changed

+105
-491
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
run: apt-get update && apt-get install -y python3-dev python3-pip
3636

3737
- name: Install extra requirements
38-
run: python3 -m pip install setuptools_scm
38+
run: python3 -m pip install setuptools_scm toml
3939

4040
- name: Configure
4141
run: cmake -S . -B build -DCMAKE_CXX_CLANG_TIDY="$(which clang-tidy);--warnings-as-errors=*"
@@ -49,7 +49,7 @@ jobs:
4949
strategy:
5050
fail-fast: false
5151
matrix:
52-
python-version: ["2.7", "3.5", "3.8"] # Waiting on CPython or pybind11 fix: , "3.9-dev"]
52+
python-version: ["2.7", "3.5", "3.8", "3.9", "pypy3"]
5353

5454
name: CMake Python ${{ matrix.python-version }}
5555

.github/workflows/wheels.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ on:
1818

1919
env:
2020
CIBW_TEST_EXTRAS: test
21-
CIBW_TEST_COMMAND: pytest {project}/tests
21+
# Disabled currently - needs NumPy 3.9 wheels
22+
CIBW_TEST_COMMAND_: "" # pytest {project}/tests
2223
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.overrideVersion }}
2324

2425

@@ -34,10 +35,10 @@ jobs:
3435
- uses: actions/setup-python@v2
3536

3637
- name: Install deps
37-
run: python -m pip install "setuptools>=42" "setuptools_scm[toml]>=4.1.0" twine
38+
run: python -m pip install build twine
3839

3940
- name: Build SDist
40-
run: python setup.py sdist
41+
run: python -m build -s
4142

4243
- name: Check metadata
4344
run: twine check dist/*
@@ -51,12 +52,14 @@ jobs:
5152
name: ${{ matrix.type }} wheels on ${{ matrix.os }}
5253
runs-on: ${{ matrix.os }}
5354
strategy:
55+
fail-fast: false
5456
matrix:
5557
os: [ubuntu-18.04, windows-latest, macos-latest]
5658
type: [Standard]
5759

5860
include:
59-
- type: Standard
61+
- os: ubuntu-18.04
62+
type: Standard
6063
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2010
6164
CIBW_MANYLINUX_I686_IMAGE: manylinux2010
6265

@@ -73,12 +76,12 @@ jobs:
7376
- uses: actions/setup-python@v2
7477

7578
- name: Install cibuildwheel
76-
run: python -m pip install cibuildwheel==1.5.5
79+
run: python -m pip install cibuildwheel==1.6.3
7780

7881
- name: Build wheel
7982
run: python -m cibuildwheel --output-dir wheelhouse
8083
env:
81-
CIBW_SKIP: pp* cp27-win*
84+
CIBW_SKIP: cp27-win* pp27-win32
8285
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.CIBW_MANYLINUX_I686_IMAGE }}
8386
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.CIBW_MANYLINUX_X86_64_IMAGE }}
8487

@@ -109,7 +112,7 @@ jobs:
109112
- uses: actions/setup-python@v2
110113

111114
- name: Install cibuildwheel
112-
run: python -m pip install cibuildwheel==1.5.5
115+
run: python -m pip install cibuildwheel==1.6.3
113116

114117
- uses: ilammy/msvc-dev-cmd@v1
115118

@@ -127,7 +130,7 @@ jobs:
127130
- name: Build 32-bit wheel
128131
run: python -m cibuildwheel --output-dir wheelhouse
129132
env:
130-
CIBW_BUILD: cp27-win32
133+
CIBW_BUILD: cp27-win32 pp27-win32
131134
DISTUTILS_USE_SDK: 1
132135
MSSdk: 1
133136

CMakeLists.txt

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -174,27 +174,6 @@ install(TARGETS _core DESTINATION "boost_histogram")
174174
# Tests (Requires pytest to be available to run)
175175
include(CTest)
176176

177-
# Check to see if modules are importable.
178-
function(python_import)
179-
foreach(PACKAGE_NAME IN LISTS ARGN)
180-
string(REPLACE "-" "_" PYTHON_PACKAGE_NAME "${PACKAGE_NAME}")
181-
execute_process(
182-
COMMAND ${PYTHON_EXECUTABLE} -c "import ${PYTHON_PACKAGE_NAME}"
183-
RESULT_VARIABLE RESULT_PRESENT
184-
OUTPUT_QUIET ERROR_QUIET)
185-
if(RESULT_PRESENT)
186-
list(APPEND FAILED_NAMES "${PACKAGE_NAME}")
187-
endif()
188-
endforeach()
189-
if(FAILED_NAMES)
190-
list(JOIN FAILED_NAMES " " FAILED_NAMES)
191-
message(
192-
WARNING
193-
"Dependencies missing, try installing:\n ${PYTHON_EXECUTABLE} -m pip install ${FAILED_NAMES}\n"
194-
)
195-
endif()
196-
endfunction()
197-
198177
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/boost_histogram/version.py")
199178
set(VERSION_REGEX [=[version[ \t]*=[ \t]*["']([0-9]+\.[0-9]+\.[0-9]+)]=])
200179

@@ -205,7 +184,8 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/boost_histogram/version.py")
205184
# Pick out just the version
206185
string(REGEX MATCH [=[[0-9]+\.[0-9]+\.[0-9]+]=] VERSION_STRING "${VERSION_STRING}")
207186
else()
208-
python_import(setuptools_scm toml)
187+
pybind11_find_import(setuptools_scm REQUIRED)
188+
pybind11_find_import(toml REQUIRED)
209189

210190
execute_process(
211191
COMMAND

CONTRIBUTING.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ source ./env_cmake/bin/activate
8585
pip install -r dev-requirements.txt
8686
cmake -S . -B build-debug \
8787
-GNinja \
88-
-DPYTHON_EXECUTABLE=$(which python) \
8988
-DCMAKE_INSTALL_PREFIX=$(python -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False))")
9089
cmake --build build-debug -j4
9190
cmake --install build-debug # Option 3 only

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ graft extern/variant2/include
1414

1515
graft extern/pybind11/include
1616
graft extern/pybind11/tools
17+
graft extern/pybind11/pybind11
1718
include extern/pybind11/CMakeLists.txt
1819

1920
prune docs/_build

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
numpy
2-
pytest <6.1
2+
pytest !=6.1.0
33
pytest-benchmark
44
setuptools >=42
55
setuptools_scm[toml] >=3.4,!=4.0.0

docs/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
# What's new in boost-histogram
22

33
## Version 0.11
4+
5+
### Version 0.11.1
6+
7+
Updating pybind11 to 2.6.0. Features:
8+
9+
* Python 3.9 support
10+
* PyPy support
11+
* Warnings on latest AppleClang fixed
12+
* 40% faster accumulator fills, simpler implementation
13+
* Segfaults when passing an object with a throwing repr fixed
14+
* kwargs replaced older workarounds (partially at the moment)
15+
* Using new `py::type` instead of `pybind11::detail` usage
16+
* Enhanced CMake support, finds conda and venv now, uses `pybind11_find_import`
17+
* Using setuptools support from pybind11 (previously vendored, so benefits have been available since 0.11.0)
18+
419
### Version 0.11.0
520

621
A release focused on preparing for the upcoming Hist 2.0 release.

extern/pybind11

Submodule pybind11 updated 202 files

include/bh_python/array_like.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ py::array_t<T> array_like(py::object obj) {
2323
return py::array_t<T>(shape);
2424
}
2525
auto arr = py::cast<py::array>(obj);
26-
std::vector<ssize_t> strides;
26+
std::vector<py::ssize_t> strides;
2727
strides.reserve(static_cast<std::size_t>(arr.ndim()));
2828
for(int i = 0; i < arr.ndim(); ++i) {
2929
strides.emplace_back(arr.strides()[i] / arr.itemsize()
30-
* static_cast<ssize_t>(sizeof(T)));
30+
* static_cast<py::ssize_t>(sizeof(T)));
3131
}
32-
return py::array_t<T>(bh::detail::span<const ssize_t>(
33-
arr.shape(), static_cast<std::size_t>(arr.ndim())),
34-
strides);
32+
return py::array_t<T>{bh::detail::span<const py::ssize_t>{
33+
arr.shape(), static_cast<std::size_t>(arr.ndim())},
34+
strides};
3535
}

include/bh_python/axis.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ py::array_t<double> edges(const A& ax, bool flow = false, bool numpy_upper = fal
214214
= flow && (bh::axis::traits::get_options<AX>::test(option::overflow));
215215

216216
py::array_t<double> edges(
217-
static_cast<std::size_t>(ax.size() + 1 + overflow + underflow));
217+
static_cast<py::ssize_t>(ax.size() + 1 + overflow + underflow));
218218

219219
for(index_type i = -underflow; i <= ax.size() + overflow; ++i)
220220
edges.mutable_at(i + underflow) = ax.value(i);
@@ -238,7 +238,7 @@ py::array_t<double> edges(const A& ax, bool flow = false, bool numpy_upper = fal
238238
= flow && bh::axis::traits::get_options<AX>::test(option::overflow);
239239

240240
py::array_t<double> edges(
241-
static_cast<std::size_t>(ax.size() + 1 + overflow));
241+
static_cast<py::ssize_t>(ax.size() + 1 + overflow));
242242

243243
for(bh::axis::index_type i = 0; i <= ax.size() + overflow; ++i)
244244
edges.mutable_at(i) = i;
@@ -251,15 +251,15 @@ py::array_t<double> edges(const A& ax, bool flow = false, bool numpy_upper = fal
251251

252252
template <class A>
253253
py::array_t<double> centers(const A& ax) {
254-
py::array_t<double> result(static_cast<std::size_t>(ax.size()));
254+
py::array_t<double> result(ax.size());
255255
for(bh::axis::index_type i = 0; i < ax.size(); ++i)
256256
result.mutable_data()[i] = unchecked_center(ax, i);
257257
return result;
258258
}
259259

260260
template <class A>
261261
py::array_t<double> widths(const A& ax) {
262-
py::array_t<double> result(static_cast<std::size_t>(ax.size()));
262+
py::array_t<double> result(ax.size());
263263
bh::detail::static_if<bh::axis::traits::is_continuous<A>>(
264264
[](py::array_t<double>& result, const auto& ax) {
265265
std::transform(ax.begin(),

0 commit comments

Comments
 (0)