From 3afeea46e2494e6c9abc046d9aef7988e3e7150e Mon Sep 17 00:00:00 2001 From: Naveen M K Date: Mon, 7 Jun 2021 12:26:38 +0530 Subject: [PATCH 1/3] Build Wheels using Github Actions and automatically publish to PyPI on release. --- .github/workflows/build.yml | 63 +++++++++++++++++++++++++++++++++++++ tools/test_wheels.sh | 17 ++++++++++ 2 files changed, 80 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 tools/test_wheels.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f19211f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,63 @@ +name: Build Wheels + +on: + push: + release: + types: [created] + +jobs: + build_wheels: + name: Build Wheels on ${{ matrix.os }}-${{ matrix.platform_id }} + runs-on: ${{ matrix.os }} + strategy: + # Ensure the wheels build even one fails. + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + python: [35, 36, 37, 38, 39] + bitness: [32, 64] + include: + # Run 32 and 64 bit version in parallel for Linux and Windows + - os: windows-latest + bitness: 64 + platform_id: win_amd64 + - os: windows-latest + bitness: 32 + platform_id: win32 + - os: ubuntu-latest + bitness: 64 + platform_id: manylinux_x86_64 + - os: ubuntu-latest + bitness: 32 + platform_id: manylinux_i686 + - os: macos-latest + bitness: 64 + platform_id: macosx_x86_64 + exclude: + - os: macos-latest + bitness: 32 + env: + CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }} + CIBW_TEST_REQUIRES: pytest==4.* hypothesis==4.* + CIBW_TEST_COMMAND: "bash {project}/tools/test_wheels.sh {project}" + CIBW_MANYLINUX_X86_64_IMAGE: manylinux1 + CIBW_MANYLINUX_I686_IMAGE: manylinux1 + steps: + - uses: actions/checkout@v2 + + - name: Build wheels + uses: pypa/cibuildwheel@v1.11.1.post1 + + - uses: actions/upload-artifact@v2 + with: + path: ./wheelhouse/*.whl + name: wheels-${{ runner.os }}-${{ matrix.platform_id }}-${{ matrix.python }} + + - name: Publish (Release) + if: github.event_name == 'release' + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + pip install twine + twine upload wheelhouse/*.whl diff --git a/tools/test_wheels.sh b/tools/test_wheels.sh new file mode 100644 index 0000000..92e329a --- /dev/null +++ b/tools/test_wheels.sh @@ -0,0 +1,17 @@ +#!/bin/bash +#test wheels in different directory +set -e +set -x +package=$1 + +FILE_PATH="`dirname \"$0\"`" +FILE_PATH="`( cd \"$FILE_PATH\" && pwd )`" +if [ -z "$FILE_PATH" ] ; then + exit 1 +fi + +cd $TMP +cp -r $package/tests mtests +pytest -s mtests +rm -r mtests +cd $FILE_PATH From f572737f1e1766791f756ed17aa2eb4239820099 Mon Sep 17 00:00:00 2001 From: Naveen M K Date: Tue, 8 Jun 2021 11:07:43 +0530 Subject: [PATCH 2/3] Add .pyd to gitignore it's compiled extensions on Windows --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 80e33f0..517cfc4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.pyc *# *.so +*.pyd *~ build/ pyrsistent.egg-info/ From adb438f0fd50b3dd4ff78177281adc9e16d086f6 Mon Sep 17 00:00:00 2001 From: Naveen M K Date: Tue, 8 Jun 2021 11:08:40 +0530 Subject: [PATCH 3/3] Change the return type of PVector_hash it should be Py_hash_t rather than long and it fixes tests on win_amd64 --- pvectorcmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvectorcmodule.c b/pvectorcmodule.c index 0f77123..ea69998 100644 --- a/pvectorcmodule.c +++ b/pvectorcmodule.c @@ -280,7 +280,7 @@ static PyObject *PVector_repr(PVector *self) { } -static long PVector_hash(PVector *self) { +static Py_hash_t PVector_hash(PVector *self) { // Follows the pattern of the tuple hash long x, y; Py_ssize_t i;