Skip to content

Commit f1a2e03

Browse files
rwgkhenryiii
andauthored
feat: remove Python 3.6 support (#5177)
* Change Python version guard: PYTHON < 3.7 IS UNSUPPORTED. * Replace or remove Python 3.6 jobs. * Move appveyor to Python 3.8 * Change `[tool.pylint]` `master.py-version` from `3.6` to `3.8` * Change `[tool.pylint]` `master.py-version` to `3.7` * Remove `centos:7` job; Change almalinux:8 job to use Python 3.8 * Try 🐍 3.8 • ubuntu-20.04 • x64 without `-DCMAKE_CXX_FLAGS="-D_=1"` * Update setup.cfg as suggested by @henryiii * Try running `cmake --build . --target cpptest` on all platforms (`standard` job). * Disable deadsnakes jobs entirely. * Apply PR #5179: Add Python 3.10, 3.11, 3.12 to win32 job matrix. * Add back `-DCMAKE_CXX_FLAGS="-D_=1"` but do not install boost in that case. * PY_VERSION_HEX < 3.7 cleanup pass: include/pybind11 * WITH_THREAD cleanup pass: include/pybind11 * Undo incorrect change. * Revert "Disable deadsnakes jobs entirely." This reverts commit bbcd008. * WITH_THREAD cleanup pass: tests/ * Change Python version guard in pybind11/__init__.py: pybind11 does not support Python < 3.7. * Misc cleanup pass * chore: use future imports Signed-off-by: Henry Schreiner <[email protected]> * Update tests/test_numpy_array.py * Update test_numpy_array.py --------- Signed-off-by: Henry Schreiner <[email protected]> Co-authored-by: Henry Schreiner <[email protected]>
1 parent 5552cbf commit f1a2e03

File tree

84 files changed

+238
-219
lines changed

Some content is hidden

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

84 files changed

+238
-219
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ platform:
99
- x86
1010
environment:
1111
matrix:
12-
- PYTHON: 36
12+
- PYTHON: 38
1313
CONFIG: Debug
1414
install:
1515
- ps: |

.github/workflows/ci.yml

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
matrix:
3333
runs-on: [ubuntu-20.04, windows-2022, macos-13]
3434
python:
35-
- '3.6'
35+
- '3.8'
3636
- '3.9'
3737
- '3.12'
3838
- '3.13'
@@ -48,16 +48,17 @@ jobs:
4848
include:
4949
# Just add a key
5050
- runs-on: ubuntu-20.04
51-
python: '3.6'
51+
python: '3.8'
5252
args: >
5353
-DPYBIND11_FINDPYTHON=ON
5454
-DCMAKE_CXX_FLAGS="-D_=1"
55+
exercise_D_: 1
5556
- runs-on: ubuntu-20.04
5657
python: 'pypy-3.8'
5758
args: >
5859
-DPYBIND11_FINDPYTHON=ON
5960
- runs-on: windows-2019
60-
python: '3.6'
61+
python: '3.8'
6162
args: >
6263
-DPYBIND11_FINDPYTHON=ON
6364
# Inject a couple Windows 2019 runs
@@ -82,7 +83,7 @@ jobs:
8283

8384
- name: Setup Boost (Linux)
8485
# Can't use boost + define _
85-
if: runner.os == 'Linux' && matrix.python != '3.6'
86+
if: runner.os == 'Linux' && matrix.exercise_D_ != 1
8687
run: sudo apt-get install libboost-dev
8788

8889
- name: Setup Boost (macOS)
@@ -655,15 +656,13 @@ jobs:
655656
cmake --build build-17 --target test_cmake_build
656657
657658
658-
# Testing on CentOS (manylinux uses a centos base, and this is an easy way
659-
# to get GCC 4.8, which is the manylinux1 compiler).
659+
# Testing on CentOS (manylinux uses a centos base).
660660
centos:
661661
runs-on: ubuntu-latest
662662
strategy:
663663
fail-fast: false
664664
matrix:
665665
container:
666-
- "centos:7" # GCC 4.8
667666
- "almalinux:8"
668667
- "almalinux:9"
669668

@@ -673,18 +672,13 @@ jobs:
673672
steps:
674673
- name: Latest actions/checkout
675674
uses: actions/checkout@v4
676-
if: matrix.container != 'centos:7'
677-
678-
- name: Pin actions/checkout as required for centos:7
679-
uses: actions/checkout@v3
680-
if: matrix.container == 'centos:7'
681675

682-
- name: Add Python 3 (RHEL 7)
683-
if: matrix.container == 'centos:7'
684-
run: yum update -y && yum install -y python3-devel gcc-c++ make git
676+
- name: Add Python 3.8
677+
if: matrix.container == 'almalinux:8'
678+
run: dnf update -y && dnf install -y python38-devel gcc-c++ make git
685679

686-
- name: Add Python 3 (RHEL 8+)
687-
if: matrix.container != 'centos:7'
680+
- name: Add Python 3 (default)
681+
if: matrix.container != 'almalinux:8'
688682
run: dnf update -y && dnf install -y python3-devel gcc-c++ make git
689683

690684
- name: Update pip
@@ -807,7 +801,6 @@ jobs:
807801
fail-fast: false
808802
matrix:
809803
python:
810-
- '3.6'
811804
- '3.7'
812805
- '3.8'
813806
- '3.9'

.github/workflows/pip.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,18 @@ env:
2121

2222
jobs:
2323
# This builds the sdists and wheels and makes sure the files are exactly as
24-
# expected. Using Windows and Python 3.6, since that is often the most
25-
# challenging matrix element.
24+
# expected.
2625
test-packaging:
27-
name: 🐍 3.6 • 📦 tests • windows-latest
26+
name: 🐍 3.8 • 📦 tests • windows-latest
2827
runs-on: windows-latest
2928

3029
steps:
3130
- uses: actions/checkout@v4
3231

33-
- name: Setup 🐍 3.6
32+
- name: Setup 🐍 3.8
3433
uses: actions/setup-python@v5
3534
with:
36-
python-version: 3.6
35+
python-version: 3.8
3736

3837
- name: Prepare env
3938
run: |

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dependency.
3434
Think of this library as a tiny self-contained version of Boost.Python
3535
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.6+, or PyPy) and the C++
37+
lines of code and depend on Python (3.7+, or PyPy) and the C++
3838
standard library. This compact implementation was possible thanks to
3939
some C++11 language features (specifically: tuples, lambda functions and
4040
variadic templates). Since its creation, this library has grown beyond
@@ -79,7 +79,7 @@ Goodies
7979
In addition to the core functionality, pybind11 provides some extra
8080
goodies:
8181

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

8585
- It is possible to bind C++11 lambda functions with captured

docs/benchmark.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import datetime as dt
24
import os
35
import random

docs/compiling.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ with ``PYTHON_EXECUTABLE``. For example:
426426

427427
.. code-block:: bash
428428
429-
cmake -DPYBIND11_PYTHON_VERSION=3.6 ..
429+
cmake -DPYBIND11_PYTHON_VERSION=3.7 ..
430430
431431
# Another method:
432432
cmake -DPYTHON_EXECUTABLE=/path/to/python ..
@@ -493,7 +493,7 @@ existing targets instead:
493493
cmake_minimum_required(VERSION 3.15...3.22)
494494
project(example LANGUAGES CXX)
495495
496-
find_package(Python 3.6 COMPONENTS Interpreter Development REQUIRED)
496+
find_package(Python 3.7 COMPONENTS Interpreter Development REQUIRED)
497497
find_package(pybind11 CONFIG REQUIRED)
498498
# or add_subdirectory(pybind11)
499499

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#
1212
# All configuration values have a default; values that are commented out
1313
# serve to show the default.
14+
from __future__ import annotations
1415

1516
import os
1617
import re

include/pybind11/detail/class.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -567,17 +567,9 @@ inline void enable_dynamic_attributes(PyHeapTypeObject *heap_type) {
567567
type->tp_traverse = pybind11_traverse;
568568
type->tp_clear = pybind11_clear;
569569

570-
static PyGetSetDef getset[] = {{
571-
#if PY_VERSION_HEX < 0x03070000
572-
const_cast<char *>("__dict__"),
573-
#else
574-
"__dict__",
575-
#endif
576-
PyObject_GenericGetDict,
577-
PyObject_GenericSetDict,
578-
nullptr,
579-
nullptr},
580-
{nullptr, nullptr, nullptr, nullptr, nullptr}};
570+
static PyGetSetDef getset[]
571+
= {{"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict, nullptr, nullptr},
572+
{nullptr, nullptr, nullptr, nullptr, nullptr}};
581573
type->tp_getset = getset;
582574
}
583575

include/pybind11/detail/common.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,8 @@ PYBIND11_WARNING_DISABLE_MSVC(4505)
272272
#endif
273273

274274
#include <Python.h>
275-
// Reminder: WITH_THREAD is always defined if PY_VERSION_HEX >= 0x03070000
276-
#if PY_VERSION_HEX < 0x03060000
277-
# error "PYTHON < 3.6 IS UNSUPPORTED. pybind11 v2.9 was the last to support Python 2 and 3.5."
275+
#if PY_VERSION_HEX < 0x03070000
276+
# error "PYTHON < 3.7 IS UNSUPPORTED. pybind11 v2.12 was the last to support Python 3.6."
278277
#endif
279278
#include <frameobject.h>
280279
#include <pythread.h>

0 commit comments

Comments
 (0)