Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
4d01617
add pybind11 bindings
hendrikmuhs Oct 5, 2024
7fba918
build from root
hendrikmuhs Nov 24, 2024
dd71bc1
fix test errors
hendrikmuhs Nov 24, 2024
caf0b8d
lower pytest minversion
hendrikmuhs Nov 24, 2024
a98fa3a
remove pyodide
hendrikmuhs Nov 24, 2024
f954b5a
fix deprecation error
hendrikmuhs Nov 24, 2024
ad79339
switch to default build-frontend
hendrikmuhs Nov 24, 2024
80e0c35
fix sdist
hendrikmuhs Nov 24, 2024
17de53c
update cibuildwheel
hendrikmuhs Nov 24, 2024
9af17eb
repair sdist and tests
hendrikmuhs Nov 24, 2024
66fcf9d
install ninja-build
hendrikmuhs Nov 24, 2024
820000f
install build module
hendrikmuhs Nov 24, 2024
b9c1248
fix folder
hendrikmuhs Nov 24, 2024
2738036
use pipx
hendrikmuhs Nov 25, 2024
090aa89
remove env overrides
hendrikmuhs Nov 25, 2024
5db710d
re-add project dir
hendrikmuhs Nov 25, 2024
8da0bf1
add method
hendrikmuhs Dec 1, 2024
dc49e50
move todo
hendrikmuhs Dec 1, 2024
21fe7e5
add compiler
hendrikmuhs Dec 29, 2024
b5e86b1
checkstyle
hendrikmuhs Dec 29, 2024
ab73173
add more compilers and mergers
hendrikmuhs Dec 29, 2024
031b60b
fix msgpack unpacking
hendrikmuhs Jan 10, 2025
f9cd3dd
add missing file
hendrikmuhs Jan 10, 2025
ee397dd
update workflow with changes from latest master
hendrikmuhs Jul 26, 2025
a0ce94f
fix deprecation errors
hendrikmuhs Jul 26, 2025
ce5dc7c
rename to keyvi2
hendrikmuhs Jul 27, 2025
e52481b
implement dumps and loads
hendrikmuhs Jul 30, 2025
afce66a
switch to std::variant
hendrikmuhs Jul 30, 2025
c8b6ccd
fix attribute access
hendrikmuhs Jul 30, 2025
3956b86
WIP
hendrikmuhs Jul 31, 2025
6aeeef9
Merge branch 'master' of github.com:KeyviDev/keyvi into scikit-buildcore
hendrikmuhs Jul 31, 2025
f980eb2
Merge branch 'master' of github.com:KeyviDev/keyvi into scikit-buildcore
hendrikmuhs Sep 10, 2025
562cd78
update workflow
hendrikmuhs Sep 10, 2025
9cc8f3d
Merge branch 'master' into scikit-buildcore
hendrikmuhs Sep 29, 2025
f552c4f
style fixes
hendrikmuhs Sep 29, 2025
fe64e1c
free-threading
hendrikmuhs Sep 29, 2025
f4833ec
Merge branch 'master' of github.com:KeyviDev/keyvi into scikit-buildcore
hendrikmuhs Sep 30, 2025
d30a1fd
update workflow
hendrikmuhs Sep 30, 2025
dcb80f9
update pyproject.toml
hendrikmuhs Sep 30, 2025
311170d
move logic to pyproject.toml
hendrikmuhs Sep 30, 2025
3995a55
fix versions
hendrikmuhs Sep 30, 2025
c2cea87
add msgpacked_value_as_string: WIP
hendrikmuhs Oct 1, 2025
4b9534b
Merge branch 'master' of github.com:KeyviDev/keyvi into scikit-buildcore
hendrikmuhs Oct 8, 2025
a02899c
add msgpacked_value_as_string
hendrikmuhs Oct 9, 2025
8e2e10a
Merge branch 'master' of github.com:KeyviDev/keyvi into scikit-buildcore
hendrikmuhs Oct 14, 2025
675b412
bump version
hendrikmuhs Oct 14, 2025
5c38738
fix add for key only compiler
hendrikmuhs Oct 17, 2025
e0773f1
Merge branch 'master' of github.com:KeyviDev/keyvi into scikit-buildcore
hendrikmuhs Oct 25, 2025
ed41395
update workflow
hendrikmuhs Oct 25, 2025
a66a9e9
format
hendrikmuhs Oct 25, 2025
dd1af35
test NOLINT block
hendrikmuhs Oct 25, 2025
8018d03
try to make clang-tidy happy
hendrikmuhs Oct 25, 2025
18c5a38
exclude python-pybind for clang-tidy
hendrikmuhs Oct 25, 2025
5b818a0
Revert "test NOLINT block"
hendrikmuhs Oct 26, 2025
43d866b
disable free threading
hendrikmuhs Oct 26, 2025
16930be
implement keyvi module overwrite in test
hendrikmuhs Oct 26, 2025
ff7584c
add completion stub
hendrikmuhs Oct 26, 2025
7cfa644
fix import
hendrikmuhs Oct 26, 2025
0f69ecf
Merge branch 'master' of github.com:KeyviDev/keyvi into scikit-buildcore
hendrikmuhs Nov 17, 2025
076c1aa
add placeholders for missing submodules
hendrikmuhs Nov 17, 2025
d986c40
disable 2 tests
hendrikmuhs Nov 17, 2025
df6de22
add pytest-env
hendrikmuhs Nov 17, 2025
24fccdb
downgrade pytest-env
hendrikmuhs Nov 17, 2025
a8e49a5
add missing files
hendrikmuhs Nov 17, 2025
4444d29
remove separate test files
hendrikmuhs Nov 18, 2025
199e6d2
ruff fixes
hendrikmuhs Nov 18, 2025
45dbae1
pre-commit
hendrikmuhs Nov 18, 2025
700cf8d
pre-commit again
hendrikmuhs Nov 18, 2025
5ba857f
set config-file
hendrikmuhs Nov 18, 2025
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
1 change: 1 addition & 0 deletions .github/workflows/clang-tidy-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
with:
split_workflow: true
build_dir: build
exclude: 'python-pybind/*'
apt_packages: "libsnappy-dev, libzzip-dev, zlib1g-dev, libboost-all-dev, libzstd-dev"
clang_tidy_checks: ''
cmake_command: "cmake -Bbuild -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ."
Expand Down
139 changes: 139 additions & 0 deletions .github/workflows/python-cibuildwheel-pybind.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Python Pybind cibuildwheel

on:
push:
branches: [ master, release-* ]
paths-ignore:
- '.github/workflows/docs.yml'
- '.github/workflows/keyvi.yml'
- '.github/workflows/python-dockerimages-**.yml'
- '.github/workflows/rust**.yml'
- 'docker/**'
- 'doc/**'
- 'rust/**'
pull_request:
branches: [ master ]
paths-ignore:
- '.github/workflows/docs.yml'
- '.github/workflows/keyvi.yml'
- '.github/workflows/python-dockerimages-**.yml'
- '.github/workflows/rust**.yml'
- 'docker/**'
- 'doc/**'
- 'rust/**'
release:
types: [published]
workflow_dispatch:

jobs:
build_wheels:
name: pybind-cibuildwheel ${{ matrix.os }}/${{ matrix.flavor }}/${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# macos-15-intel: x86, macos-14: Arm64
os: [ubuntu-22.04, ubuntu-24.04-arm, macos-15-intel, macos-14]
# skip pypy, https://github.com/pypa/distutils/issues/283
flavor: ['cpython']
# separate musl and many on linux, for mac we just skip one of those
target: [ 'many', 'musl' ]
exclude:
- os: macos-15-intel
target: musl
- os: macos-14
target: musl

steps:
- uses: actions/checkout@v5
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ matrix.os }}-${{ matrix.target }}-${{ matrix.flavor }}-python-pybind

- name: Setup musllinux build
if: ${{ (runner.os == 'Linux') && (matrix.target == 'musl') }}
# workaround: set CXX to g++, so it does not pick clang++ for python 3.14 builds
run: |
echo "CIBW_SKIP=*manylinux*" >> $GITHUB_ENV
echo "CIBW_ENVIRONMENT_LINUX=CXX=g++" >> $GITHUB_ENV

- name: Setup manylinux build
if: ${{ (runner.os == 'Linux') && (matrix.target == 'many') }}
run: |
echo "CIBW_SKIP=*musllinux*" >> $GITHUB_ENV

- name: Skip pypy for cpython
if: ${{ matrix.flavor == 'cpython' }}
run: |
echo "CIBW_SKIP=${{ env.CIBW_SKIP }} pp*" >> $GITHUB_ENV

- name: Skip cpython for pypy
if: ${{ matrix.flavor == 'pypy' }}
run: |
echo "CIBW_SKIP=${{ env.CIBW_SKIP }} cp*" >> $GITHUB_ENV

- name: install mac dependencies
if: ${{ runner.os == 'macOS' }}
# 2nd command: workaround https://github.com/actions/setup-python/issues/577
run: |
brew update && \
brew list -1 | grep python | while read formula; do brew unlink $formula; brew link --overwrite $formula; done && \
brew install ccache zlib snappy boost

- name: set mac deployment target
if: runner.os == 'macOS' && runner.arch == 'X64'
run: |
echo "MACOSX_DEPLOYMENT_TARGET=15.0" >> $GITHUB_ENV

- name: set mac deployment target arm64
if: runner.os == 'macOS' && runner.arch == 'ARM64'
run: |
echo "MACOSX_DEPLOYMENT_TARGET=14.0" >> $GITHUB_ENV

- name: Build python wheels for ${{ matrix.os }}
uses: pypa/[email protected]
env:
# Skip CPython 3.8
CIBW_SKIP: ${{ env.CIBW_SKIP }} cp38-*

# only build native packages
CIBW_ARCHS: native

# skip tests on pypy, currently fails for indexer tests
CIBW_TEST_SKIP: "pp*"

# prefix ccache in path
CIBW_ENVIRONMENT_MACOS: ${{ env.CIBW_ENVIRONMENT_MACOS }} PATH=/usr/local/opt/ccache/libexec:/opt/homebrew/opt/ccache/libexec:$PATH
CIBW_ENVIRONMENT_LINUX: ${{ env.CIBW_ENVIRONMENT_LINUX }} PATH=/usr/local/bin:/usr/lib/ccache:$PATH CCACHE_DIR=/host${{ github.workspace }}/.ccache CCACHE_CONFIGPATH=/host/home/runner/.config/ccache/ccache.conf

# for debugging set this to 1,2 or 3
# CIBW_BUILD_VERBOSITY: 2

- uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.os }}-${{ matrix.flavor }}-${{ matrix.target }}
path: ./wheelhouse/*.whl

build_sdist:
name: sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: install Linux deps
run: |
sudo apt-get update && \
sudo apt-get install -y libsnappy-dev libzzip-dev zlib1g-dev libboost-all-dev ccache
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ubuntu-sdist-python-pybind

- name: Build SDist
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
pipx run build --sdist
python -m pip install dist/*.tar.gz -v && \
python -m pip install pytest && \
KEYVI_SKIP_TEST_DEPRECATIONS=1 KEYVI_MODULE_OVERWRITE=keyvi2 python -m pytest python/tests && \
python -m pip uninstall -y keyvi2
5 changes: 3 additions & 2 deletions .github/workflows/python-cibuildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ jobs:
- name: Build python wheels for ${{ matrix.os }}
uses: pypa/[email protected]
env:
# Skip CPython 3.8
CIBW_SKIP: ${{ env.CIBW_SKIP }} cp38-*
# Skip CPython 3.8 and free threading
CIBW_SKIP: ${{ env.CIBW_SKIP }} cp38-* cp3??t-*

# only build native packages
CIBW_ARCHS: native
Expand Down Expand Up @@ -125,6 +125,7 @@ jobs:
# for debugging set this to 1,2 or 3
# CIBW_BUILD_VERBOSITY: 2
with:
config-file: "{package}/pyproject.toml"
package-dir: python

- uses: actions/upload-artifact@v5
Expand Down
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*.orig

# cmake build dir
build/*
/*build*
*/cmake-build-debug/*
build_dir_debug/
cmake-build-debug/
Expand All @@ -45,3 +45,12 @@ cmake-build-debug/

# vim swap files
*.swp

# python
*.egg-info
.venv

# pybind build folder
python*/*build*
python*/dist
python*/.cache/
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ endif()
#### Options

option(KEYVI_C_BINDINGS "Keyvi: Build C binding" ${PROJECT_IS_TOP_LEVEL})
option(KEYVI_PYTHON_BINDINGS "Keyvi: Build Python module" OFF)
option(KEYVI_TESTS "Keyvi: Build unit tests" ${PROJECT_IS_TOP_LEVEL})
option(KEYVI_BINARIES "Keyvi: Build keyvi binaries" ${PROJECT_IS_TOP_LEVEL})
option(KEYVI_CLANG_TIDY "Keyvi: Build with clang tidy" OFF)
option(KEYVI_DOCS "Keyvi: Build docs" ${PROJECT_IS_TOP_LEVEL})


#### Linting
if(KEYVI_CLANG_TIDY)
find_program(CLANGTIDY clang-tidy)
Expand Down Expand Up @@ -275,6 +277,10 @@ target_include_directories(keyvi INTERFACE "$<BUILD_INTERFACE:${KEYVI_INCLUDES}>
target_compile_definitions(keyvi INTERFACE ${_KEYVI_COMPILE_DEFINITIONS_LIST})
target_link_libraries(keyvi INTERFACE ${Boost_LIBRARIES} ${ZLIB_LIBRARIES} ${Snappy_LIBRARY} ${ZSTD_LIBRARIES} ${_OS_LIBRARIES})

if (KEYVI_PYTHON_BINDINGS)
add_subdirectory(python-pybind)
endif ()

### docs

# don't run it as part of a non-toplevel build, e.g. python
Expand Down
96 changes: 96 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
[build-system]
requires = ["scikit-build-core>=0.10", "pybind11"]
build-backend = "scikit_build_core.build"

[project]
name = "keyvi2"
version = "0.7.4dev0"
dependencies = [
"msgpack>=1.0.0",
]

[dependency-groups]
lint = [
'ruff>=0.5.0',
]
test = [
'pytest>=8.3.5',
'pytest-env>=1.1.5',
'python-snappy>=0.7.3',
'zstd>=1.5.7.2'
]
dev = [
{ include-group = "test" },
{ include-group = "lint" },
"tox",
]


[tool.scikit-build]
wheel.expand-macos-universal-tags = true
minimum-version = "build-system.requires"

[tool.scikit-build.cmake.define]
KEYVI_PYTHON_BINDINGS = "ON"
KEYVI_C_BINDINGS = "OFF"
KEYVI_TESTS = "OFF"
KEYVI_BINARIES = "OFF"
KEYVI_CLANG_TIDY = "OFF"
KEYVI_DOCS = "OFF"

[tool.pytest.ini_options]
env = [
"KEYVI_SKIP_TEST_DEPRECATIONS = 1",
"KEYVI_MODULE_OVERWRITE=keyvi2"
]
minversion = "7.1.1"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
log_cli_level = "INFO"
filterwarnings = [
"error",
"ignore::pytest.PytestCacheWarning",
]
testpaths = ["python/tests"]

[tool.cibuildwheel]
build-frontend = "default"
test-groups = ["test"]
test-command = "pytest {project}/python-pybind/tests"
manylinux-x86_64-image = "keyvidev/manylinux-builder-x86_64"
musllinux-x86_64-image = "keyvidev/musllinux-builder-x86_64"
manylinux-aarch64-image = "keyvidev/manylinux-builder-aarch64"
musllinux-aarch64-image = "keyvidev/musllinux-builder-aarch64"

[tool.ruff.lint]
extend-select = [
"B", # flake8-bugbear
"I", # isort
"ARG", # flake8-unused-arguments
"C4", # flake8-comprehensions
"EM", # flake8-errmsg
"ICN", # flake8-import-conventions
"G", # flake8-logging-format
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"RET", # flake8-return
"RUF", # Ruff-specific
"SIM", # flake8-simplify
"T20", # flake8-print
"UP", # pyupgrade
"YTT", # flake8-2020
"EXE", # flake8-executable
"NPY", # NumPy specific rules
"PD", # pandas-vet
]
ignore = [
"PLR09", # Too many X
"PLR2004", # Magic comparison
]
isort.required-imports = ["from __future__ import annotations"]

[tool.ruff.lint.per-file-ignores]
"tests/**" = ["T20"]
26 changes: 26 additions & 0 deletions python-pybind/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.15...3.27)

# Scikit-build-core sets these values for you, or you can just hard-code the
# name and version.
project(
${SKBUILD_PROJECT_NAME}
VERSION ${SKBUILD_PROJECT_VERSION}
LANGUAGES CXX)

# Find the module development requirements (requires FindPython from 3.17 or
# scikit-build-core's built-in backport)
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
find_package(pybind11 CONFIG REQUIRED)

# Add a library using FindPython's tooling (pybind11 also provides a helper like
# this)
FILE(GLOB_RECURSE KEYVI_PYBIND_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/*.cpp)
pybind11_add_module(keyvi2 ${KEYVI_PYBIND_SOURCES})

target_link_libraries(keyvi2 PRIVATE keyvi)

# This is passing in the version as a define just as an example
target_compile_definitions(keyvi2 PRIVATE VERSION_INFO=${PROJECT_VERSION})

# The install directory is the output (wheel) directory
install(TARGETS keyvi2 DESTINATION .)
12 changes: 12 additions & 0 deletions python-pybind/src/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
BasedOnStyle: Google
ColumnLimit: '120'
Language: Cpp
Standard: c++17
TabWidth: '2'
UseTab: Never
ConstructorInitializerIndentWidth: 4
AllowShortFunctionsOnASingleLine: Inline
IncludeBlocks: Preserve

...
3 changes: 3 additions & 0 deletions python-pybind/src/CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
linelength=120
root=.
filter=-build/include_subdir,-whitespace/indent_namespace
Loading
Loading