Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

cmake - Python packaging: handle dependency from non-Python libraries

A Python package I'm currently working on has the following dependencies:

  • a C++ library (which is included in the source files of the package)
  • Google's protobuf & protoc
  • cmake

The package can be found at https://github.com/bayesmix-dev/pybmix

The protobuf library is needed both for the C++ library (internal data exchange) and for the Python/C++ interface (C++ passes to python serialized protobuf objects and Python de-serializes them).

Basically, in the setup.py the following operations are performed:

  • cmake is invoked to compile a pybind11 python package, that is a wrapper of the C++ library. The pybind11 package links to protobuf. Also, cmake compiles a bunch of .proto files into the corresponding .pb.h and .pb.cc
  • protoc is invoked to compile the same .proto files into the corresponding python classes (further 2to3 is used to handle relative imports of the generated files)

Now, my question is: what is the best way to handle these dependencies in a user-friendly way? My plan is to distribute this package through PyPi, and ideally one should just type

pip install pybmix

and the setup script would either deal with the dependencies itself or point to the missing libraries.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...