0

I have a freenect.pyd file compiled from c programs however when I import the function and call dir(freenect) its output is just ['__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__'] there are no functions in there to call. I have checked on a dependency walker and the functions I was expecting to be there are in the module imports and the only export is PyInit_freenect which I think is what is to be expected. So to sum up I am just confused on why the functions I want to call are in there on the dependency walker but I cannot access them.

My directory structure is as follows

site-packages
|-freenect
  |-freenect.pyd
  |-libfreenect.dll
  |-libfreenect_sync.dll

I have the .dll files in there as they are dependencies that showed in the dependency walker. So is it that it is an issue with the .pyd file is corrupted or something or is there an extra initialisation step that I missed.

Cython generated a file called freenect3.c which was then compiled into freenect.dll and then I just renamed the extension to .dll (which I think you can do it seems to me that .dll and .pyd are pretty much the same).

I will provide a screenshot of my dependency walker if that helps at all. Dependency walker

Again any help would be greatly appreciated.

hugo
  • 31
  • 4
  • Only `def` or `cpdef` functions are visible from Python (`cdef` functions are only accessible from within Cython code, and aren't introspectable with `dir()`). Have you written anything that *should* be visible from Python? – DavidW Aug 14 '23 at 15:38
  • im not too sure as this code was generated through cmake. Sorry if I cant really give a clear answer I'm not well versed on this subject. But they are called def in the .pyx file that freenect3.c has generated from so I believe that there should be visible functions. Also in the documentation of freenect it says you can just put the pyd file and the dlls in the same directory in site packages and you can just call them like `freenect.sync_get_depth` so I am not sure where mine has gone wrong – hugo Aug 14 '23 at 15:53
  • That all seems odd - you wouldn't normally have to rename a .dll for example, and renaming `freenect3` -> `freenect` sounds dodgy since Python relies on the module name in the import mechanism. The build mechanism should just create a pyd file with the right name. Unfortunately I don't anything about how freenect specifically is supposed to be installed. – DavidW Aug 14 '23 at 16:04
  • How do you import it `import freenect`? Try `from freenect import freenect` (with original location). – CristiFati Aug 21 '23 at 19:13

1 Answers1

0

Move .pyd and dependent DLLs from python/Lib/site-packages into python/DLLs. I guess it is to do with the way python reads modules or something.

hugo
  • 31
  • 4