Vardan Gupta
Vardan Gupta

Reputation: 3585

How to make Python module shareable?

We have a python based module which we want to distribute to our customers by creating a compiled copy understandable by linux system(i.e. .so file)

We have evaluated cython which does this quite easily, but we're seeing it's creating as many .so file as .pyx/.py file but we want to make one uber .so file for complete package. We want to do it smartly in a sense that if we add dependency to other module in future, uber compiled file should have all the dependencies.

Any recommendations, how we can do it neatly?

Upvotes: 4

Views: 288

Answers (1)

danny
danny

Reputation: 5270

cx_freeze can create re-distributable packages of python modules.

For example:

cxfreeze my_script_using_my_python_module.py --target-dir dist

Whether the python package is compiled or regular python is not really relevant. What is relevant is that your customers will need to have compatible python version, as well as compatible libc/gcc, to run it.

So for the purposes of distributing a python module to third parties, a single .so will not be compatible with everyone. Ever.

cx_freeze bundles the required python interpreter version and python packages so there are no dependencies. It is also cross-platform.

Upvotes: 2

Related Questions