当前位置: 动力学知识库 > 问答 > 编程问答 >

ctypes - How do I package for distribution a python module that uses a shared library?

问题描述:

I'm writing some bindings for a C library and am not sure how to configure all this for distribution so it is possible to pip install my package.

Let's say I have the following files:

  • library.c
  • library.h
  • wrapper.py

In order for my wrapper library to work it is necessary to:

  • compile library.c and create a shared library
  • run ctypesgen on library.h to generate the ctypes code

Here are the commands:

  • gcc -Wall -fPIC -c library.c
  • gcc -shared -Wl,-soname,liblibrary.so.1 -o liblibrary.so.1.0 library.o
  • ctypesgen.py library.h -L ./ -l library -o _library.py

Running setup.py will also depend on the user having installed ctypesgen.

I have no idea how to get this all set up so that someone interested in the library can simply pip install library and have all this happen automagically. Anyone able to help?

分享给朋友:
您可能感兴趣的文章:
随机阅读: