5

I am working on a python package that relies heavily on a Julia library. Rather than use PyCall, we actually compile the Julia code down into shared objects .so files using PackageCompiler.jl. It is referenced using ctypes in the python module. It also requires a Julia systemimage.

Does anyone have any ideas on how to package this? I know that you can build C/C++ inside of distutils, but I haven't really found a good venue for including Julia across multiple platforms.

To be clear here, for someone to use this Python package they need a Julia installation and they need the appropriate shared object libraries for their system. Those can be gotten by running the Julia compiler juliac.jl. Everything else is in Python.

phd
  • 82,685
  • 13
  • 120
  • 165
jay
  • 493
  • 1
  • 3
  • 11
  • Possible duplicate of [How to include a shared C library in a Python package](https://stackoverflow.com/questions/45121352/how-to-include-a-shared-c-library-in-a-python-package) – phd Oct 18 '19 at 08:36
  • https://stackoverflow.com/search?q=%5Bsetuptools%5D+distribute+shared+library – phd Oct 18 '19 at 08:36

1 Answers1

0

Assuming you are using setup.py to build your library, you need to add the shared library(s) to package_data when calling setup():

setup.py

# call out to build system to build the shared library

setup(
  name="my-extension",
  ext_modules="..."
  package_data="/path/to/mylib.so"
)

See further documentation here: https://docs.python.org/3/distutils/setupscript.html#installing-package-data

After running python setup.py bdist_wheel to create a .whl file, you may also want to run auditwheel, which will compatibility tag (e.g. manylinux1) and isolate (rename with hash, fix-up linkages) the shared libraries.

Isaiah Norton
  • 4,205
  • 1
  • 24
  • 38