Skip to content

Commit

Permalink
Merge commit 'fab1eebe2c4c~' into feature-bump-merge-curated-moar
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/ci.yml
#	.github/workflows/pip.yml
#	tests/test_class.cpp
#	tests/test_class.py
  • Loading branch information
EricCousineau-TRI committed Oct 12, 2023
2 parents e61bb56 + b926396 commit 7d1fc18
Show file tree
Hide file tree
Showing 58 changed files with 910 additions and 293 deletions.
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Checks: |
-bugprone-unused-raii,
CheckOptions:
- key: modernize-use-equals-default.IgnoreMacros
value: false
- key: performance-for-range-copy.WarnOnAllAutoCopies
value: true
- key: performance-inefficient-string-concatenation.StrictMode
Expand Down
24 changes: 24 additions & 0 deletions .codespell-ignore-lines
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
template <op_id id, op_type ot, typename L = undefined_t, typename R = undefined_t>
template <typename ThisT>
auto &this_ = static_cast<ThisT &>(*this);
if (load_impl<ThisT>(temp, false)) {
ssize_t nd = 0;
auto trivial = broadcast(buffers, nd, shape);
auto ndim = (size_t) nd;
int nd;
ssize_t ndim() const { return detail::array_proxy(m_ptr)->nd; }
using op = op_impl<id, ot, Base, L_type, R_type>;
template <op_id id, op_type ot, typename L, typename R>
template <detail::op_id id, detail::op_type ot, typename L, typename R, typename... Extra>
class_ &def(const detail::op_<id, ot, L, R> &op, const Extra &...extra) {
class_ &def_cast(const detail::op_<id, ot, L, R> &op, const Extra &...extra) {
@pytest.mark.parametrize("access", ["ro", "rw", "static_ro", "static_rw"])
struct IntStruct {
explicit IntStruct(int v) : value(v){};
~IntStruct() { value = -value; }
IntStruct(const IntStruct &) = default;
IntStruct &operator=(const IntStruct &) = default;
py::class_<IntStruct>(m, "IntStruct").def(py::init([](const int i) { return IntStruct(i); }));
py::implicitly_convertible<int, IntStruct>();
m.def("test", [](int expected, const IntStruct &in) {
[](int expected, const IntStruct &in) {
49 changes: 29 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
run: brew install boost

- name: Update CMake
uses: jwlawson/actions-setup-cmake@v1.12
uses: jwlawson/actions-setup-cmake@v1.13

- name: Cache wheels
if: runner.os == 'macOS'
Expand Down Expand Up @@ -201,7 +201,7 @@ jobs:
# debug: ${{ matrix.python-debug }}

# - name: Update CMake
# uses: jwlawson/actions-setup-cmake@v1.12
# uses: jwlawson/actions-setup-cmake@v1.13

# - name: Valgrind cache
# if: matrix.valgrind
Expand Down Expand Up @@ -280,6 +280,12 @@ jobs:
std: 20
- clang: 10
std: 17
- clang: 11
std: 20
- clang: 12
std: 20
- clang: 13
std: 20
- clang: 14
std: 20

Expand Down Expand Up @@ -317,8 +323,8 @@ jobs:
# # Testing NVCC; forces sources to behave like .cu files
# cuda:
# runs-on: ubuntu-latest
# name: "🐍 3.8 • CUDA 11.2 • Ubuntu 20.04"
# container: nvidia/cuda:11.2.2-devel-ubuntu20.04
# name: "🐍 3.10 • CUDA 11.7 • Ubuntu 22.04"
# container: nvidia/cuda:11.7.0-devel-ubuntu22.04

# steps:
# - uses: actions/checkout@v3
Expand Down Expand Up @@ -440,14 +446,14 @@ jobs:
strategy:
fail-fast: false
matrix:
gcc:
- 7
- latest
std:
- 11
include:
- gcc: 10
std: 20
- { gcc: 7, std: 11 }
- { gcc: 7, std: 17 }
- { gcc: 8, std: 14 }
- { gcc: 8, std: 17 }
- { gcc: 10, std: 17 }
- { gcc: 11, std: 20 }
- { gcc: 12, std: 20 }

name: "🐍 3 • GCC ${{ matrix.gcc }} • C++${{ matrix.std }}• x64"
container: "gcc:${{ matrix.gcc }}"
Expand All @@ -462,7 +468,7 @@ jobs:
run: python3 -m pip install --upgrade pip

- name: Update CMake
uses: jwlawson/actions-setup-cmake@v1.12
uses: jwlawson/actions-setup-cmake@v1.13

- name: Configure
shell: bash
Expand Down Expand Up @@ -736,6 +742,9 @@ jobs:
# args: -DCMAKE_CXX_STANDARD=20
# - python: 3.8
# args: -DCMAKE_CXX_STANDARD=17
- python: 3.7
args: -DCMAKE_CXX_STANDARD=14


# name: "🐍 ${{ matrix.python }} • MSVC 2019 • x86 ${{ matrix.args }}"
# runs-on: windows-2019
Expand All @@ -750,10 +759,10 @@ jobs:
# architecture: x86

# - name: Update CMake
# uses: jwlawson/actions-setup-cmake@v1.12
# uses: jwlawson/actions-setup-cmake@v1.13

# - name: Prepare MSVC
# uses: ilammy/msvc-dev-cmd@v1.10.0
# uses: ilammy/msvc-dev-cmd@v1.12.0
# with:
# arch: x86

Expand Down Expand Up @@ -803,10 +812,10 @@ jobs:
# architecture: x86

# - name: Update CMake
# uses: jwlawson/actions-setup-cmake@v1.12
# uses: jwlawson/actions-setup-cmake@v1.13

# - name: Prepare MSVC
# uses: ilammy/msvc-dev-cmd@v1.10.0
# uses: ilammy/msvc-dev-cmd@v1.12.0
# with:
# arch: x86

Expand Down Expand Up @@ -854,7 +863,7 @@ jobs:
# python3 -m pip install -r tests/requirements.txt

# - name: Update CMake
# uses: jwlawson/actions-setup-cmake@v1.12
# uses: jwlawson/actions-setup-cmake@v1.13

# - name: Configure C++20
# run: >
Expand Down Expand Up @@ -911,7 +920,7 @@ jobs:
# - name: Configure C++11
# # LTO leads to many undefined reference like
# # `pybind11::detail::function_call::function_call(pybind11::detail::function_call&&)
# run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=11 -DDOWNLOAD_CATCH=ON -S . -B build
# run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=11 -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build

# - name: Build C++11
# run: cmake --build build -j 2
Expand All @@ -929,7 +938,7 @@ jobs:
# run: git clean -fdx

# - name: Configure C++14
# run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=14 -DDOWNLOAD_CATCH=ON -S . -B build2
# run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=14 -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build2

# - name: Build C++14
# run: cmake --build build2 -j 2
Expand All @@ -947,7 +956,7 @@ jobs:
# run: git clean -fdx

# - name: Configure C++17
# run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=17 -DDOWNLOAD_CATCH=ON -S . -B build3
# run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=17 -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build3

# - name: Build C++17
# run: cmake --build build3 -j 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
# An action for adding a specific version of CMake:
# https://github.com/jwlawson/actions-setup-cmake
- name: Setup CMake ${{ matrix.cmake }}
uses: jwlawson/actions-setup-cmake@v1.12
uses: jwlawson/actions-setup-cmake@v1.13
with:
cmake-version: ${{ matrix.cmake }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
run: sudo apt-get install libboost-dev

- name: Update CMake
uses: jwlawson/actions-setup-cmake@v1.12
uses: jwlawson/actions-setup-cmake@v1.13

- name: Prepare env
run: |
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
run: cmake --build build3 --target pytest

- name: Interface test
run: cmake --build build2 --target test_cmake_build
run: cmake --build build3 --target test_cmake_build

# This makes sure the setup_helpers module can build packages using
# setuptools
Expand Down
35 changes: 23 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
#
# See https://github.com/pre-commit/pre-commit


ci:
autoupdate_commit_msg: "chore(deps): update pre-commit hooks"
autofix_commit_msg: "style: pre-commit fixes"
autoupdate_schedule: monthly

# third-party content
exclude: ^tools/JoinPaths.cmake$

repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -32,7 +41,7 @@ repos:

# Upgrade old Python syntax
- repo: https://github.com/asottile/pyupgrade
rev: "v2.37.1"
rev: "v2.38.2"
hooks:
- id: pyupgrade
args: [--py36-plus]
Expand All @@ -45,7 +54,7 @@ repos:

# Black, the code formatter, natively supports pre-commit
- repo: https://github.com/psf/black
rev: "22.6.0" # Keep in sync with blacken-docs
rev: "22.8.0" # Keep in sync with blacken-docs
hooks:
- id: black

Expand All @@ -55,23 +64,23 @@ repos:
hooks:
- id: blacken-docs
additional_dependencies:
- black==22.6.0 # keep in sync with black hook
- black==22.8.0 # keep in sync with black hook

# Changes tabs to spaces
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: "v1.3.0"
rev: "v1.3.1"
hooks:
- id: remove-tabs

- repo: https://github.com/sirosen/texthooks
rev: "0.3.1"
rev: "0.4.0"
hooks:
- id: fix-ligatures
- id: fix-smartquotes

# Autoremoves unused imports
- repo: https://github.com/hadialqattan/pycln
rev: "v2.0.1"
rev: "v2.1.1"
hooks:
- id: pycln
stages: [manual]
Expand All @@ -90,7 +99,7 @@ repos:

# Automatically remove noqa that are not used
- repo: https://github.com/asottile/yesqa
rev: "v1.3.0"
rev: "v1.4.0"
hooks:
- id: yesqa
additional_dependencies: &flake8_dependencies
Expand All @@ -99,15 +108,15 @@ repos:

# Flake8 also supports pre-commit natively (same author)
- repo: https://github.com/PyCQA/flake8
rev: "4.0.1"
rev: "5.0.4"
hooks:
- id: flake8
exclude: ^(docs/.*|tools/.*)$
additional_dependencies: *flake8_dependencies

# PyLint has native support - not always usable, but works for us
- repo: https://github.com/PyCQA/pylint
rev: "v2.14.4"
rev: "v2.15.3"
hooks:
- id: pylint
files: ^pybind11
Expand All @@ -123,7 +132,7 @@ repos:

# Check static types with mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v0.961"
rev: "v0.981"
hooks:
- id: mypy
args: []
Expand All @@ -140,12 +149,14 @@ repos:
additional_dependencies: [cmake, ninja]

# Check for spelling
# Use tools/codespell_ignore_lines_from_errors.py
# to rebuild .codespell-ignore-lines
- repo: https://github.com/codespell-project/codespell
rev: "v2.1.0"
rev: "v2.2.1"
hooks:
- id: codespell
exclude: ".supp$"
args: ["-L", "nd,ot,thist"]
args: ["-x", ".codespell-ignore-lines"]

# Check for common shell mistakes
- repo: https://github.com/shellcheck-py/shellcheck-py
Expand Down
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ else()
endif()

include("${CMAKE_CURRENT_SOURCE_DIR}/tools/pybind11Common.cmake")
# https://github.com/jtojnar/cmake-snips/#concatenating-paths-when-building-pkg-config-files
# TODO: cmake 3.20 adds the cmake_path() function, which obsoletes this snippet
include("${CMAKE_CURRENT_SOURCE_DIR}/tools/JoinPaths.cmake")

# Relative directory setting
if(USE_PYTHON_INCLUDE_DIR AND DEFINED Python_INCLUDE_DIRS)
Expand Down Expand Up @@ -262,6 +265,16 @@ if(PYBIND11_INSTALL)
NAMESPACE "pybind11::"
DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR})

# pkg-config support
if(NOT prefix_for_pc_file)
set(prefix_for_pc_file "${CMAKE_INSTALL_PREFIX}")
endif()
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/pybind11.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/pybind11.pc" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pybind11.pc"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig/")

# Uninstall target
if(PYBIND11_MASTER_PROJECT)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake_uninstall.cmake.in"
Expand Down
4 changes: 2 additions & 2 deletions docs/advanced/cast/custom.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type is explicitly allowed.

.. code-block:: cpp
namespace pybind11 { namespace detail {
namespace PYBIND11_NAMESPACE { namespace detail {
template <> struct type_caster<inty> {
public:
/**
Expand Down Expand Up @@ -78,7 +78,7 @@ type is explicitly allowed.
return PyLong_FromLong(src.long_value);
}
};
}} // namespace pybind11::detail
}} // namespace PYBIND11_NAMESPACE::detail
.. note::

Expand Down
6 changes: 3 additions & 3 deletions docs/advanced/cast/stl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ types:
.. code-block:: cpp
// `boost::optional` as an example -- can be any `std::optional`-like container
namespace pybind11 { namespace detail {
namespace PYBIND11_NAMESPACE { namespace detail {
template <typename T>
struct type_caster<boost::optional<T>> : optional_caster<boost::optional<T>> {};
}}
Expand All @@ -54,7 +54,7 @@ for custom variant types:
.. code-block:: cpp
// `boost::variant` as an example -- can be any `std::variant`-like container
namespace pybind11 { namespace detail {
namespace PYBIND11_NAMESPACE { namespace detail {
template <typename... Ts>
struct type_caster<boost::variant<Ts...>> : variant_caster<boost::variant<Ts...>> {};
Expand All @@ -66,7 +66,7 @@ for custom variant types:
return boost::apply_visitor(args...);
}
};
}} // namespace pybind11::detail
}} // namespace PYBIND11_NAMESPACE::detail
The ``visit_helper`` specialization is not required if your ``name::variant`` provides
a ``name::visit()`` function. For any other function name, the specialization must be
Expand Down
Loading

0 comments on commit 7d1fc18

Please sign in to comment.