diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 092c60a..0828616 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 6e4065c..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,92 +0,0 @@ -name: publish - -on: - workflow_dispatch: - inputs: - repository: - description: 'The repository to upload the package to' - required: true - default: 'testpypi' - -jobs: - build_wheels: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04, windows-2019, macOS-13] - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.9' - - - name: Set up QEMU - if: runner.os == 'Linux' - # uses: docker/setup-qemu-action@v1.0.1 - uses: docker/setup-qemu-action@v3 - with: - platforms: arm64 - - - 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: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: cibw-wheels-${{ strategy.job-index }} - path: ./wheelhouse/*.whl - - build_sdist: - name: Build a source distribution - runs-on: ubuntu-20.04 - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.9' - - - name: Build sdist - run: | - pip install py-cpuinfo - python setup.py build sdist - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: cibw-sdist-${{ strategy.job-index }} - path: dist/*.tar.gz - - publish: - needs: [build_wheels, build_sdist] - environment: ${{ github.event.inputs.repository }} - permissions: - id-token: write - runs-on: ubuntu-latest - steps: - - uses: actions/download-artifact@v4 - with: - pattern: cibw-* - path: dist - merge-multiple: true - - - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/src/cityhash.pyx b/src/cityhash.pyx index 566b8fd..ed0ece8 100644 --- a/src/cityhash.pyx +++ b/src/cityhash.pyx @@ -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: @@ -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 diff --git a/src/cityhashcrc.pyx b/src/cityhashcrc.pyx index accd84e..610ece8 100644 --- a/src/cityhashcrc.pyx +++ b/src/cityhashcrc.pyx @@ -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: @@ -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 diff --git a/src/farmhash.pyx b/src/farmhash.pyx index d9bbffb..7123883 100644 --- a/src/farmhash.pyx +++ b/src/farmhash.pyx @@ -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: @@ -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: @@ -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