lucasb-eyer / libheatmap

High performance C heatmap generation library. Supposed to be wrapped by higher-level languages.
MIT License
302 stars 60 forks source link

Python windows #7

Open antoinedewailly opened 7 years ago

antoinedewailly commented 7 years ago

I use your project heatmap with python and linux thanks to the .so library but now I would like to do the same with python and windows. How I could have a .dll ?

lucasb-eyer commented 7 years ago

Sorry Antoine, I wanted to get to it this week-end, but unfortunately didn't. I'll get back to it ASAP though.

What needs to be done (for VisualC++) is essentially sprinkle the header and code with optional __declspec(dllimport) and/or __declspec(dllexport), like I've done here. I will do that in the provided msvc project files, and additionally, I'll include a pre-compiled .dll in the repo for convenience.

lucasb-eyer commented 7 years ago

Hi again, Antoine. I have successfully created a 64-bit DLL and got it to work within (64-bit) Python on Windows. I've pushed the code-changes, VS-2017 project files and a pre-compiled DLL to the win-dll branch.

Note that it will not work with the code from the README as-is, because apparently things are more finnicky on windows. In Python, you need to declare the function return types and parameter types as described in the ctypes doc here, otherwise it will crash.

I plan to update that in the README file too before I merge to master, but since it may take me a little time (with Christmas and all), I pushed the preliminary changes to that branch so you could use them right away.

In the long term, it's probably better to create a wrapper in Cython as a separate project though, I just won't get to that myself anytime soon.