Fix Python 3.8 incompatibility.
This commit is contained in:
parent
b3c6e37f76
commit
c9d433321f
81
6cb584e9de6e8d54f5576c299a308f89bfdcb519.patch
Normal file
81
6cb584e9de6e8d54f5576c299a308f89bfdcb519.patch
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
From 6cb584e9de6e8d54f5576c299a308f89bfdcb519 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Sergei Izmailov <sergei.a.izmailov@gmail.com>
|
||||||
|
Date: Tue, 8 Oct 2019 19:25:09 +0300
|
||||||
|
Subject: [PATCH] Adapt to python3.8 C API change (#1950)
|
||||||
|
|
||||||
|
* Adapt to python3.8 C API change
|
||||||
|
|
||||||
|
Do `Py_DECREF(type)` on all python objects on deallocation
|
||||||
|
|
||||||
|
fix #1946
|
||||||
|
|
||||||
|
* Add bare python3.8 build to CI matrix
|
||||||
|
|
||||||
|
While numpy/scipy wheels are available, run python3.8 test without them
|
||||||
|
---
|
||||||
|
.travis.yml | 27 +++++++++++++++++++++++++++
|
||||||
|
include/pybind11/detail/class.h | 6 ++++++
|
||||||
|
2 files changed, 33 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/.travis.yml b/.travis.yml
|
||||||
|
index 381148e04..28f35f995 100644
|
||||||
|
--- a/.travis.yml
|
||||||
|
+++ b/.travis.yml
|
||||||
|
@@ -106,6 +106,33 @@ matrix:
|
||||||
|
- lld-7
|
||||||
|
- libc++-7-dev
|
||||||
|
- libc++abi-7-dev # Why is this necessary???
|
||||||
|
+ - os: linux
|
||||||
|
+ dist: xenial
|
||||||
|
+ env: PYTHON=3.8 CPP=17 GCC=7
|
||||||
|
+ name: Python 3.8, c++17, gcc 7 (w/o numpy/scipy) # TODO: update build name when the numpy/scipy wheels become available
|
||||||
|
+ addons:
|
||||||
|
+ apt:
|
||||||
|
+ sources:
|
||||||
|
+ - deadsnakes
|
||||||
|
+ - ubuntu-toolchain-r-test
|
||||||
|
+ packages:
|
||||||
|
+ - g++-7
|
||||||
|
+ - python3.8-dev
|
||||||
|
+ - python3.8-venv
|
||||||
|
+ # Currently there is no numpy/scipy wheels available for python3.8
|
||||||
|
+ # TODO: remove next before_install, install and script clause when the wheels become available
|
||||||
|
+ before_install:
|
||||||
|
+ - pyenv global $(pyenv whence 2to3) # activate all python versions
|
||||||
|
+ - PY_CMD=python3
|
||||||
|
+ - $PY_CMD -m pip install --user --upgrade pip wheel setuptools
|
||||||
|
+ install:
|
||||||
|
+ - $PY_CMD -m pip install --user --upgrade pytest
|
||||||
|
+ script:
|
||||||
|
+ - |
|
||||||
|
+ # Barebones build
|
||||||
|
+ cmake -DCMAKE_BUILD_TYPE=Debug -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DPYTHON_EXECUTABLE=$(which $PY_CMD) .
|
||||||
|
+ make pytest -j 2
|
||||||
|
+ make cpptest -j 2
|
||||||
|
- os: osx
|
||||||
|
name: Python 2.7, c++14, AppleClang 7.3, CMake test
|
||||||
|
osx_image: xcode7.3
|
||||||
|
diff --git a/include/pybind11/detail/class.h b/include/pybind11/detail/class.h
|
||||||
|
index ffdfefe74..230ae81ae 100644
|
||||||
|
--- a/include/pybind11/detail/class.h
|
||||||
|
+++ b/include/pybind11/detail/class.h
|
||||||
|
@@ -350,6 +350,7 @@ extern "C" inline void pybind11_object_dealloc(PyObject *self) {
|
||||||
|
auto type = Py_TYPE(self);
|
||||||
|
type->tp_free(self);
|
||||||
|
|
||||||
|
+#if PY_VERSION_HEX < 0x03080000
|
||||||
|
// `type->tp_dealloc != pybind11_object_dealloc` means that we're being called
|
||||||
|
// as part of a derived type's dealloc, in which case we're not allowed to decref
|
||||||
|
// the type here. For cross-module compatibility, we shouldn't compare directly
|
||||||
|
@@ -357,6 +358,11 @@ extern "C" inline void pybind11_object_dealloc(PyObject *self) {
|
||||||
|
auto pybind11_object_type = (PyTypeObject *) get_internals().instance_base;
|
||||||
|
if (type->tp_dealloc == pybind11_object_type->tp_dealloc)
|
||||||
|
Py_DECREF(type);
|
||||||
|
+#else
|
||||||
|
+ // This was not needed before Python 3.8 (Python issue 35810)
|
||||||
|
+ // https://github.com/pybind/pybind11/issues/1946
|
||||||
|
+ Py_DECREF(type);
|
||||||
|
+#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Create the type which can be used as a common base for all classes. This is
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
Name: pybind11
|
Name: pybind11
|
||||||
Version: 2.4.2
|
Version: 2.4.2
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
Summary: Seamless operability between C++11 and Python
|
Summary: Seamless operability between C++11 and Python
|
||||||
License: BSD
|
License: BSD
|
||||||
URL: https://github.com/pybind/pybind11
|
URL: https://github.com/pybind/pybind11
|
||||||
@ -23,6 +23,8 @@ Source0: https://github.com/pybind/pybind11/archive/v%{version}/%{name}-%{versio
|
|||||||
|
|
||||||
# Don't use pip to get path to headers
|
# Don't use pip to get path to headers
|
||||||
Patch1: pybind11-2.4.0-nopip.patch
|
Patch1: pybind11-2.4.0-nopip.patch
|
||||||
|
# Patch for Python 3.8 compatibility
|
||||||
|
Patch2: https://github.com/pybind/pybind11/commit/6cb584e9de6e8d54f5576c299a308f89bfdcb519.patch
|
||||||
|
|
||||||
%if %{python2_enabled}
|
%if %{python2_enabled}
|
||||||
# Needed to build the python libraries
|
# Needed to build the python libraries
|
||||||
@ -101,6 +103,7 @@ This package contains the Python 3 files.
|
|||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q
|
||||||
%patch1 -p1 -b .nopip
|
%patch1 -p1 -b .nopip
|
||||||
|
%patch2 -p1 -b .python38
|
||||||
|
|
||||||
%build
|
%build
|
||||||
pys=""
|
pys=""
|
||||||
@ -168,6 +171,9 @@ PYBIND11_USE_CMAKE=true %py3_install "--install-purelib" "%{python3_sitearch}"
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Oct 08 2019 Susi Lehtola - 2.4.2-2
|
||||||
|
- Fix Python 3.8 incompatibility.
|
||||||
|
|
||||||
* Sat Sep 28 2019 Susi Lehtola - 2.4.2-1
|
* Sat Sep 28 2019 Susi Lehtola - 2.4.2-1
|
||||||
- Update to 2.4.2.
|
- Update to 2.4.2.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user