From 0f4dfc756fcdd4dd8af8ab2f380a5c321069c07e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20D=C3=B6rrer?= Date: Sun, 26 Jul 2026 16:42:42 +0200 Subject: [PATCH 1/6] update pre-commit hooks to latest versions --- .pre-commit-config.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 61a144c..7c2e675 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v6.0.0 hooks: - id: check-json - id: check-toml @@ -15,44 +15,44 @@ repos: - id: trailing-whitespace args: [--markdown-linebreak-ext=md] - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks - rev: v2.13.0 + rev: v2.16.0 hooks: - id: pretty-format-yaml args: [--autofix] - repo: https://github.com/tox-dev/pyproject-fmt - rev: 1.7.0 + rev: v2.25.3 hooks: - id: pyproject-fmt - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v18.1.3 + rev: v22.1.8 hooks: - id: clang-format - repo: https://github.com/asottile/pyupgrade - rev: v3.15.2 + rev: v3.21.2 hooks: - id: pyupgrade args: [--py37-plus] - repo: https://github.com/MarcoGorelli/cython-lint - rev: v0.16.2 + rev: v0.21.0 hooks: - id: cython-lint - id: double-quote-cython-strings - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.4.0 + rev: 26.5.1 hooks: - id: black - repo: https://github.com/PyCQA/isort - rev: 5.13.2 + rev: 8.0.1 hooks: - id: isort - repo: https://github.com/PyCQA/bandit - rev: 1.7.8 + rev: 1.9.4 hooks: - id: bandit args: [-c, pyproject.toml] additional_dependencies: ['.[toml]'] - repo: https://github.com/pycqa/flake8 - rev: 7.0.0 + rev: 7.3.0 hooks: - id: flake8 additional_dependencies: @@ -62,6 +62,6 @@ repos: - flake8-mutable - flake8-simplify - repo: https://github.com/Yelp/detect-secrets - rev: v1.4.0 + rev: v1.5.0 hooks: - id: detect-secrets From 016286a7e904fb4da5dc3dbad9554a24ac758811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20D=C3=B6rrer?= Date: Sun, 26 Jul 2026 16:46:21 +0200 Subject: [PATCH 2/6] add tox config to run unittests --- .pre-commit-config.yaml | 4 ++++ tox.ini | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7c2e675..a30d201 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -65,3 +65,7 @@ repos: rev: v1.5.0 hooks: - id: detect-secrets +- repo: https://github.com/tox-dev/tox-ini-fmt + rev: 1.8.0 + hooks: + - id: tox-ini-fmt diff --git a/tox.ini b/tox.ini index 0361504..52ab4ea 100644 --- a/tox.ini +++ b/tox.ini @@ -1,3 +1,14 @@ +[tox] +requires = + tox>=4.2 +env_list = + py3.{15, 14, 13, 12, 11, 10, 9, 8, 7} +skip_missing_interpreters = true + +[testenv] +commands = + python -m unittest discover -s tests + [flake8] max-line-length = 120 select = B, E7, E9, W2, W3, W6, F From 9bd84d5ab76dd2d2c3d105152ddf155cecd439ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20D=C3=B6rrer?= Date: Sun, 26 Jul 2026 17:01:02 +0200 Subject: [PATCH 3/6] bump github actions and added latest python version in matrix --- .github/workflows/pythonpackage.yml | 30 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 21321b0..f34ccf6 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -1,4 +1,6 @@ name: Python package +env: + PYTHON_VERSION: 3.8 on: push: @@ -12,10 +14,10 @@ jobs: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@v7 + - uses: actions/setup-python@v7 with: - python-version: 3.8 + python-version: ${{ env.PYTHON_VERSION }} - name: Install dependencies run: | python -m pip install black isort flake8 bandit[toml] @@ -29,14 +31,14 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 with: submodules: true - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v7 with: python-version: ${{ matrix.python-version }} - name: Install @@ -57,19 +59,19 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 with: submodules: true - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v7 with: - python-version: 3.8 + python-version: ${{ env.PYTHON_VERSION }} - name: Install dependencies run: | python -m pip install setuptools wheel cython cibuildwheel==2.3.0 - name: Build wheels run: | python -m cibuildwheel --output-dir wheelhouse - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v7 with: path: ./wheelhouse/*.whl @@ -83,16 +85,16 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v7 with: - python-version: 3.8 + python-version: ${{ env.PYTHON_VERSION }} - name: Install dependencies run: | python -m pip install build - name: Build dists run: | python -m build --sdist - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v7 with: path: dist/*.tar.gz @@ -105,7 +107,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v8 with: name: artifact path: dist From 589f26981b03eafe9a8b6fd6633b518d1f25d481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20D=C3=B6rrer?= Date: Sun, 26 Jul 2026 20:19:18 +0200 Subject: [PATCH 4/6] added stubfiles for metrohash classes and functions --- src/metrohash/__init__.py | 0 src/metrohash/__init__.pyi | 42 ++++++++++++++++++++++++++++++++++++++ src/metrohash/py.typed | 0 3 files changed, 42 insertions(+) create mode 100644 src/metrohash/__init__.py create mode 100644 src/metrohash/__init__.pyi create mode 100644 src/metrohash/py.typed diff --git a/src/metrohash/__init__.py b/src/metrohash/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/metrohash/__init__.pyi b/src/metrohash/__init__.pyi new file mode 100644 index 0000000..794605f --- /dev/null +++ b/src/metrohash/__init__.pyi @@ -0,0 +1,42 @@ +import typing as t + +from _typeshed import ReadableBuffer + +__all__: t.Final[t.List[str]] = [ + "MetroHash128", + "MetroHash64", + "metrohash128", + "metrohash64", +] + +def metrohash128(data: ReadableBuffer, seed: int = 0) -> bytes: ... +def metrohash64(data: ReadableBuffer, seed: int = 0) -> bytes: ... +@t.final +class MetroHash128: + @property + def block_size(self) -> int: ... + @property + def digest_size(self) -> int: ... + @property + def name(self) -> str: ... + @classmethod + def __init__(cls, *, seed: int = 0) -> None: ... + def copy(self) -> MetroHash128: ... + def digest(self) -> bytes: ... + def hexdigest(self) -> str: ... + def update(self, data: ReadableBuffer) -> None: ... + +@t.final +class MetroHash64: + @property + def block_size(self) -> int: ... + @property + def digest_size(self) -> int: ... + @property + def name(self) -> str: ... + @classmethod + def __init__(cls, *, seed: int = 0) -> None: ... + def copy(self) -> MetroHash64: ... + def digest(self) -> bytes: ... + def hexdigest(self) -> str: ... + def update(self, data: ReadableBuffer) -> None: ... diff --git a/src/metrohash/py.typed b/src/metrohash/py.typed new file mode 100644 index 0000000..e69de29 From e5d739f6a1c1689e5807a5a9226c78ef064ea661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20D=C3=B6rrer?= Date: Sun, 26 Jul 2026 20:26:51 +0200 Subject: [PATCH 5/6] refactor: reorganize project structure and include necessary files for metrohash package in setup.py --- MANIFEST.in | 2 +- setup.py | 13 +++++++++++-- src/metrohash/__init__.py | 8 ++++++++ metrohash.pyx => src/metrohash/_metrohash.pyx | 0 4 files changed, 20 insertions(+), 3 deletions(-) rename metrohash.pyx => src/metrohash/_metrohash.pyx (100%) diff --git a/MANIFEST.in b/MANIFEST.in index 8ec70e6..85363e2 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,2 @@ include MetroHash/src/*.h -global-include *.pyx +recursive-include src/metrohash *.pyx *.pyi py.typed diff --git a/setup.py b/setup.py index 483dd16..806baa9 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ "MetroHash/src/metrohash128.cpp", ] -INT_SOURCES = ["metrohash.pyx"] +INT_SOURCES = ["src/metrohash/_metrohash.pyx"] machine = platform.machine().lower() x86 = ("x86_64", "amd64", "i386", "x86", "i686") @@ -27,7 +27,7 @@ extensions = [ Extension( - "metrohash", + "metrohash._metrohash", sources=EXT_SOURCES + INT_SOURCES, extra_compile_args=cflags, include_dirs=["MetroHash/src"], @@ -62,4 +62,13 @@ ext_modules=cythonize(extensions), python_requires=">=3.7", zip_safe=False, + package_dir={"": "src"}, + packages=["metrohash"], + package_data={ + "metrohash": ["*.pyi", "py.typed"], + }, + exclude_package_data={ + "metrohash": ["*.pyx", "*.cpp", "*.c"], + }, + include_package_data=True, ) diff --git a/src/metrohash/__init__.py b/src/metrohash/__init__.py index e69de29..af46b38 100644 --- a/src/metrohash/__init__.py +++ b/src/metrohash/__init__.py @@ -0,0 +1,8 @@ +from ._metrohash import MetroHash64, MetroHash128, metrohash64, metrohash128 + +__all__ = [ + "MetroHash128", + "MetroHash64", + "metrohash128", + "metrohash64", +] diff --git a/metrohash.pyx b/src/metrohash/_metrohash.pyx similarity index 100% rename from metrohash.pyx rename to src/metrohash/_metrohash.pyx From ce628a295736fb2f1f7bcedeaaf0b14f22e0cff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20D=C3=B6rrer?= Date: Sun, 26 Jul 2026 20:54:26 +0200 Subject: [PATCH 6/6] bumped version to 1.1.3.4 --- .github/workflows/pythonpackage.yml | 2 +- README.md | 4 ++-- setup.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index f34ccf6..97159df 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -82,7 +82,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 with: submodules: true - uses: actions/setup-python@v7 diff --git a/README.md b/README.md index 64b854e..0402edd 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ Python bindings for the fast non-cryptograpical hash function MetroHash. MetroHa ## Requirements -The library has been tested on Linux Python 3.6, and on Windows Python 3.6, 3.7. +The library has been tested on Linux Python ^3.7, and on Windows Python ^3.7. ## Install -``` +```console pip install metrohash-python ``` diff --git a/setup.py b/setup.py index 806baa9..6b45b0e 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ setup( author="Dobatymo", name="metrohash-python", - version="1.1.3.3", + version="1.1.3.4", url="https://github.com/Dobatymo/metrohash-python", description="Python bindings for MetroHash", long_description=long_description,