From 340e4ad2fe14df0fa65c3ddfc186cfcde8da37f8 Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Tue, 16 Apr 2024 08:19:38 +0200 Subject: [PATCH] Build Windows wheels on GHA. (#84) * Use GHA to build windows wheels * Build Windows wheels on GHA. * Use cffi only when needed. * fix: remove copy-pasta Because we are emulating the Python stdlib function only for internal purposes, we do not want (nor are we allowed) to export it as a publically-linkable endpoing. --------- Co-authored-by: Tres Seaver --- .github/workflows/tests.yml | 132 ++++++++++++++++++++++++++---------- .meta.toml | 5 +- CHANGES.rst | 2 + MANIFEST.in | 1 - appveyor.yml | 52 -------------- src/zodbpickle/_pickle_33.c | 2 +- 6 files changed, 102 insertions(+), 92 deletions(-) delete mode 100644 appveyor.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8164ddf..84305b2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -104,7 +104,7 @@ jobs: - "3.11" - "3.12" - "3.13.0-alpha - 3.13.0" - os: [ubuntu-20.04, macos-11] + os: [ubuntu-20.04, macos-11, windows-latest] exclude: - os: macos-11 python-version: "pypy-3.10" @@ -122,15 +122,32 @@ jobs: # to save the cache. So it must come before the thing we want to use # the cache. ### - - name: Get pip cache dir - id: pip-cache + - name: Get pip cache dir (default) + id: pip-cache-default + if: ${{ !startsWith(runner.os, 'Windows') }} run: | echo "dir=$(pip cache dir)" >>$GITHUB_OUTPUT - - name: pip cache + - name: Get pip cache dir (Windows) + id: pip-cache-windows + if: ${{ startsWith(runner.os, 'Windows') }} + run: | + echo "dir=$(pip cache dir)" >> $Env:GITHUB_OUTPUT + + - name: pip cache (default) uses: actions/cache@v4 + if: ${{ !startsWith(runner.os, 'Windows') }} with: - path: ${{ steps.pip-cache.outputs.dir }} + path: ${{ steps.pip-cache-default.outputs.dir }} + key: ${{ runner.os }}-pip-${{ matrix.python-version }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: pip cache (Windows) + uses: actions/cache@v4 + if: ${{ startsWith(runner.os, 'Windows') }} + with: + path: ${{ steps.pip-cache-windows.outputs.dir }} key: ${{ runner.os }}-pip-${{ matrix.python-version }} restore-keys: | ${{ runner.os }}-pip- @@ -140,15 +157,11 @@ jobs: 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 + pip install -U setuptools wheel twine - name: Build zodbpickle (macOS x86_64, Python 3.8+) if: > @@ -193,12 +206,9 @@ jobs: 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] + pip install --pre .[test] - name: Install zodbpickle and dependencies if: matrix.python-version != '3.13.0-alpha - 3.13.0' run: | @@ -265,7 +275,7 @@ jobs: - "3.11" - "3.12" - "3.13.0-alpha - 3.13.0" - os: [ubuntu-20.04, macos-11] + os: [ubuntu-20.04, macos-11, windows-latest] exclude: - os: macos-11 python-version: "pypy-3.10" @@ -283,15 +293,32 @@ jobs: # to save the cache. So it must come before the thing we want to use # the cache. ### - - name: Get pip cache dir - id: pip-cache + - name: Get pip cache dir (default) + id: pip-cache-default + if: ${{ !startsWith(runner.os, 'Windows') }} run: | echo "dir=$(pip cache dir)" >>$GITHUB_OUTPUT - - name: pip cache + - name: Get pip cache dir (Windows) + id: pip-cache-windows + if: ${{ startsWith(runner.os, 'Windows') }} + run: | + echo "dir=$(pip cache dir)" >> $Env:GITHUB_OUTPUT + + - name: pip cache (default) uses: actions/cache@v4 + if: ${{ !startsWith(runner.os, 'Windows') }} with: - path: ${{ steps.pip-cache.outputs.dir }} + path: ${{ steps.pip-cache-default.outputs.dir }} + key: ${{ runner.os }}-pip-${{ matrix.python-version }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: pip cache (Windows) + uses: actions/cache@v4 + if: ${{ startsWith(runner.os, 'Windows') }} + with: + path: ${{ steps.pip-cache-windows.outputs.dir }} key: ${{ runner.os }}-pip-${{ matrix.python-version }} restore-keys: | ${{ runner.os }}-pip- @@ -301,14 +328,11 @@ 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') }} + - name: Install zodbpickle 3.13.0-alpha - 3.13.0 ${{ matrix.python-version }} + if: 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 + # coverage might have 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 @@ -317,7 +341,7 @@ jobs: 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] + pip install --pre -U -e .[test] - name: Install zodbpickle if: ${{ !startsWith(matrix.python-version, '3.13.0-alpha - 3.13.0') }} run: | @@ -336,7 +360,9 @@ jobs: - name: Run tests without C extensions run: # coverage makes PyPy run about 3x slower! - PURE_PYTHON=1 python -m coverage run -p -m zope.testrunner --test-path=src --auto-color --auto-progress + python -m coverage run -p -m zope.testrunner --test-path=src --auto-color --auto-progress + env: + PURE_PYTHON: 1 - name: Report Coverage run: | coverage combine @@ -378,15 +404,32 @@ jobs: # to save the cache. So it must come before the thing we want to use # the cache. ### - - name: Get pip cache dir - id: pip-cache + - name: Get pip cache dir (default) + id: pip-cache-default + if: ${{ !startsWith(runner.os, 'Windows') }} run: | echo "dir=$(pip cache dir)" >>$GITHUB_OUTPUT - - name: pip cache + - name: Get pip cache dir (Windows) + id: pip-cache-windows + if: ${{ startsWith(runner.os, 'Windows') }} + run: | + echo "dir=$(pip cache dir)" >> $Env:GITHUB_OUTPUT + + - name: pip cache (default) + uses: actions/cache@v4 + if: ${{ !startsWith(runner.os, 'Windows') }} + with: + path: ${{ steps.pip-cache-default.outputs.dir }} + key: ${{ runner.os }}-pip-${{ matrix.python-version }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: pip cache (Windows) uses: actions/cache@v4 + if: ${{ startsWith(runner.os, 'Windows') }} with: - path: ${{ steps.pip-cache.outputs.dir }} + path: ${{ steps.pip-cache-windows.outputs.dir }} key: ${{ runner.os }}-pip-${{ matrix.python-version }} restore-keys: | ${{ runner.os }}-pip- @@ -431,15 +474,32 @@ jobs: # to save the cache. So it must come before the thing we want to use # the cache. ### - - name: Get pip cache dir - id: pip-cache + - name: Get pip cache dir (default) + id: pip-cache-default + if: ${{ !startsWith(runner.os, 'Windows') }} run: | echo "dir=$(pip cache dir)" >>$GITHUB_OUTPUT - - name: pip cache + - name: Get pip cache dir (Windows) + id: pip-cache-windows + if: ${{ startsWith(runner.os, 'Windows') }} + run: | + echo "dir=$(pip cache dir)" >> $Env:GITHUB_OUTPUT + + - name: pip cache (default) + uses: actions/cache@v4 + if: ${{ !startsWith(runner.os, 'Windows') }} + with: + path: ${{ steps.pip-cache-default.outputs.dir }} + key: ${{ runner.os }}-pip_manylinux-${{ matrix.image }}-${{ matrix.python-version }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: pip cache (Windows) uses: actions/cache@v4 + if: ${{ startsWith(runner.os, 'Windows') }} with: - path: ${{ steps.pip-cache.outputs.dir }} + path: ${{ steps.pip-cache-windows.outputs.dir }} key: ${{ runner.os }}-pip_manylinux-${{ matrix.image }}-${{ matrix.python-version }} restore-keys: | ${{ runner.os }}-pip- @@ -477,7 +537,7 @@ jobs: path: wheelhouse/*whl name: manylinux_${{ matrix.image }}_wheels.zip - name: Restore pip cache permissions - run: sudo chown -R $(whoami) ${{ steps.pip-cache.outputs.dir }} + run: sudo chown -R $(whoami) ${{ steps.pip-cache-default.outputs.dir }} - name: Publish package to PyPI uses: pypa/gh-action-pypi-publish@release/v1 if: > diff --git a/.meta.toml b/.meta.toml index 9267487..57f6fef 100644 --- a/.meta.toml +++ b/.meta.toml @@ -2,15 +2,16 @@ # https://github.com/zopefoundation/meta/tree/master/config/c-code [meta] template = "c-code" -commit-id = "1351c95d" +commit-id = "8daa034c" [python] with-appveyor = true -with-windows = false +with-windows = true with-pypy = true with-sphinx-doctests = false with-future-python = true with-macos = false +with-docs = false [tox] use-flake8 = true diff --git a/CHANGES.rst b/CHANGES.rst index eaac311..c222127 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,8 @@ 3.3 (unreleased) ================ +- Build Windows wheels on GHA. + - Add preliminary support for Python 3.13 as of 3.13a5. diff --git a/MANIFEST.in b/MANIFEST.in index 27c8622..4ecf9c4 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,7 +5,6 @@ include *.rst include *.txt include buildout.cfg include tox.ini -include appveyor.yml include .coveragerc recursive-include src *.py diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 75f4626..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,52 +0,0 @@ -# Generated from: -# https://github.com/zopefoundation/meta/tree/master/config/c-code -environment: - # Currently the builds use @mgedmin's Appveyor account. The PyPI token belongs - # to zope.wheelbuilder, which is managed by @mgedmin and @dataflake. - global: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: - secure: aoZC/+rvJKg8B5GMGIxd1YzSugYzr1vrR0NzX+NBCGjc64YaTc/K4kIRj4eqD0p11Nhl2aGUgHF6qMUcHIAAUybaKU/3Kyp+BwxU5eGX/NZv9S6AsBGVyiHD4oourkczzeB/HGrICEm9TeTcR3lc70SrpxSpYwnDyLv8CUpk0D/iUgQyFT/BERDsBTJEPI3HV/ngmMQrj9g2H7PkfF0yR5ss8AclYcIdWOKTvTapcGLerlK+mFm5muturTCT2njYMP2cv+NV3+Ih6OxSpQlWjw== - - matrix: - - python: 37-x64 - - python: 38-x64 - - python: 39-x64 - - 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%" - - "SET PATH=C:\\Python%PYTHON%;c:\\Python%PYTHON%\\scripts;%PATH%" - - ps: | - $env:PYTHON = "C:\\Python${env:PYTHON}" - if (-not (Test-Path $env:PYTHON)) { - curl -o install_python.ps1 https://raw.githubusercontent.com/matthew-brett/multibuild/11a389d78892cf90addac8f69433d5e22bfa422a/install_python.ps1 - .\install_python.ps1 - } - - ps: if (-not (Test-Path $env:PYTHON)) { throw "No $env:PYTHON" } - - echo "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 > "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat" - - python -m pip install -U pip - - pip install -U setuptools wheel - - pip install -U -e .[test] - -matrix: - fast_finish: true - -build_script: - - python -W ignore setup.py -q bdist_wheel - -test_script: - - zope-testrunner --test-path=src -artifacts: - - path: 'dist\*.whl' - name: wheel - -deploy_script: - - ps: if ($env:APPVEYOR_REPO_TAG -eq $TRUE) { pip install twine; twine upload --skip-existing dist\*.whl } - -deploy: on diff --git a/src/zodbpickle/_pickle_33.c b/src/zodbpickle/_pickle_33.c index 83cf455..d01c49c 100644 --- a/src/zodbpickle/_pickle_33.c +++ b/src/zodbpickle/_pickle_33.c @@ -32,7 +32,7 @@ _Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size) * 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, +static int _PyLong_AsByteArray_compat(PyLongObject* v, unsigned char* bytes, size_t n, int little_endian, int is_signed) {