ejdb icon indicating copy to clipboard operation
ejdb copied to clipboard

EJDB2 Python Bindings

Open techdragon opened this issue 6 years ago • 6 comments

I tried to write my own python bindings ( It's the first time I've needed/wanted to write bindings from scratch :smile: ) using the precompiled ejdb2 and the headers after compiling the project from source, but I haven't been able to get this all working using cython or cffi. I also started to try and add a new binding into the project and its build tools incase that was easier, but my C IDE (JetBrains CLion) doesn't like the current project layout... something about the include paths for static compilation #include <ejdb2/iowow/iwkv.h> rubs it the wrong way...

So for now, I'm just going to put my polite request for python bindings into the issue tracker in the hopes someone else has the time to work it out, or knows how and has the time to do it.

techdragon avatar Aug 28 '19 05:08 techdragon

Thank you for the request Samuel! We are on the way of implementation Rust and Python bindings hope will release it September. I will check sample project in CLion and will back shortly.

adamansky avatar Aug 29 '19 05:08 adamansky

Great to hear Python and Rust bindings are on the way!

On the topic of CLion, it seems to be confused by some of the header paths, like the the use of #include <ejdb2/iowow/iwkv.h> as part of linking iowow statically. If theres any advice you have about getting the repo/project to open and build with CLion, I'm happy to give it a shot.

techdragon avatar Aug 30 '19 05:08 techdragon

  • CLion builds project without problems - just open the project, then run Build -> Build Project
  • After first build run Reload CMake Project and you will be able to navigate to #include <ejdb2/iowow/iwkv.h> it located in build/include directory

adamansky avatar Sep 03 '19 13:09 adamansky

here is the python binding I created:

https://github.com/shi-yan/ejdb2rs/tree/master/python

it works on my local machine, but I ran into issues when trying to publish it to the public package repository.

they have very strict restriction regarding what libraries you could link. to support very old linux distributions, they could only link very old glibc.

the problem is, ejdb doesn't build with old glibc:

some issues I saw:

src/extern_iowow/src/platform/unix/unix.c:103:34: error: ‘struct stat’ has no member named ‘st_atim’; did you mean ‘st_atime’?
  103 |   fs->atime = _IW_TIMESPEC2MS(st.st_atim);

src/extern_iowow/src/log/iwlog.h:141:14: error: unknown type name ‘locale_t’
  141 |   FILE *out, locale_t locale, iwlog_lvl lvl, iwrc ecode,

the suggested way of building python package is using a docker container:

https://github.com/PyO3/maturin#manylinux-and-auditwheel

which has only glibc 2.17

ldd --version ldd
ldd (GNU libc) 2.17
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

to move forward, need to make sure ejdb can build under this docker container:

quay.io/pypa/manylinux2014_x86_64

https://stackoverflow.com/questions/59451069/binary-wheel-cant-be-uploaded-on-pypi-using-twine

shi-yan avatar Oct 14 '21 03:10 shi-yan

@shi-yan https://github.com/pypa/cibuildwheel is a convenient way to build those wheels (with github actions for example). It will use the appropriate Docker containers automatically under Linux.

Dobatymo avatar Oct 14 '21 09:10 Dobatymo

Thank you for the link, however the issue isn't how to build wheels, the issue is on the ejdb side.

shi-yan avatar Oct 14 '21 20:10 shi-yan