Skip to content

Commit b50c3d8

Browse files
committed
Remove Python 3.8 support
This commit removes support for Python 3.8, mostly by deleting workarounds and corner cases related to this old Python version.
1 parent 892dd81 commit b50c3d8

Some content is hidden

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

42 files changed

+98
-334
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
fail-fast: false
2222
matrix:
2323
os: ['ubuntu-latest', 'windows-2022', 'macos-13']
24-
python: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14', 'pypy3.9-v7.3.16', 'pypy3.10-v7.3.17']
24+
python: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14', 'pypy3.9-v7.3.16', 'pypy3.10-v7.3.17']
2525

2626
name: "Python ${{ matrix.python }} / ${{ matrix.os }}"
2727
runs-on: ${{ matrix.os }}

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ if (NOT TARGET Python::Module OR NOT TARGET Python::Interpreter)
145145
set(NB_PYTHON_DEV_MODULE Development.Module)
146146
endif()
147147

148-
find_package(Python 3.8
148+
find_package(Python 3.9
149149
REQUIRED COMPONENTS Interpreter ${NB_PYTHON_DEV_MODULE}
150150
OPTIONAL_COMPONENTS Development.SABIModule)
151151
endif()

cmake/collect-symbols.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
funcs: "set[str]" = set()
1212

13-
for ver in ['3.7', '3.8', '3.9']:
13+
for ver in ['3.9']:
1414
url = f'https://raw.githubusercontent.com/python/cpython/{ver}/PC/python3.def'
1515
output = urlopen(url).read().decode('utf-8')
1616
for match in re.findall(r" (.*)=.*", output):

cmake/nanobind-config.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ if (NOT TARGET Python::Module)
44
message(FATAL_ERROR "You must invoke 'find_package(Python COMPONENTS Interpreter Development REQUIRED)' prior to including nanobind.")
55
endif()
66

7+
if (Python_VERSION VERSION_LESS "3.9")
8+
message(FATAL_ERROR "nanobind requires Python 3.9 or newer (found Python ${Python_VERSION}).")
9+
endif()
10+
711
# Determine the right suffix for ordinary and stable ABI extensions.
812

913
# We always need to know the extension

docs/api_core.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,9 +2158,6 @@ declarations in generated :ref:`stubs <stubs>`,
21582158
See the section on :ref:`creating generic types <typing_generics_creating>`
21592159
for an example.
21602160

2161-
This feature is only supported on Python 3.9+. Nanobind will ignore
2162-
the attribute in Python 3.8 builds.
2163-
21642161
.. cpp:struct:: template <typename T> supplement
21652162

21662163
Indicate that ``sizeof(T)`` bytes of memory should be set aside to

docs/building.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Preliminaries
2020
Begin by creating a new file named ``CMakeLists.txt`` in the root directory of
2121
your project. It should start with the following lines that declare a project
2222
name and tested CMake version range. The third line line searches for Python >=
23-
3.8 including the ``Development.Module`` component required by nanobind. The
23+
3.9 including the ``Development.Module`` component required by nanobind. The
2424
name of this module changed across CMake versions, hence the additional
2525
conditional check.
2626

@@ -35,7 +35,7 @@ conditional check.
3535
set(DEV_MODULE Development.Module)
3636
endif()
3737
38-
find_package(Python 3.8 COMPONENTS Interpreter ${DEV_MODULE} REQUIRED)
38+
find_package(Python 3.9 COMPONENTS Interpreter ${DEV_MODULE} REQUIRED)
3939
4040
Add the following lines below. They configure CMake to perform an optimized
4141
*release* build by default unless another build type is specified. Without this

docs/exceptions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ Should they throw or fail to catch any exceptions in their call graph,
266266
the C++ runtime calls ``std::terminate()`` to abort immediately.
267267

268268
Similarly, Python exceptions raised in a class's ``__del__`` method do not
269-
propagate, but are logged by Python as an unraisable error. In Python 3.8+, a
270-
`system hook is triggered
269+
propagate, but are logged by Python as an unraisable error. A `system hook is
270+
triggered
271271
<https://docs.python.org/3/library/sys.html#sys.unraisablehook>`_
272272
and an auditing event is logged.
273273

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ similar runtime performance).
5454

5555
nanobinds depends on
5656

57-
- **Python 3.8+** or **PyPy 7.3.10+** (the *3.8* and *3.9* PyPy flavors are
57+
- **Python 3.9+** or **PyPy 7.3.10+** (the *3.9* and *3.10* PyPy flavors are
5858
supported, though there are :ref:`some limitations <pypy_issues>`).
5959
- **CMake 3.15+**.
6060
- **A C++17 compiler**: Clang 8+, GCC 8+, MSVC2019+, MinGW-w64, Intel ICX

docs/packaging.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ An example is shown below:
101101
version = "0.0.1"
102102
description = "A brief description of what this project does"
103103
readme = "README.md"
104-
requires-python = ">=3.8"
104+
requires-python = ">=3.9"
105105
authors = [
106106
{ name = "Your Name", email = "[email protected]" },
107107
]
@@ -178,7 +178,7 @@ component that can be used to create `stable ABI
178178
.. code-block:: cmake
179179
180180
# Try to import all Python components potentially needed by nanobind
181-
find_package(Python 3.8
181+
find_package(Python 3.9
182182
REQUIRED COMPONENTS Interpreter Development.Module
183183
OPTIONAL_COMPONENTS Development.SABIModule)
184184
@@ -316,7 +316,6 @@ block to remove incompatible configurations from the matrix:
316316

317317
.. code-block:: toml
318318
319-
skip = ["cp38-*", "pp38-*"] # Skip CPython and PyPy 3.8
320319
archs = ["auto64"] # Only target 64 bit architectures
321320
322321
The `cibuildwheel documentation

docs/refleaks.rst

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,9 @@ Here is an example of the required code for a ``Wrapper`` type:
337337
struct Wrapper { std::shared_ptr<Wrapper> value; };
338338
339339
int wrapper_tp_traverse(PyObject *self, visitproc visit, void *arg) {
340-
// On Python 3.9+, we must traverse the implicit dependency
341-
// of an object on its associated type object.
342-
#if PY_VERSION_HEX >= 0x03090000
343-
Py_VISIT(Py_TYPE(self));
344-
#endif
340+
// We must traverse the implicit dependency of an object on its
341+
// associated type object.
342+
Py_VISIT(Py_TYPE(self));
345343
346344
// The tp_traverse method may be called after __new__ but before or during
347345
// __init__, before the C++ constructor has been completed. We must not
@@ -454,28 +452,6 @@ how deal with them. For completeness, let's consider some other possibilities.
454452
should be fixed in the responsible framework so that leak warnings aren't
455453
cluttered with flukes and can be more broadly useful.
456454

457-
- **Older Python versions**: Very old Python versions (e.g., 3.8) don't
458-
do a good job cleaning up global references when the interpreter shuts down.
459-
The following code may leak a reference if it is a top-level statement in a
460-
Python file or the REPL.
461-
462-
.. code-block:: python
463-
464-
a = my_ext.MyObject()
465-
466-
Such a warning is benign and does not indicate an actual leak. It simply
467-
highlights a flaws in the interpreter shutdown logic of old Python versions.
468-
Wrap your code into a function to address this issue even on such versions:
469-
470-
.. code-block:: python
471-
472-
def run():
473-
a = my_ext.MyObject()
474-
# ...
475-
476-
if __name__ == '__main__':
477-
run()
478-
479455
- **Exceptions**. Some exceptions such as ``AttributeError`` have been observed
480456
to hold references, e.g. to the object which lacked the desired attribute. If
481457
the last exception raised by the program references a nanobind instance, then

0 commit comments

Comments
 (0)