I’ve written Python bindings using ctypes for the units library. The bindings themselves are only ~100 lines of Python. The library has an unnecessary (for the purposes of the Python bindings) dependency on tcl, and the configure script fails if tcl is absent. However, the library builds fine with gcc -Wl,-soname,units.so -o units.so -fPIC -shared units.c.
I would now like to release these bindings. There are three ways I could do this.
- Release the bindings on their own, with a basic setup.py and provide build, download and install instructions for the C library in the documentation.
- Release the bindings, along with the original library source and provide a setup.py that handles the compilation and installation of the C library. This is obviously more work for me.
- Just release the .py file, and let the users worry about installation and dependencies.
If I choose option 2, where should I put the library? Should I put it in the same directory as the .py file, allowing me to assume lib_name = CDLL('./units.extension'), or should I put it in a directory that tends to be in the linker’s path (like /lib)? In addition, how is this normally handled for Windows machines which a) might not have a C compiler and b) have no standard place to put shared libraries?
Which of these options is the preferred one and what should I do about the Windows case?
It appears that the
unitslibrary hasn’t been modified in over 5 years, so option 2 may be the best one. It’s also unlikely that one of the major distributions will package it (I can’t find it in Ubuntu Lucid or Macports for example).For example, copy units.c and units.h into your project and create a setup.py to compile and deploy it along with your bindings: