Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 32 additions & 37 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ on:

jobs:
build-and-test:
name: Testing with Python 3.${{ matrix.python_minor }} on Linux
runs-on: ubuntu-20.04
strategy:
matrix:
python_minor: [ "6" , "7" , "8" , "9" , "10" ]
name: Testing on Linux
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4.2.2
- uses: actions/checkout@v5.0.0
- name: Install cibuildwheel
run: |
python3 -m pip install --upgrade pip
Expand All @@ -26,8 +23,8 @@ jobs:
- name: 🛠 Build and Test Hexhamming Python C extension
run: cibuildwheel
env:
CIBW_BUILD: ${{ format('cp3{0}-manylinux_x86_64', matrix.python_minor) }}
CIBW_BEFORE_TEST: pip install -r requirements-dev.txt
CIBW_BUILD: "cp3*-manylinux_x86_64"
CIBW_BEFORE_TEST: pip install ".[dev]"
CIBW_TEST_COMMAND: "pytest -s {project}"
CIBW_BUILD_VERBOSITY: 1

Expand All @@ -38,15 +35,15 @@ jobs:
if: startsWith(github.ref, 'refs/tags')
needs: build-and-test
name: Source distribution
runs-on: macos-11
runs-on: macos-latest

steps:
- uses: actions/checkout@v4.2.2
- uses: actions/checkout@v5.0.0
- name: Install requirements
run: |
pip3 install --user check-manifest twine
python3 -m pip install --upgrade pip setuptools wheel
python3 -m pip install -r requirements-dev.txt
python3 -m pip install ".[dev]"

- name: Run check-manifest
run: python3 -m check_manifest
Expand All @@ -61,7 +58,7 @@ jobs:
run: python3 -m twine check wheelhouse/*

- name: Upload sdist
uses: actions/upload-artifact@v4.4.3
uses: actions/upload-artifact@v4.6.2
with:
name: wheels
path: wheelhouse/*.tar.gz
Expand All @@ -70,15 +67,14 @@ jobs:
if: startsWith(github.ref, 'refs/tags')
needs: [build-and-test, sdist]
name: Build macOS ${{ matrix.cibw_python }} ${{ matrix.cibw_arch }} wheels
runs-on: macos-11
runs-on: macos-latest
strategy:
fail-fast: true
matrix:
cibw_python: [ "cp38-*", "cp39-*", "cp310-*" ]
cibw_arch: [ "x86_64", "arm64" ]

steps:
- uses: actions/checkout@v4.2.2
- uses: actions/checkout@v5.0.0
- name: Install cibuildwheel
run: |
python3 -m pip install --upgrade pip
Expand All @@ -93,21 +89,21 @@ jobs:
run: cibuildwheel
env:
CIBW_ENVIRONMENT: MACOSX_DEPLOYMENT_TARGET=${{ env.DEPLOYMENT_TARGET }}
CIBW_BUILD: ${{ matrix.cibw_python }}
CIBW_BUILD: "cp3*"
CIBW_ARCHS_MACOS: ${{ matrix.cibw_arch }}
CIBW_TEST_SKIP: "*-macosx_arm64"
CC: /usr/bin/clang
CXX: /usr/bin/clang++
CFLAGS: "-Wno-implicit-function-declaration"
CIBW_BEFORE_TEST: pip install -r requirements-dev.txt
CIBW_BEFORE_TEST: pip install ".[dev]"
CIBW_TEST_COMMAND: "pytest -s {project}"
CIBW_BUILD_VERBOSITY: 1

- name: Check built wheels
run: twine check wheelhouse/*

- name: Upload built wheels
uses: actions/upload-artifact@v4.4.3
uses: actions/upload-artifact@v4.6.2
with:
name: wheels
path: wheelhouse/*.whl
Expand All @@ -117,15 +113,15 @@ jobs:
if: startsWith(github.ref, 'refs/tags')
needs: [build-and-test, sdist]
name: Build ${{ matrix.cibw_buildlinux }} ${{ matrix.cibw_arch }} wheels
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
cibw_buildlinux: [ manylinux, musllinux ]
cibw_arch: [ "x86_64", "aarch64" ]

steps:
- uses: actions/checkout@v4.2.2
- uses: actions/checkout@v5.0.0
- name: Set up QEMU
if: matrix.cibw_arch == 'aarch64'
uses: docker/setup-qemu-action@v3.2.0
Expand All @@ -142,15 +138,15 @@ jobs:
env:
CIBW_BUILD: ${{ format('cp3*-{0}*', matrix.cibw_buildlinux) }}
CIBW_ARCHS_LINUX: ${{ matrix.cibw_arch }}
CIBW_BEFORE_TEST: pip install -r requirements-dev.txt
CIBW_BEFORE_TEST: pip install ".[dev]"
CIBW_TEST_COMMAND: "pytest -s {project}"
CIBW_BUILD_VERBOSITY: 1

- name: Check built wheels
run: twine check wheelhouse/*

- name: Upload built wheels
uses: actions/upload-artifact@v4.4.3
uses: actions/upload-artifact@v4.6.2
with:
name: wheels
path: wheelhouse/*.whl
Expand All @@ -160,10 +156,10 @@ jobs:
if: startsWith(github.ref, 'refs/tags')
needs: [build-and-test, sdist]
name: Build Windows wheels
runs-on: windows-2019
runs-on: windows-latest

steps:
- uses: actions/checkout@v4.2.2
- uses: actions/checkout@v5.0.0
- name: Install cibuildwheel
run: |
python3 -m pip install --upgrade pip
Expand All @@ -172,17 +168,17 @@ jobs:
- name: 🛠 Build Hexhamming Python C extension
run: cibuildwheel
env:
CIBW_BUILD: "cp36-* cp37-* cp38-* cp39-* cp310-*"
CIBW_BUILD: "cp3*"
CIBW_ARCHS_WINDOWS: "AMD64"
CIBW_BEFORE_TEST: pip install -r requirements-dev.txt
CIBW_BEFORE_TEST: pip install ".[dev]"
CIBW_TEST_COMMAND: "pytest -s {project}"
CIBW_BUILD_VERBOSITY: 1

- name: Check built wheels
run: twine check wheelhouse/*

- name: Upload built wheels
uses: actions/upload-artifact@v4.4.3
uses: actions/upload-artifact@v4.6.2
with:
name: wheels
path: wheelhouse/*.whl
Expand All @@ -192,20 +188,19 @@ jobs:
if: startsWith(github.ref, 'refs/tags')
needs: [wheels_macos, wheels_linux, wheels_windows]
name: Publish wheels
runs-on: ubuntu-20.04
environment:
name: pypi
url: https://pypi.org/p/hexhamming
permissions:
id-token: write
runs-on: ubuntu-latest

steps:
- name: Collect sdist and wheels
uses: actions/download-artifact@v4.1.8
uses: actions/download-artifact@v5.0.0
with:
name: wheels
path: wheelhouse

- name: Install twine
run: python -m pip install twine
path: dist

- name: 📦 Publish distribution to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload --skip-existing wheelhouse/*
uses: pypa/gh-action-pypi-publish@release/v1
25 changes: 21 additions & 4 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
"THE BEERWARE LICENSE" (Revision 42):
Michael Recachinas <mrecachinas@gmail.com> wrote this software. As long as you retain
this notice, you can do whatever you want with this stuff. If we meet some
day, and you think this stuff is worth it, you can buy me a beer in return.
MIT License

Copyright (c) 2024 Michael Recachinas

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 7 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,17 @@ or to install from source

git clone https://github.com/mrecachinas/hexhamming
cd hexhamming
python setup.py install # or pip install .
pip install .

If you want to contribute to hexhamming, you should install the dev
dependencies

::

pip install -e ".[dev]"

Alternatively, you can still use the legacy method:

::

pip install -r requirements-dev.txt
Expand Down
43 changes: 43 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[build-system]
requires = ["setuptools>=45", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "hexhamming"
dynamic = ["version"]
description = "Fast Hamming distance calculation for hexadecimal strings"
readme = "README.rst"
license = "MIT"
license-files = [
"LICENSE",
]
authors = [
{name = "Michael Recachinas", email = "m.recachinas@gmail.com"}
]
keywords = ["hamming", "distance", "simd"]
classifiers = [
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
"Programming Language :: C"
]
requires-python = ">=3.10"

[project.urls]
Repository = "https://github.com/mrecachinas/hexhamming.git"

[project.optional-dependencies]
dev = [
"ruff",
"pytest",
"pytest-benchmark"
]

[tool.setuptools]
zip-safe = false

[tool.setuptools.packages.find]
include = ["hexhamming*"]

[tool.pytest.ini_options]
testpaths = ["test"]
3 changes: 0 additions & 3 deletions requirements-dev.txt

This file was deleted.

31 changes: 5 additions & 26 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,20 @@ def get_version():
return search(r'_version.*"(.*)";', f.read(), IGNORECASE).groups()[0]


with open("./README.rst", "r") as readme_file:
long_description = readme_file.read()

with open("requirements-dev.txt", "r", encoding="utf-8") as fh:
test_requirements = [line.rstrip() for line in fh.readlines()]

# Platform-specific compiler optimization flags
extra_compile_args = []
if system().lower() == "darwin" and (machine().lower() == "arm64" or
environ.get("CIBW_ARCHS_MACOS", "") == "arm64"):
if system().lower() == "darwin" and (
machine().lower() == "arm64" or environ.get("CIBW_ARCHS_MACOS", "") == "arm64"
):
extra_compile_args.append("-mcpu=apple-m1")
elif uname().system == 'Windows':
elif uname().system == "Windows":
extra_compile_args.append("-O2")
extra_compile_args.append("/d2FH4-")
else:
extra_compile_args.append("-march=native")

setup(
name="hexhamming",
version=get_version(),
description="Fast Hamming distance calculation for hexadecimal strings",
url="https://github.com/mrecachinas/hexhamming.git",
long_description=long_description,
long_description_content_type="text/x-rst",
test_suite="test",
tests_require=test_requirements,
ext_modules=[
Extension(
name="hexhamming",
Expand All @@ -44,14 +33,4 @@ def get_version():
language="c++11",
)
],
author="Michael Recachinas",
author_email="m.recachinas@gmail.com",
classifiers=[
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
"Programming Language :: C"
],
keywords="hamming distance simd",
zip_safe=False,
)
Loading
Loading