Skip to content
Closed
65 changes: 34 additions & 31 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,52 @@
name: build
name: Build wheels

on:
push:
branches:
- master
branches: [main]
pull_request:
types:
- opened
- synchronize
- reopened
branches: [main]
workflow_dispatch:

jobs:
build:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
python-version: ["3.13"]

runs-on: ${{ matrix.os }}
os: [ubuntu-20.04, windows-2019, macOS-13]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
python-version: '3.9'

# block below based on:
# https://medium.com/ai2-blog/python-caching-in-github-actions-e9452698e98d
- name: Cache Python environment
uses: actions/cache@v4
- name: Set up QEMU
if: runner.os == 'Linux'
# uses: docker/setup-qemu-action@v1.0.1
uses: docker/setup-qemu-action@v3
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('pip-freeze.txt') }}
platforms: arm64

- name: Install dependencies
run: |
pip install --upgrade --upgrade-strategy eager setuptools wheel
pip install --upgrade --upgrade-strategy eager -r requirements.txt
pip freeze > pip-freeze.txt
- name: Build wheels
# uses: joerick/cibuildwheel@v1.9.0
uses: pypa/cibuildwheel@v2.23.0
with:
output-dir: wheelhouse
env:
CIBW_BUILD: '{cp36,cp37,cp38,cp39,cp310,cp311,cp312,cp313}-{manylinux_x86_64,manylinux_aarch64,win32,win_amd64,macosx_x86_64} {cp39,cp310,cp311,cp312,cp313}-macosx_arm64'
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
CIBW_ARCHS_LINUX: 'auto aarch64'
CIBW_ARCHS_MACOS: 'auto arm64'
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: 'pytest -s {project}/tests'
CIBW_TEST_SKIP: '*-macosx_arm64' # Until the day Apple silicon instances are available on GitHub Actions

- name: Test with pytest
run: |
python setup.py build_ext --inplace
pip install -e .
python -m pytest
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
92 changes: 0 additions & 92 deletions .github/workflows/publish.yml

This file was deleted.

8 changes: 6 additions & 2 deletions src/cityhash.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ def CityHash128(data) -> int:
PyBuffer_Release(&buf)
else:
raise _type_error("data", ["basestring", "buffer"], data)
return (long(result.first) << 64ULL) + long(result.second)
cdef unsigned PY_LONG_LONG high = result.first
cdef unsigned PY_LONG_LONG low = result.second
return (high << 64) + low


def CityHash128WithSeed(data, seed: int = 0L) -> int:
Expand Down Expand Up @@ -262,4 +264,6 @@ def CityHash128WithSeed(data, seed: int = 0L) -> int:
PyBuffer_Release(&buf)
else:
raise _type_error("data", ["basestring", "buffer"], data)
return (long(result.first) << 64ULL) + long(result.second)
cdef unsigned PY_LONG_LONG high = result.first
cdef unsigned PY_LONG_LONG low = result.second
return (high << 64) + low
8 changes: 6 additions & 2 deletions src/cityhashcrc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ def CityHashCrc128(data) -> int:
PyBuffer_Release(&buf)
else:
raise _type_error("data", ["basestring", "buffer"], data)
return (long(result.first) << 64ULL) + long(result.second)
cdef unsigned PY_LONG_LONG high = result.first
cdef unsigned PY_LONG_LONG low = result.second
return (high << 64) + low


def CityHashCrc256Bytes(data) -> bytes:
Expand Down Expand Up @@ -169,4 +171,6 @@ def CityHashCrc128WithSeed(data, seed: int = 0L) -> int:
PyBuffer_Release(&buf)
else:
raise _type_error("data", ["basestring", "buffer"], data)
return (long(result.first) << 64ULL) + long(result.second)
cdef unsigned PY_LONG_LONG high = result.first
cdef unsigned PY_LONG_LONG low = result.second
return (high << 64) + low
12 changes: 9 additions & 3 deletions src/farmhash.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,9 @@ def FarmHash128(data) -> int:
PyBuffer_Release(&buf)
else:
raise _type_error("data", ["basestring", "buffer"], data)
return (long(result.first) << 64ULL) + long(result.second)
cdef unsigned PY_LONG_LONG high = result.first
cdef unsigned PY_LONG_LONG low = result.second
return (high << 64) + low


def Fingerprint128(data) -> int:
Expand Down Expand Up @@ -354,7 +356,9 @@ def Fingerprint128(data) -> int:
PyBuffer_Release(&buf)
else:
raise _type_error("data", ["basestring", "buffer"], data)
return (long(result.first) << 64ULL) + long(result.second)
cdef unsigned PY_LONG_LONG high = result.first
cdef unsigned PY_LONG_LONG low = result.second
return (high << 64) + low


def FarmHash128WithSeed(data, seed: int = 0L) -> int:
Expand Down Expand Up @@ -388,4 +392,6 @@ def FarmHash128WithSeed(data, seed: int = 0L) -> int:
PyBuffer_Release(&buf)
else:
raise _type_error("data", ["basestring", "buffer"], data)
return (long(result.first) << 64ULL) + long(result.second)
cdef unsigned PY_LONG_LONG high = result.first
cdef unsigned PY_LONG_LONG low = result.second
return (high << 64) + low