Skip to content

chore: drop Python 3.5 #3719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,18 @@ cmake --build build -j4

Tips:

* You can use `virtualenv` (from PyPI) instead of `venv` (which is Python 3
only).
* You can use `virtualenv` (faster, from PyPI) instead of `venv`.
* You can select any name for your environment folder; if it contains "env" it
will be ignored by git.
* If you dont have CMake 3.14+, just add cmake to the pip install command.
* If you don't have CMake 3.14+, just add "cmake" to the pip install command.
* You can use `-DPYBIND11_FINDPYTHON=ON` to use FindPython on CMake 3.12+
* In classic mode, you may need to set `-DPYTHON_EXECUTABLE=/path/to/python`.
FindPython uses `-DPython_ROOT_DIR=/path/to` or
`-DPython_EXECUTABLE=/path/to/python`.

### Configuration options

In CMake, configuration options are given with “-D”. Options are stored in the
In CMake, configuration options are given with "-D". Options are stored in the
build directory, in the `CMakeCache.txt` file, so they are remembered for each
build directory. Two selections are special - the generator, given with `-G`,
and the compiler, which is selected based on environment variables `CXX` and
Expand All @@ -115,7 +114,7 @@ after the initial run.
The valid options are:

* `-DCMAKE_BUILD_TYPE`: Release, Debug, MinSizeRel, RelWithDebInfo
* `-DPYBIND11_FINDPYTHON=ON`: Use CMake 3.12+s FindPython instead of the
* `-DPYBIND11_FINDPYTHON=ON`: Use CMake 3.12+'s FindPython instead of the
classic, deprecated, custom FindPythonLibs
* `-DPYBIND11_NOPYTHON=ON`: Disable all Python searching (disables tests)
* `-DBUILD_TESTING=ON`: Enable the tests
Expand Down Expand Up @@ -257,7 +256,7 @@ The report is sent to stderr; you can pipe it into a file if you wish.
### Build recipes

This builds with the Intel compiler (assuming it is in your path, along with a
recent CMake and Python 3):
recent CMake and Python):

```bash
python3 -m venv venv
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ concurrency:

env:
PIP_ONLY_BINARY: numpy
FORCE_COLOR: 3
PYTEST_TIMEOUT: 300

jobs:
# This is the "main" test suite, which tests a large number of different
Expand All @@ -25,7 +27,6 @@ jobs:
matrix:
runs-on: [ubuntu-latest, windows-2022, macos-latest]
python:
- '3.5'
- '3.6'
- '3.9'
- '3.10'
Expand Down Expand Up @@ -167,7 +168,7 @@ jobs:
# setuptools
- name: Setuptools helpers test
run: pytest tests/extra_setuptools
if: "!(matrix.python == '3.5' && matrix.runs-on == 'windows-2022')"
if: "!(matrix.runs-on == 'windows-2022')"


deadsnakes:
Expand Down Expand Up @@ -624,9 +625,9 @@ jobs:

# This tests an "install" with the CMake tools
install-classic:
name: "🐍 3.5 • Debian • x86 • Install"
name: "🐍 3.7 • Debian • x86 • Install"
runs-on: ubuntu-latest
container: i386/debian:stretch
container: i386/debian:buster

steps:
- uses: actions/checkout@v1
Expand All @@ -635,7 +636,7 @@ jobs:
run: |
apt-get update
apt-get install -y git make cmake g++ libeigen3-dev python3-dev python3-pip
pip3 install "pytest==3.1.*"
pip3 install "pytest==6.*"

- name: Configure for install
run: >
Expand Down Expand Up @@ -704,12 +705,10 @@ jobs:
fail-fast: false
matrix:
python:
- 3.5
- 3.6
- 3.7
- 3.8
- 3.9
- pypy-3.6

include:
- python: 3.9
Expand Down Expand Up @@ -810,7 +809,7 @@ jobs:
fail-fast: false
matrix:
python:
- 3.5
- 3.6
- 3.7
std:
- 14
Expand Down
39 changes: 22 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: "v4.1.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -32,59 +32,64 @@ repos:

# Upgrade old Python syntax
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
rev: "v2.31.0"
hooks:
- id: pyupgrade
args: [--py3-plus]
args: [--py36-plus]

# Nicely sort includes
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: "5.10.1"
hooks:
- id: isort

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

# Also code format the docs
- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
rev: "v1.12.1"
hooks:
- id: blacken-docs
additional_dependencies:
- black==22.1.0 # keep in sync with black hook

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

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

# Autoremoves unused imports
- repo: https://github.com/hadialqattan/pycln
rev: v1.1.0
rev: "v1.1.0"
hooks:
- id: pycln

# Checking for common mistakes
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
rev: "v1.9.0"
hooks:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-no-log-warn
# Python 3.6
# - id: python-use-type-annotations
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

# Flake8 also supports pre-commit natively (same author)
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: "4.0.1"
hooks:
- id: flake8
additional_dependencies: &flake8_dependencies
Expand All @@ -94,14 +99,14 @@ repos:

# Automatically remove noqa that are not used
- repo: https://github.com/asottile/yesqa
rev: v1.3.0
rev: "v1.3.0"
hooks:
- id: yesqa
additional_dependencies: *flake8_dependencies

# CMake formatting
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
rev: "v0.6.13"
hooks:
- id: cmake-format
additional_dependencies: [pyyaml]
Expand All @@ -110,7 +115,7 @@ repos:

# Check static types with mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.931
rev: "v0.931"
hooks:
- id: mypy
args: [--show-error-codes]
Expand All @@ -128,15 +133,15 @@ repos:

# Check for spelling
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
rev: "v2.1.0"
hooks:
- id: codespell
exclude: ".supp$"
args: ["-L", "nd,ot,thist"]

# Check for common shell mistakes
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.8.0.4
rev: "v0.8.0.4"
hooks:
- id: shellcheck

Expand Down
14 changes: 7 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ this heavy machinery has become an excessively large and unnecessary
dependency.

Think of this library as a tiny self-contained version of Boost.Python
with everything stripped away that isnt relevant for binding
with everything stripped away that isn't relevant for binding
generation. Without comments, the core header files only require ~4K
lines of code and depend on Python (3.5+, or PyPy) and the C++
lines of code and depend on Python (3.6+, or PyPy) and the C++
standard library. This compact implementation was possible thanks to
some of the new C++11 language features (specifically: tuples, lambda
functions and variadic templates). Since its creation, this library has
Expand Down Expand Up @@ -78,8 +78,8 @@ Goodies
In addition to the core functionality, pybind11 provides some extra
goodies:

- Python 3.5+, and PyPy3 7.3 are supported with an implementation-agnostic
interface (pybind11 2.9 was the last version to support Python 2).
- Python 3.6+, and PyPy3 7.3 are supported with an implementation-agnostic
interface (pybind11 2.9 was the last version to support Python 2 and 3.5).

- It is possible to bind C++11 lambda functions with captured
variables. The lambda capture data is stored inside the resulting
Expand All @@ -88,8 +88,8 @@ goodies:
- pybind11 uses C++11 move constructors and move assignment operators
whenever possible to efficiently transfer custom data types.

- Its easy to expose the internal storage of custom data types through
Pythons buffer protocols. This is handy e.g. for fast conversion
- It's easy to expose the internal storage of custom data types through
Pythons' buffer protocols. This is handy e.g. for fast conversion
between C++ matrix classes like Eigen and NumPy without expensive
copy operations.

Expand Down Expand Up @@ -119,7 +119,7 @@ goodies:
Supported compilers
-------------------

1. Clang/LLVM 3.3 or newer (for Apple Xcodes clang, this is 5.0.0 or
1. Clang/LLVM 3.3 or newer (for Apple Xcode's clang, this is 5.0.0 or
newer)
2. GCC 4.8 or newer
3. Microsoft Visual Studio 2015 Update 3 or newer
Expand Down
3 changes: 1 addition & 2 deletions docs/advanced/cast/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,4 @@ as arguments and return values, refer to the section on binding :ref:`classes`.
+------------------------------------+---------------------------+-----------------------------------+

.. [#] ``std::filesystem::path`` is converted to ``pathlib.Path`` and
``os.PathLike`` is converted to ``std::filesystem::path``, but this requires
Python 3.6 (for ``__fspath__`` support).
``os.PathLike`` is converted to ``std::filesystem::path``.
21 changes: 10 additions & 11 deletions docs/advanced/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ like so:
Keyword-only arguments
======================

Python 3 introduced keyword-only arguments by specifying an unnamed ``*``
Python implements keyword-only arguments by specifying an unnamed ``*``
argument in a function definition:

.. code-block:: python
Expand All @@ -395,19 +395,18 @@ argument annotations when registering the function:
m.def("f", [](int a, int b) { /* ... */ },
py::arg("a"), py::kw_only(), py::arg("b"));

Note that you currently cannot combine this with a ``py::args`` argument. This
feature does *not* require Python 3 to work.

.. versionadded:: 2.6

As of pybind11 2.9, a ``py::args`` argument implies that any following arguments
are keyword-only, as if ``py::kw_only()`` had been specified in the same
relative location of the argument list as the ``py::args`` argument. The
``py::kw_only()`` may be included to be explicit about this, but is not
required. (Prior to 2.9 ``py::args`` may only occur at the end of the argument
list, or immediately before a ``py::kwargs`` argument at the end).
A ``py::args`` argument implies that any following arguments are keyword-only,
as if ``py::kw_only()`` had been specified in the same relative location of the
argument list as the ``py::args`` argument. The ``py::kw_only()`` may be
included to be explicit about this, but is not required.

.. versionchanged:: 2.9
This can now be combined with ``py::args``. Before, ``py::args`` could only
occur at the end of the argument list, or immediately before a ``py::kwargs``
argument at the end.

.. versionadded:: 2.9

Positional-only arguments
=========================
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced/pycpp/numpy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ uses of ``py::array``:
Ellipsis
========

Python 3 provides a convenient ``...`` ellipsis notation that is often used to
Python provides a convenient ``...`` ellipsis notation that is often used to
slice multidimensional arrays. For instance, the following snippet extracts the
middle dimensions of a tensor with the first and last index set to zero.

Expand Down
25 changes: 11 additions & 14 deletions docs/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ def generate_dummy_code_pybind11(nclasses=10):
bindings = ""

for cl in range(nclasses):
decl += "class cl%03i;\n" % cl
decl += f"class cl{cl:03};\n"
decl += "\n"

for cl in range(nclasses):
decl += "class cl%03i {\n" % cl
decl += f"class {cl:03} {{\n"
decl += "public:\n"
bindings += ' py::class_<cl%03i>(m, "cl%03i")\n' % (cl, cl)
bindings += f' py::class_<cl{cl:03}>(m, "cl{cl:03}")\n'
for fn in range(nfns):
ret = random.randint(0, nclasses - 1)
params = [random.randint(0, nclasses - 1) for i in range(nargs)]
decl += " cl%03i *fn_%03i(" % (ret, fn)
decl += ", ".join("cl%03i *" % p for p in params)
decl += f" cl{ret:03} *fn_{fn:03}("
decl += ", ".join(f"cl{p:03} *" for p in params)
decl += ");\n"
bindings += ' .def("fn_%03i", &cl%03i::fn_%03i)\n' % (fn, cl, fn)
bindings += f' .def("fn_{fn:03}", &cl{cl:03}::fn_{fn:03})\n'
decl += "};\n\n"
bindings += " ;\n"

Expand All @@ -42,23 +42,20 @@ def generate_dummy_code_boost(nclasses=10):
bindings = ""

for cl in range(nclasses):
decl += "class cl%03i;\n" % cl
decl += f"class cl{cl:03};\n"
decl += "\n"

for cl in range(nclasses):
decl += "class cl%03i {\n" % cl
decl += "public:\n"
bindings += ' py::class_<cl%03i>("cl%03i")\n' % (cl, cl)
bindings += f' py::class_<cl{cl:03}>("cl{cl:03}")\n'
for fn in range(nfns):
ret = random.randint(0, nclasses - 1)
params = [random.randint(0, nclasses - 1) for i in range(nargs)]
decl += " cl%03i *fn_%03i(" % (ret, fn)
decl += ", ".join("cl%03i *" % p for p in params)
decl += f" cl{ret:03} *fn_{fn:03}("
decl += ", ".join(f"cl{p:03} *" for p in params)
decl += ");\n"
bindings += (
' .def("fn_%03i", &cl%03i::fn_%03i, py::return_value_policy<py::manage_new_object>())\n'
% (fn, cl, fn)
)
bindings += f' .def("fn_{fn:03}", &cl{cl:03}::fn_{fn:03}, py::return_value_policy<py::manage_new_object>())\n'
decl += "};\n\n"
bindings += " ;\n"

Expand Down
Loading