From e3a9d77eb7f62c5fe63d75ed0925f89d45873ffb Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Fri, 8 Mar 2024 09:09:10 +0100 Subject: [PATCH 1/4] Preliminary support for Python 3.13a3 --- .github/workflows/tests.yml | 42 +++++++++++++++++++++++++++++++++++++ .manylinux-install.sh | 11 ++++++++-- .meta.toml | 2 +- appveyor.yml | 3 +++ tox.ini | 2 ++ 5 files changed, 57 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d782a75..8164ddf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -103,6 +103,7 @@ jobs: - "3.10" - "3.11" - "3.12" + - "3.13.0-alpha - 3.13.0" os: [ubuntu-20.04, macos-11] exclude: - os: macos-11 @@ -134,7 +135,17 @@ jobs: restore-keys: | ${{ runner.os }}-pip- + - name: Install Build Dependencies (3.13.0-alpha - 3.13.0) + if: matrix.python-version == '3.13.0-alpha - 3.13.0' + run: | + pip install -U pip + pip install -U setuptools wheel twine + # cffi will probably have no public release until a Python 3.13 beta + # or even RC release, see https://github.com/python-cffi/cffi/issues/23 + echo "cffi @ git+https://github.com/python-cffi/cffi.git@954cab4f889fb019a7f90df153ee1be501495f58" > cffi_constraint.txt + PIP_CONSTRAINT=$PWD/cffi_constraint.txt pip install cffi - name: Install Build Dependencies + if: matrix.python-version != '3.13.0-alpha - 3.13.0' run: | pip install -U pip pip install -U setuptools wheel twine cffi @@ -178,7 +189,18 @@ jobs: python setup.py build_ext -i python setup.py bdist_wheel + - name: Install zodbpickle and dependencies (3.13.0-alpha - 3.13.0) + if: matrix.python-version == '3.13.0-alpha - 3.13.0' + run: | + # Install to collect dependencies into the (pip) cache. + # cffi will probably have no public release until a Python 3.13 beta + # or even RC release, see https://github.com/python-cffi/cffi/issues/23 + echo "cffi @ git+https://github.com/python-cffi/cffi.git@954cab4f889fb019a7f90df153ee1be501495f58" > cffi_constraint.txt + # Use "--pre" here because dependencies with support for this future + # Python release may only be available as pre-releases + PIP_CONSTRAINT=$PWD/cffi_constraint.txt pip install --pre .[test] - name: Install zodbpickle and dependencies + if: matrix.python-version != '3.13.0-alpha - 3.13.0' run: | # Install to collect dependencies into the (pip) cache. pip install .[test] @@ -222,6 +244,7 @@ jobs: && startsWith(github.ref, 'refs/tags') && startsWith(runner.os, 'Mac') && !startsWith(matrix.python-version, 'pypy') + && !startsWith(matrix.python-version, '3.13.0-alpha - 3.13.0') env: TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} run: | @@ -241,6 +264,7 @@ jobs: - "3.10" - "3.11" - "3.12" + - "3.13.0-alpha - 3.13.0" os: [ubuntu-20.04, macos-11] exclude: - os: macos-11 @@ -277,7 +301,25 @@ jobs: with: name: zodbpickle-${{ runner.os }}-${{ matrix.python-version }}.whl path: dist/ + - name: Install zodbpickle 3.13.0-alpha - 3.13.0 + if: ${{ startsWith(matrix.python-version, '3.13.0-alpha - 3.13.0') }} + run: | + pip install -U wheel setuptools + # cffi will probably have no public release until a beta or even RC + # version of Python 3.13, see https://github.com/python-cffi/cffi/issues/23 + echo 'cffi @ git+https://github.com/python-cffi/cffi.git@954cab4f889fb019a7f90df153ee1be501495f58 ; platform_python_implementation == "CPython"' > cffi_constraint.txt + # coverage has a wheel on PyPI for a future python version which is + # not ABI compatible with the current one, so build it from sdist: + pip install -U --no-binary :all: coverage + # Unzip into src/ so that testrunner can find the .so files + # when we ask it to load tests from that directory. This + # might also save some build time? + unzip -n dist/zodbpickle-*whl -d src + # Use "--pre" here because dependencies with support for this future + # Python release may only be available as pre-releases + PIP_CONSTRAINT=$PWD/cffi_constraint.txt pip install --pre -U -e .[test] - name: Install zodbpickle + if: ${{ !startsWith(matrix.python-version, '3.13.0-alpha - 3.13.0') }} run: | pip install -U wheel setuptools pip install -U coverage diff --git a/.manylinux-install.sh b/.manylinux-install.sh index 579b9de..d8e6422 100755 --- a/.manylinux-install.sh +++ b/.manylinux-install.sh @@ -28,6 +28,7 @@ yum -y install libffi-devel tox_env_map() { case $1 in + *"cp313"*) echo 'py313';; *"cp37"*) echo 'py37';; *"cp38"*) echo 'py38';; *"cp39"*) echo 'py39';; @@ -41,14 +42,20 @@ tox_env_map() { # Compile wheels for PYBIN in /opt/python/*/bin; do if \ + [[ "${PYBIN}" == *"cp313"* ]] || \ [[ "${PYBIN}" == *"cp311"* ]] || \ [[ "${PYBIN}" == *"cp312"* ]] || \ [[ "${PYBIN}" == *"cp37"* ]] || \ [[ "${PYBIN}" == *"cp38"* ]] || \ [[ "${PYBIN}" == *"cp39"* ]] || \ [[ "${PYBIN}" == *"cp310"* ]] ; then - "${PYBIN}/pip" install -e /io/ - "${PYBIN}/pip" wheel /io/ -w wheelhouse/ + if [[ "${PYBIN}" == *"cp313"* ]] ; then + "${PYBIN}/pip" install --pre -e /io/ + "${PYBIN}/pip" wheel /io/ --pre -w wheelhouse/ + else + "${PYBIN}/pip" install -e /io/ + "${PYBIN}/pip" wheel /io/ -w wheelhouse/ + fi if [ `uname -m` == 'aarch64' ]; then cd /io/ ${PYBIN}/pip install tox diff --git a/.meta.toml b/.meta.toml index dd09db9..9267487 100644 --- a/.meta.toml +++ b/.meta.toml @@ -9,7 +9,7 @@ with-appveyor = true with-windows = false with-pypy = true with-sphinx-doctests = false -with-future-python = false +with-future-python = true with-macos = false [tox] diff --git a/appveyor.yml b/appveyor.yml index d93b61d..75f4626 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,6 +15,9 @@ environment: - python: 310-x64 - python: 311-x64 - python: 312-x64 + # `multibuild` cannot install non-final versions as they are not on + # ftp.python.org, so we skip Python 3.13 until its final release: + # - python: 313-x64 install: - "SET PYTHONVERSION=%PYTHON%" diff --git a/tox.ini b/tox.ini index b81fb57..c828791 100644 --- a/tox.ini +++ b/tox.ini @@ -10,11 +10,13 @@ envlist = py310,py310-pure py311,py311-pure py312,py312-pure + py313,py313-pure pypy3 coverage [testenv] usedevelop = true +pip_pre = py313: true deps = setenv = pure: PURE_PYTHON=1 From 9c57fa08bbcd24f69cfd0512a55a4f8305d0ca01 Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Fri, 8 Mar 2024 09:09:49 +0100 Subject: [PATCH 2/4] Add change log. --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index fe432f3..b47e56d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,7 +5,7 @@ 3.3 (unreleased) ================ -- Remove premature support for Python 3.13. +- Nothing changed yet. 3.2 (2024-02-16) From a18122fc5d3b5bd2a8c28954c119f7c272ade1bf Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Thu, 14 Mar 2024 08:23:58 +0100 Subject: [PATCH 3/4] Fix CHANGES.rst --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index b47e56d..eaac311 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,7 +5,7 @@ 3.3 (unreleased) ================ -- Nothing changed yet. +- Add preliminary support for Python 3.13 as of 3.13a5. 3.2 (2024-02-16) From 73596ede72bf460062cefba69bbdfa0060d444ae Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Fri, 5 Apr 2024 17:29:30 -0400 Subject: [PATCH 4/4] fix: build on Python-3.13.0a5 Work around added 'with_exceptions' argument to '_PyLong_AsBytesArray', added in https://github.com/python/cpython/commit/7861dfd26a41e40c2b4361eb0bb1356b9b4a064b. --- src/zodbpickle/_pickle_33.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/zodbpickle/_pickle_33.c b/src/zodbpickle/_pickle_33.c index d6a26a7..83cf455 100644 --- a/src/zodbpickle/_pickle_33.c +++ b/src/zodbpickle/_pickle_33.c @@ -15,15 +15,37 @@ PyDoc_STRVAR(pickle_module_doc, #endif #if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_SIZE) /* 3.9.0a4 */ + PYCAPI_COMPAT_STATIC_INLINE(void) _Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size) { ob->ob_size = size; } + #define Py_SET_SIZE(ob, size) _Py_SET_SIZE((PyVarObject*)(ob), size) + +#endif + +#if (PY_VERSION_HEX >= 0x30D00A5) /* 3.13.0a5 */ + +/** + * In 3.13a5 ``_PyLong_AsByteArray`` got a new ``with_exceptions`` argument. + * See https://github.com/python/cpython/commit/7861dfd26a41e40c2b4361eb0bb1356b9b4a064b + */ +PyAPI_FUNC(int) _PyLong_AsByteArray_compat(PyLongObject* v, + unsigned char* bytes, size_t n, + int little_endian, int is_signed) +{ + return _PyLong_AsByteArray( + v, bytes, n, little_endian, is_signed, 1 /* with_exceptions */ + ); +} + +#define _PyLong_AsByteArray(v, bytes, n, little_endian, is_signed) _PyLong_AsByteArray_compat(v, bytes, n, little_endian, is_signed) #endif #if (PY_VERSION_HEX >= 0x30D00A1) /* 3.13.0a1 */ + /** * In 3.13a1 ``_PyObject_LookupAttrId`` was removed. * See https://github.com/python/cpython/commit/579aa89e68a6607398317a50586af781981e89fb @@ -41,13 +63,16 @@ static int _PyObject_HasAttrId(PyObject* obj, void* id) Py_XDECREF(attr_val); return result; } + /* * This declaration was moved to the internal API only accessible for building * CPython itself. But the implementation is still in `Objects/longobject.c` and * Pythons own `Modules/_pickle.c` still uses it. */ PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v); + #elif (PY_VERSION_HEX >= 0x30A00B1) /* 3.10.0b1 */ + /** * The function ``_PyObject_LookupAttrId`` function replaces the combo of * ``_PyObject_HasAttrId`` followed by ``_PyObject_GetAttrId``; our code isn't @@ -62,6 +87,7 @@ static int _PyObject_HasAttrId(PyObject* obj, void* id) Py_XDECREF(attr_val); return result; } + #endif #if (PY_VERSION_HEX < 0x30B00A7) /* 3.11.0a7 */