rust-python-example
rust-python-example copied to clipboard
Does not work on Windows OS
import os
import sys
from ctypes import *
lib = cdll.LoadLibrary(r'myrustlib.dll')
val='tesTTanotheRRtesTTtest'
lib.count_doubles(val)
errors out:
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'count_doubles' not found
just rename myrustlib.dll
to myrustlib.pyd
and import should work by name.
just rename
myrustlib.dll
tomyrustlib.pyd
and import should work by name.
Can you paste your code here? I also get the same error result. Thanks.
pyd files can be imported by name
>>> import myrustlib
>>> dir(myrustlib)
[...]
make sure myrustlib is on pythonpath, if not just put it next the the py file that imports it.
move myrustlib.pyd to the project's root in this case. the Makefile does this for the .so file on linux. On windows the the so equivalent is dll but it must be renamed to pyd.