Repository navigation
Python bindings using scikit build core #316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hendrikmuhs
wants to merge
111
commits into
KeyviDev:master
Choose a base branch
from
hendrikmuhs:scikit-buildcore
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,797
−28
Open
Changes from all commits
Commits
Show all changes
111 commits
Select commit
Hold shift + click to select a range
4d01617
add pybind11 bindings
hendrikmuhs 7fba918
build from root
hendrikmuhs dd71bc1
fix test errors
hendrikmuhs caf0b8d
lower pytest minversion
hendrikmuhs a98fa3a
remove pyodide
hendrikmuhs f954b5a
fix deprecation error
hendrikmuhs ad79339
switch to default build-frontend
hendrikmuhs 80e0c35
fix sdist
hendrikmuhs 17de53c
update cibuildwheel
hendrikmuhs 9af17eb
repair sdist and tests
hendrikmuhs 66fcf9d
install ninja-build
hendrikmuhs 820000f
install build module
hendrikmuhs b9c1248
fix folder
hendrikmuhs 2738036
use pipx
hendrikmuhs 090aa89
remove env overrides
hendrikmuhs 5db710d
re-add project dir
hendrikmuhs 8da0bf1
add method
hendrikmuhs dc49e50
move todo
hendrikmuhs 21fe7e5
add compiler
hendrikmuhs b5e86b1
checkstyle
hendrikmuhs ab73173
add more compilers and mergers
hendrikmuhs 031b60b
fix msgpack unpacking
hendrikmuhs f9cd3dd
add missing file
hendrikmuhs ee397dd
update workflow with changes from latest master
hendrikmuhs a0ce94f
fix deprecation errors
hendrikmuhs ce5dc7c
rename to keyvi2
hendrikmuhs e52481b
implement dumps and loads
hendrikmuhs afce66a
switch to std::variant
hendrikmuhs c8b6ccd
fix attribute access
hendrikmuhs 3956b86
WIP
hendrikmuhs 6aeeef9
Merge branch 'master' of github.com:KeyviDev/keyvi into scikit-buildcore
hendrikmuhs f980eb2
Merge branch 'master' of github.com:KeyviDev/keyvi into scikit-buildcore
hendrikmuhs 562cd78
update workflow
hendrikmuhs 9cc8f3d
Merge branch 'master' into scikit-buildcore
hendrikmuhs f552c4f
style fixes
hendrikmuhs fe64e1c
free-threading
hendrikmuhs f4833ec
Merge branch 'master' of github.com:KeyviDev/keyvi into scikit-buildcore
hendrikmuhs d30a1fd
update workflow
hendrikmuhs dcb80f9
update pyproject.toml
hendrikmuhs 311170d
move logic to pyproject.toml
hendrikmuhs 3995a55
fix versions
hendrikmuhs c2cea87
add msgpacked_value_as_string: WIP
hendrikmuhs 4b9534b
Merge branch 'master' of github.com:KeyviDev/keyvi into scikit-buildcore
hendrikmuhs a02899c
add msgpacked_value_as_string
hendrikmuhs 8e2e10a
Merge branch 'master' of github.com:KeyviDev/keyvi into scikit-buildcore
hendrikmuhs 675b412
bump version
hendrikmuhs 5c38738
fix add for key only compiler
hendrikmuhs e0773f1
Merge branch 'master' of github.com:KeyviDev/keyvi into scikit-buildcore
hendrikmuhs ed41395
update workflow
hendrikmuhs a66a9e9
format
hendrikmuhs dd1af35
test NOLINT block
hendrikmuhs 8018d03
try to make clang-tidy happy
hendrikmuhs 18c5a38
exclude python-pybind for clang-tidy
hendrikmuhs 5b818a0
Revert "test NOLINT block"
hendrikmuhs 43d866b
disable free threading
hendrikmuhs 16930be
implement keyvi module overwrite in test
hendrikmuhs ff7584c
add completion stub
hendrikmuhs 7cfa644
fix import
hendrikmuhs 0f69ecf
Merge branch 'master' of github.com:KeyviDev/keyvi into scikit-buildcore
hendrikmuhs 076c1aa
add placeholders for missing submodules
hendrikmuhs d986c40
disable 2 tests
hendrikmuhs df6de22
add pytest-env
hendrikmuhs 24fccdb
downgrade pytest-env
hendrikmuhs a8e49a5
add missing files
hendrikmuhs 4444d29
remove separate test files
hendrikmuhs 199e6d2
ruff fixes
hendrikmuhs 45dbae1
pre-commit
hendrikmuhs 700cf8d
pre-commit again
hendrikmuhs 5ba857f
set config-file
hendrikmuhs c26d41c
Merge branch 'master' of github.com:KeyviDev/keyvi into scikit-buildcore
hendrikmuhs 16ae56f
apply workflow updates
hendrikmuhs eba13d7
fix test directory
hendrikmuhs cc8eea9
make completions const
hendrikmuhs 8b72d5b
move match iterator
hendrikmuhs 5fb9e08
Revert "make completions const"
hendrikmuhs 6f03185
Merge branch 'master' of github.com:KeyviDev/keyvi into scikit-buildcore
hendrikmuhs 6ad78f4
update version
hendrikmuhs e0f325b
try to fix CI for old python module
hendrikmuhs 00d6d4c
use test-environment
hendrikmuhs 81fed62
make Dictionary python object a shared pointer, so it can be passed
hendrikmuhs aeea005
add more completion bindings
hendrikmuhs 11534db
install python-snappy zstd when testing sdist package
hendrikmuhs c27e636
add missing methods to Dictionary object
hendrikmuhs d7b843c
NOLINT GetFuzzyCompletions
hendrikmuhs 49b3bc7
fix items
hendrikmuhs a07b3bd
add const
hendrikmuhs 2c1a120
Merge branch 'master' of github.com:KeyviDev/keyvi into scikit-buildcore
hendrikmuhs 17374fd
Merge branch 'master' of github.com:KeyviDev/keyvi into scikit-buildcore
hendrikmuhs 494a9a9
Merge branch 'master' into scikit-buildcore
hendrikmuhs 0a36860
add bindings for keys and values
hendrikmuhs bf95f34
add bindings for SecondaryKeyDictionary
hendrikmuhs 5e479eb
add bindings for Index
hendrikmuhs a1d5eec
add vector bindings
hendrikmuhs 241217f
add util binding
hendrikmuhs 79013d1
fix compile error
hendrikmuhs 28046d4
NOLINT
hendrikmuhs 8ec0550
add keyvimerger script
hendrikmuhs 0237a25
fix test / binding differences
hendrikmuhs 5bb6e1d
update flow
hendrikmuhs d91cdee
ignore runtime warning due to missing zstd GIL declaration
hendrikmuhs dd79614
release GIL where possible
hendrikmuhs b582944
re-enable merger binary test
hendrikmuhs d540940
reenable tests
hendrikmuhs 22f38a6
fix test
hendrikmuhs 4484a35
add KeyOnlyDictionaryGenerator binding
hendrikmuhs 8615383
add missing methods
hendrikmuhs b807502
port doc strings
hendrikmuhs 42e7574
make pybind module a beta version
hendrikmuhs 5f2b740
update workflow
hendrikmuhs 092a700
Merge remote-tracking branch 'upstream/master' into scikit-buildcore
hendrikmuhs 225845c
drop mac intel and bump mac version
hendrikmuhs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| 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: Arm64 | ||
| os: [ubuntu-22.04, ubuntu-24.04-arm, macos-15] | ||
| # 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 | ||
| target: musl | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| - name: ccache | ||
| uses: hendrikmuhs/ccache-action@v1.2.24 | ||
| 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 arm64 | ||
| if: runner.os == 'macOS' && runner.arch == 'ARM64' | ||
| run: | | ||
| echo "MACOSX_DEPLOYMENT_TARGET=15.0" >> $GITHUB_ENV | ||
|
|
||
| - name: Build python wheels for ${{ matrix.os }} | ||
| uses: pypa/cibuildwheel@v4.2.1 | ||
| env: | ||
| # Skip CPython 3.15 | ||
| CIBW_SKIP: ${{ env.CIBW_SKIP }} cp315* | ||
|
|
||
| # 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@v7 | ||
| with: | ||
| name: artifact-${{ matrix.os }}-${{ matrix.flavor }}-${{ matrix.target }} | ||
| path: ./wheelhouse/*.whl | ||
|
|
||
| build_sdist: | ||
| name: sdist | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| - 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/ccache-action@v1.2.24 | ||
| 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 python-snappy zstd && \ | ||
| KEYVI_SKIP_TEST_DEPRECATIONS=1 python -m pytest python/tests && \ | ||
| python -m pip uninstall -y keyvi | ||
|
|
||
| - uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: artifact-sdist | ||
| path: dist/*.tar.gz | ||
|
|
||
| upload_all: | ||
| needs: [build_wheels, build_sdist] | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'release' | ||
| environment: | ||
| name: pypi | ||
| url: https://pypi.org/p/keyvi | ||
| permissions: | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/download-artifact@v8 | ||
| with: | ||
| pattern: artifact-* | ||
| merge-multiple: true | ||
| path: dist | ||
|
|
||
| - uses: pypa/gh-action-pypi-publish@release/v1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 = "keyvi" | ||
| # 0.9.6 corresponds to 0.7.6 (Cython), using 0.9.x for the pybind11 beta series | ||
| version = "0.9.6b1" | ||
| 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] | ||
| minversion = "7.1.1" | ||
| addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"] | ||
| xfail_strict = true | ||
| log_cli_level = "INFO" | ||
| filterwarnings = [ | ||
| "error", | ||
| "ignore::pytest.PytestCacheWarning", | ||
| # zstd C extension lacks Py_mod_gil declaration, triggers RuntimeWarning on Python 3.14t free-threaded builds | ||
| "ignore:The global interpreter lock.*:RuntimeWarning", | ||
| ] | ||
| testpaths = ["python/tests"] | ||
|
|
||
| [tool.cibuildwheel] | ||
| build-frontend = "default" | ||
| test-groups = ["test"] | ||
| test-command = "pytest {project}/python/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" | ||
| test-environment = { KEYVI_SKIP_TEST_DEPRECATIONS="1"} | ||
|
|
||
| [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"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| 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) | ||
|
|
||
| # Use _keyvi_pybind as internal target name to avoid conflict with the keyvi C++ library target | ||
| FILE(GLOB_RECURSE KEYVI_PYBIND_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/*.cpp) | ||
| pybind11_add_module(_keyvi_pybind ${KEYVI_PYBIND_SOURCES}) | ||
|
|
||
| set_target_properties(_keyvi_pybind PROPERTIES OUTPUT_NAME keyvi) | ||
| target_include_directories(_keyvi_pybind PRIVATE src) | ||
| target_link_libraries(_keyvi_pybind PRIVATE keyvi) | ||
|
|
||
| # This is passing in the version as a define just as an example | ||
| target_compile_definitions(_keyvi_pybind PRIVATE VERSION_INFO=${PROJECT_VERSION}) | ||
|
|
||
| # The install directory is the output (wheel) directory | ||
| install(TARGETS _keyvi_pybind DESTINATION .) | ||
| install(FILES keyvimerger.py DESTINATION .) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.