Python + setuptools: distributing a precompiled shared library with boost.python bindings

I have a C ++ library (we will call it an example in the following) for which I wrote Python bindings using the boost.python library. This library wrapped by Python will be called pyExample. The entire project is built using CMake, and the resulting Python library is a file with a name libpyExample.so.

When I use Python bindings from a Python script located in the same directory as libpyExample.soI just need to write:

import libpyExample
libpyExample.hello_world()

and it performs the function hello_world()opened by the packaging process.

What i want to do

For convenience, I would like my pyExample library to be accessible from anywhere just by using the command

import pyExample

, pyExample virtualenv . , setuptools, . :

  • libpyExample.so Python script
  • ,

++ setuptools, ++. , , ?

pyExample setuptools, . CMake , libpyExample.so.

+4
1

, :

  • CMake ++ Python.
  • setuptools

python setup.py install --user, lib site-packages .

, , , , setuptools , CMake. , , pybind11:

https://github.com/pybind/cmake_example

setup.py, , build_ext Extension CMake.

- -D. , !

+1

Source: https://habr.com/ru/post/1615286/


All Articles