Closed JohnAD closed 2 years ago
Interesting issue. Thanks very much for trying genny and for reporting this issue along with great information so we can reproduce it. Will reply back here with an update soon.
Ok this took a bit longer than I expected to get back to but I do have an update. I am not able to reproduce the issue, but I do know we haven't really documented well how to set things up so there could be many issues along the way. Some things:
nim c -f -d:release --app:lib --gc:arc --tlsEmulation:off --out:txtdb bindings.nim
or something like this should be the compile command.
From here, the generated python file does need a tweak to work without the pip set up (which is too much for a simple test). An modified output python file would be:
from ctypes import *
import os, sys
dir = os.path.dirname(os.path.abspath(__file__))
if sys.platform == "win32":
libName = "txtdb.dll"
elif sys.platform == "darwin":
libName = "libtxtdb.dylib"
else:
libName = "libtxtdb.so"
dll = cdll.LoadLibrary(os.path.join(dir, libName))
class txtdbError(Exception):
pass
def joe():
result = dll.txtdb_joe().decode("utf8")
return result
dll.txtdb_joe.argtypes = []
dll.txtdb_joe.restype = c_char_p
test = joe()
print(test)
Notice that I added the print at the bottom, call joe()
instead of the dll proc, and changed the dir =
at the top to work with file paths. It expects the dll / so to be in the same directory as the python file, and the same directory you are running the python script.
For me, then python txtdb.py
prints hello
as expected.
I hope this helps and thanks for giving genny a try. As you've noticed, it is pretty cool but also quite new and rough. We'll work through it though as we put more time in on genny.
Closing this just for housekeeping. Please re-open if there is an update.
I've been impressed by this library. It seems to greatly simplify the interface between nim and python.
Unfortunately, I've been having problems with
def
procs that return strings.So, to provide a simplified example, a
bindings.nim
:Examining the internal file:
And yet, if I call it from python:
I get:
Details:
Running on Pop_OS!, an ubuntu variant. So, using
libtxtdb.so
. Nim is version1.4.8
. Python isgenny version is
genny [0.1.0]
Thanks for any help you can provide!