vikingshore
vikingshore

Reputation: 175

how to "install" custom python module made by boost.python

I have made a .so module with boost.python and can import it from local folder.

|--my_class.so
|--python_code.py

in python_code.py

from my_class import *

Obviously if I put python_code.py in a different folder, from my_class import * would fail.

I am wondering if there is a way that I can "install" my_class.so in a gobal package location that I can import it from any python script. So my_class has the same status as packages like numpy .

Upvotes: 4

Views: 548

Answers (1)

joeButler
joeButler

Reputation: 1711

You should be able to move the .so file somewhere on your python library path. On my machine one example is the directory /usr/lib/python2.7

One way you might consider doing this is with a setup.py file, which can be configured to handle your build and install.

In the past I've sometimes just copied it there by hand for testing or put a something such as below into a Makefile so it copies after compile:

#
#   Install the python module
#
install: /usr/local/lib/python2.7/dist-packages/MyModule.so

/usr/local/lib/python2.7/dist-packages/MyModule.so: python-module
    cp $(BIN)MyModule.so /usr/local/lib/python2.7/dist-packages/MyModule.so

Upvotes: 1

Related Questions