From b9f91ef049c44a1ec2010e654ece74aaac839317 Mon Sep 17 00:00:00 2001 From: zhang-liang-pengkun Date: Wed, 25 Oct 2023 11:44:33 +0800 Subject: [PATCH] Add support for Python 3.10 Signed-off-by: zhang-liang-pengkun --- 0002-Add-support-for-Python-3.10.patch | 124 +++++++++++++++++++++++++ python-greenlet.spec | 7 +- 2 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 0002-Add-support-for-Python-3.10.patch diff --git a/0002-Add-support-for-Python-3.10.patch b/0002-Add-support-for-Python-3.10.patch new file mode 100644 index 0000000..100beea --- /dev/null +++ b/0002-Add-support-for-Python-3.10.patch @@ -0,0 +1,124 @@ +From 6c5f0963eb00eeb1cfb337c6edbd3efaf7d8eacc Mon Sep 17 00:00:00 2001 +From: Jason Madden +Date: Wed, 5 May 2021 08:13:04 -0500 +Subject: [PATCH] Add support for Python 3.10 + +--- + .github/workflows/tests.yml | 11 +++++++++-- + CHANGES.rst | 7 +++++++ + setup.py | 1 + + src/greenlet/greenlet.c | 14 ++++++++++++-- + tox.ini | 2 +- + 5 files changed, 30 insertions(+), 5 deletions(-) + +diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml +index affac53..3e73d3c 100644 +--- a/.github/workflows/tests.yml ++++ b/.github/workflows/tests.yml +@@ -23,7 +23,7 @@ jobs: + runs-on: ${{ matrix.os }} + strategy: + matrix: +- python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9] ++ python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10.0-beta.1] + os: [ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v2 +@@ -95,10 +95,17 @@ jobs: + #run: | + # docker run --rm --privileged multiarch/qemu-user-static:register --reset + - name: Build and test greenlet ++ if: matrix.image == 'manylinux2010_x86_64' + # An alternate way to do this is to run the container directly with a uses: + # and then the script runs inside it. That may work better with caching. + # See https://github.com/pyca/bcrypt/blob/f6b5ee2eda76d077c531362ac65e16f045cf1f29/.github/workflows/wheel-builder.yml +- # The 2010 image is the last one that comes with Python 2.7. ++ # The 2010 image is the last one that comes with Python 2.7, ++ # and only up through the tag 2021-02-06-3d322a5 ++ env: ++ DOCKER_IMAGE: quay.io/pypa/${{ matrix.image }}:2021-02-06-3d322a5 ++ run: bash ./make-manylinux ++ - name: Build and test greenlet (other) ++ if: matrix.image != 'manylinux2010_x86_64' + env: + DOCKER_IMAGE: quay.io/pypa/${{ matrix.image }} + run: bash ./make-manylinux +diff --git a/CHANGES.rst b/CHANGES.rst +index 22af55d..e6d5936 100644 +--- a/CHANGES.rst ++++ b/CHANGES.rst +@@ -2,6 +2,13 @@ + Changes + ========= + ++1.1.0 (unreleased) ++================== ++ ++- Add support for Python 3.10. Pre-built binary wheels are not ++ currently available for 3.10. ++ ++ + 1.0.0 (2021-01-13) + ================== + +diff --git a/setup.py b/setup.py +index 6cd3199..c66b87f 100644 +--- a/setup.py ++++ b/setup.py +@@ -138,6 +138,7 @@ setup( + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', ++ 'Programming Language :: Python :: 3.10', + 'Operating System :: OS Independent', + 'Topic :: Software Development :: Libraries :: Python Modules' + ], +diff --git a/src/greenlet/greenlet.c b/src/greenlet/greenlet.c +index eff39a1..eeece04 100644 +--- a/src/greenlet/greenlet.c ++++ b/src/greenlet/greenlet.c +@@ -96,6 +96,16 @@ extern PyTypeObject PyGreenlet_Type; + # define GREENLET_PY37 0 + #endif + ++#if PY_VERSION_HEX >= 0x30A00B1 ++/* ++Python 3.10 beta 1 changed tstate->use_tracing to a nested cframe member. ++See https://github.com/python/cpython/pull/25276 ++*/ ++#define TSTATE_USE_TRACING(tstate) (tstate->cframe->use_tracing) ++#else ++#define TSTATE_USE_TRACING(tstate) (tstate->use_tracing) ++#endif ++ + #ifndef Py_SET_REFCNT + /* Py_REFCNT and Py_SIZE macros are converted to functions + https://bugs.python.org/issue39573 */ +@@ -567,10 +577,10 @@ g_calltrace(PyObject* tracefunc, PyObject* event, PyGreenlet* origin, + PyErr_Fetch(&exc_type, &exc_val, &exc_tb); + tstate = PyThreadState_GET(); + tstate->tracing++; +- tstate->use_tracing = 0; ++ TSTATE_USE_TRACING(tstate) = 0; + retval = PyObject_CallFunction(tracefunc, "O(OO)", event, origin, target); + tstate->tracing--; +- tstate->use_tracing = ++ TSTATE_USE_TRACING(tstate) = + (tstate->tracing <= 0 && + ((tstate->c_tracefunc != NULL) || (tstate->c_profilefunc != NULL))); + if (retval == NULL) { +diff --git a/tox.ini b/tox.ini +index e4bde4c..df06fc3 100644 +--- a/tox.ini ++++ b/tox.ini +@@ -1,6 +1,6 @@ + [tox] + envlist = +- py27,py35,py36,py37,py38,py39,docs ++ py27,py35,py36,py37,py38,py39,py310,docs + + [testenv] + commands = +-- +2.39.0.windows.2 + diff --git a/python-greenlet.spec b/python-greenlet.spec index a9bc4d6..aa9c83a 100644 --- a/python-greenlet.spec +++ b/python-greenlet.spec @@ -1,12 +1,13 @@ Name: python-greenlet Version: 1.0.0 -Release: 2 +Release: 3 Summary: lightweight coroutines for in-process concurrent programming License: Python-2.0 and MIT URL: https://github.com/python-greenlet/greenlet Source0: https://files.pythonhosted.org/packages/92/be/878cc5314fa5aadce33e68738c1a24debe317605196bdfc2049e66bc9c30/greenlet-1.0.0.tar.gz Patch0: 0001-add-loongarch64-architecture-support.patch +Patch1: 0002-Add-support-for-Python-3.10.patch %description The greenlet package is a spin-off of Stackless, a version of CPython @@ -43,6 +44,7 @@ that use python3-greenlet. %setup -n greenlet-%{version} %ifarch loongarch64 %patch0 -p1 +%patch1 -p1 %endif %build @@ -65,6 +67,9 @@ that use python3-greenlet. %{_includedir}/python%{python3_version}*/greenlet/ %changelog +* Wed Oct 25 2023 zhangliangpengkun - 1.0.0-3 +- Add support for Python 3.10 + * Thu Nov 17 2022 huajingyun - 1.0.0-2 - add loongarch64 architecture support -- Gitee