Skip to content
Open
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
32 changes: 17 additions & 15 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: Python package
env:
PYTHON_VERSION: 3.8

on:
push:
Expand All @@ -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]
Expand All @@ -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
Expand All @@ -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

Expand All @@ -80,19 +82,19 @@ jobs:
runs-on: ubuntu-latest

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 build
- name: Build dists
run: |
python -m build --sdist
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v7
with:
path: dist/*.tar.gz

Expand All @@ -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
Expand Down
26 changes: 15 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand All @@ -62,6 +62,10 @@ repos:
- flake8-mutable
- flake8-simplify
- repo: https://github.com/Yelp/detect-secrets
rev: v1.4.0
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
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include MetroHash/src/*.h
global-include *.pyx
recursive-include src/metrohash *.pyx *.pyi py.typed
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
15 changes: 12 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -27,7 +27,7 @@

extensions = [
Extension(
"metrohash",
"metrohash._metrohash",
sources=EXT_SOURCES + INT_SOURCES,
extra_compile_args=cflags,
include_dirs=["MetroHash/src"],
Expand All @@ -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,
Expand All @@ -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,
)
8 changes: 8 additions & 0 deletions src/metrohash/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from ._metrohash import MetroHash64, MetroHash128, metrohash64, metrohash128

__all__ = [
"MetroHash128",
"MetroHash64",
"metrohash128",
"metrohash64",
]
42 changes: 42 additions & 0 deletions src/metrohash/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
File renamed without changes.
Empty file added src/metrohash/py.typed
Empty file.
11 changes: 11 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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
Expand Down