Skip to content

Commit 522c59c

Browse files
henryiiiSkylion007rwgk
authored
chore: drop Python 3.5 (pybind#3719)
* chore: drop Python 3.5 support * chore: more fstrings with flynt's help * ci: drop Python 3.5 * chore: bump dependency versions * docs: touch up py::args * tests: remove deprecation warning * Ban smartquotes * Very minor tweaks (by-product of reviewing PR pybind#3719). Co-authored-by: Aaron Gokaslan <[email protected]> Co-authored-by: Ralf W. Grosse-Kunstleve <[email protected]>
1 parent 1a432b4 commit 522c59c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+171
-241
lines changed

.github/CONTRIBUTING.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,18 @@ cmake --build build -j4
9393

9494
Tips:
9595

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

106105
### Configuration options
107106

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

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

259258
This builds with the Intel compiler (assuming it is in your path, along with a
260-
recent CMake and Python 3):
259+
recent CMake and Python):
261260

262261
```bash
263262
python3 -m venv venv

.github/workflows/ci.yml

+7-8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ concurrency:
1515

1616
env:
1717
PIP_ONLY_BINARY: numpy
18+
FORCE_COLOR: 3
19+
PYTEST_TIMEOUT: 300
1820

1921
jobs:
2022
# This is the "main" test suite, which tests a large number of different
@@ -25,7 +27,6 @@ jobs:
2527
matrix:
2628
runs-on: [ubuntu-latest, windows-2022, macos-latest]
2729
python:
28-
- '3.5'
2930
- '3.6'
3031
- '3.9'
3132
- '3.10'
@@ -167,7 +168,7 @@ jobs:
167168
# setuptools
168169
- name: Setuptools helpers test
169170
run: pytest tests/extra_setuptools
170-
if: "!(matrix.python == '3.5' && matrix.runs-on == 'windows-2022')"
171+
if: "!(matrix.runs-on == 'windows-2022')"
171172

172173

173174
deadsnakes:
@@ -624,9 +625,9 @@ jobs:
624625

625626
# This tests an "install" with the CMake tools
626627
install-classic:
627-
name: "🐍 3.5 • Debian • x86 • Install"
628+
name: "🐍 3.7 • Debian • x86 • Install"
628629
runs-on: ubuntu-latest
629-
container: i386/debian:stretch
630+
container: i386/debian:buster
630631

631632
steps:
632633
- uses: actions/checkout@v1
@@ -635,7 +636,7 @@ jobs:
635636
run: |
636637
apt-get update
637638
apt-get install -y git make cmake g++ libeigen3-dev python3-dev python3-pip
638-
pip3 install "pytest==3.1.*"
639+
pip3 install "pytest==6.*"
639640
640641
- name: Configure for install
641642
run: >
@@ -704,12 +705,10 @@ jobs:
704705
fail-fast: false
705706
matrix:
706707
python:
707-
- 3.5
708708
- 3.6
709709
- 3.7
710710
- 3.8
711711
- 3.9
712-
- pypy-3.6
713712

714713
include:
715714
- python: 3.9
@@ -810,7 +809,7 @@ jobs:
810809
fail-fast: false
811810
matrix:
812811
python:
813-
- 3.5
812+
- 3.6
814813
- 3.7
815814
std:
816815
- 14

.pre-commit-config.yaml

+22-17
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
repos:
1616
# Standard hooks
1717
- repo: https://github.com/pre-commit/pre-commit-hooks
18-
rev: v4.1.0
18+
rev: "v4.1.0"
1919
hooks:
2020
- id: check-added-large-files
2121
- id: check-case-conflict
@@ -32,59 +32,64 @@ repos:
3232

3333
# Upgrade old Python syntax
3434
- repo: https://github.com/asottile/pyupgrade
35-
rev: v2.31.0
35+
rev: "v2.31.0"
3636
hooks:
3737
- id: pyupgrade
38-
args: [--py3-plus]
38+
args: [--py36-plus]
3939

4040
# Nicely sort includes
4141
- repo: https://github.com/PyCQA/isort
42-
rev: 5.10.1
42+
rev: "5.10.1"
4343
hooks:
4444
- id: isort
4545

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

5252
# Also code format the docs
5353
- repo: https://github.com/asottile/blacken-docs
54-
rev: v1.12.1
54+
rev: "v1.12.1"
5555
hooks:
5656
- id: blacken-docs
5757
additional_dependencies:
5858
- black==22.1.0 # keep in sync with black hook
5959

6060
# Changes tabs to spaces
6161
- repo: https://github.com/Lucas-C/pre-commit-hooks
62-
rev: v1.1.11
62+
rev: "v1.1.11"
6363
hooks:
6464
- id: remove-tabs
6565

66+
- repo: https://github.com/sirosen/texthooks
67+
rev: "0.2.2"
68+
hooks:
69+
- id: fix-ligatures
70+
- id: fix-smartquotes
71+
6672
# Autoremoves unused imports
6773
- repo: https://github.com/hadialqattan/pycln
68-
rev: v1.1.0
74+
rev: "v1.1.0"
6975
hooks:
7076
- id: pycln
7177

7278
# Checking for common mistakes
7379
- repo: https://github.com/pre-commit/pygrep-hooks
74-
rev: v1.9.0
80+
rev: "v1.9.0"
7581
hooks:
7682
- id: python-check-blanket-noqa
7783
- id: python-check-blanket-type-ignore
7884
- id: python-no-log-warn
79-
# Python 3.6
80-
# - id: python-use-type-annotations
85+
- id: python-use-type-annotations
8186
- id: rst-backticks
8287
- id: rst-directive-colons
8388
- id: rst-inline-touching-normal
8489

8590
# Flake8 also supports pre-commit natively (same author)
8691
- repo: https://github.com/PyCQA/flake8
87-
rev: 4.0.1
92+
rev: "4.0.1"
8893
hooks:
8994
- id: flake8
9095
additional_dependencies: &flake8_dependencies
@@ -94,14 +99,14 @@ repos:
9499

95100
# Automatically remove noqa that are not used
96101
- repo: https://github.com/asottile/yesqa
97-
rev: v1.3.0
102+
rev: "v1.3.0"
98103
hooks:
99104
- id: yesqa
100105
additional_dependencies: *flake8_dependencies
101106

102107
# CMake formatting
103108
- repo: https://github.com/cheshirekow/cmake-format-precommit
104-
rev: v0.6.13
109+
rev: "v0.6.13"
105110
hooks:
106111
- id: cmake-format
107112
additional_dependencies: [pyyaml]
@@ -110,7 +115,7 @@ repos:
110115

111116
# Check static types with mypy
112117
- repo: https://github.com/pre-commit/mirrors-mypy
113-
rev: v0.931
118+
rev: "v0.931"
114119
hooks:
115120
- id: mypy
116121
args: [--show-error-codes]
@@ -128,15 +133,15 @@ repos:
128133

129134
# Check for spelling
130135
- repo: https://github.com/codespell-project/codespell
131-
rev: v2.1.0
136+
rev: "v2.1.0"
132137
hooks:
133138
- id: codespell
134139
exclude: ".supp$"
135140
args: ["-L", "nd,ot,thist"]
136141

137142
# Check for common shell mistakes
138143
- repo: https://github.com/shellcheck-py/shellcheck-py
139-
rev: v0.8.0.4
144+
rev: "v0.8.0.4"
140145
hooks:
141146
- id: shellcheck
142147

README.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ this heavy machinery has become an excessively large and unnecessary
3232
dependency.
3333

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

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

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

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

@@ -119,7 +119,7 @@ goodies:
119119
Supported compilers
120120
-------------------
121121

122-
1. Clang/LLVM 3.3 or newer (for Apple Xcodes clang, this is 5.0.0 or
122+
1. Clang/LLVM 3.3 or newer (for Apple Xcode's clang, this is 5.0.0 or
123123
newer)
124124
2. GCC 4.8 or newer
125125
3. Microsoft Visual Studio 2015 Update 3 or newer

docs/advanced/cast/overview.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,4 @@ as arguments and return values, refer to the section on binding :ref:`classes`.
167167
+------------------------------------+---------------------------+-----------------------------------+
168168

169169
.. [#] ``std::filesystem::path`` is converted to ``pathlib.Path`` and
170-
``os.PathLike`` is converted to ``std::filesystem::path``, but this requires
171-
Python 3.6 (for ``__fspath__`` support).
170+
``os.PathLike`` is converted to ``std::filesystem::path``.

docs/advanced/functions.rst

+10-11
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ like so:
372372
Keyword-only arguments
373373
======================
374374

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

378378
.. code-block:: python
@@ -395,19 +395,18 @@ argument annotations when registering the function:
395395
m.def("f", [](int a, int b) { /* ... */ },
396396
py::arg("a"), py::kw_only(), py::arg("b"));
397397
398-
Note that you currently cannot combine this with a ``py::args`` argument. This
399-
feature does *not* require Python 3 to work.
400-
401398
.. versionadded:: 2.6
402399

403-
As of pybind11 2.9, a ``py::args`` argument implies that any following arguments
404-
are keyword-only, as if ``py::kw_only()`` had been specified in the same
405-
relative location of the argument list as the ``py::args`` argument. The
406-
``py::kw_only()`` may be included to be explicit about this, but is not
407-
required. (Prior to 2.9 ``py::args`` may only occur at the end of the argument
408-
list, or immediately before a ``py::kwargs`` argument at the end).
400+
A ``py::args`` argument implies that any following arguments are keyword-only,
401+
as if ``py::kw_only()`` had been specified in the same relative location of the
402+
argument list as the ``py::args`` argument. The ``py::kw_only()`` may be
403+
included to be explicit about this, but is not required.
404+
405+
.. versionchanged:: 2.9
406+
This can now be combined with ``py::args``. Before, ``py::args`` could only
407+
occur at the end of the argument list, or immediately before a ``py::kwargs``
408+
argument at the end.
409409

410-
.. versionadded:: 2.9
411410

412411
Positional-only arguments
413412
=========================

docs/advanced/pycpp/numpy.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ uses of ``py::array``:
395395
Ellipsis
396396
========
397397

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

docs/benchmark.py

+11-14
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ def generate_dummy_code_pybind11(nclasses=10):
1111
bindings = ""
1212

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

1717
for cl in range(nclasses):
18-
decl += "class cl%03i {\n" % cl
18+
decl += f"class {cl:03} {{\n"
1919
decl += "public:\n"
20-
bindings += ' py::class_<cl%03i>(m, "cl%03i")\n' % (cl, cl)
20+
bindings += f' py::class_<cl{cl:03}>(m, "cl{cl:03}")\n'
2121
for fn in range(nfns):
2222
ret = random.randint(0, nclasses - 1)
2323
params = [random.randint(0, nclasses - 1) for i in range(nargs)]
24-
decl += " cl%03i *fn_%03i(" % (ret, fn)
25-
decl += ", ".join("cl%03i *" % p for p in params)
24+
decl += f" cl{ret:03} *fn_{fn:03}("
25+
decl += ", ".join(f"cl{p:03} *" for p in params)
2626
decl += ");\n"
27-
bindings += ' .def("fn_%03i", &cl%03i::fn_%03i)\n' % (fn, cl, fn)
27+
bindings += f' .def("fn_{fn:03}", &cl{cl:03}::fn_{fn:03})\n'
2828
decl += "};\n\n"
2929
bindings += " ;\n"
3030

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

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

4848
for cl in range(nclasses):
4949
decl += "class cl%03i {\n" % cl
5050
decl += "public:\n"
51-
bindings += ' py::class_<cl%03i>("cl%03i")\n' % (cl, cl)
51+
bindings += f' py::class_<cl{cl:03}>("cl{cl:03}")\n'
5252
for fn in range(nfns):
5353
ret = random.randint(0, nclasses - 1)
5454
params = [random.randint(0, nclasses - 1) for i in range(nargs)]
55-
decl += " cl%03i *fn_%03i(" % (ret, fn)
56-
decl += ", ".join("cl%03i *" % p for p in params)
55+
decl += f" cl{ret:03} *fn_{fn:03}("
56+
decl += ", ".join(f"cl{p:03} *" for p in params)
5757
decl += ");\n"
58-
bindings += (
59-
' .def("fn_%03i", &cl%03i::fn_%03i, py::return_value_policy<py::manage_new_object>())\n'
60-
% (fn, cl, fn)
61-
)
58+
bindings += f' .def("fn_{fn:03}", &cl{cl:03}::fn_{fn:03}, py::return_value_policy<py::manage_new_object>())\n'
6259
decl += "};\n\n"
6360
bindings += " ;\n"
6461

0 commit comments

Comments
 (0)