Python C extension with executable dependency

502 views Asked by At

I have this C SDK that I'm working on creating a Python extension for. The C SDK documentation says that it expects a ffmpeg executable in it's working directory. My current project structure is:

my-extension/
    include/
        sdk-file.h
        sdk-file-2.h
    lib/
        sdk-lib.so
        sdk-lib2.so
    src/
        my-extension.c
    setup.py

My setup.py:

from setuptools import setup
from setuptools.extension import Extension

setup(
    name='my_extension',
    version='develop',
    ext_modules=[Extension(
        'my_extension',
        ['src/my-extension.c'],
        include_dirs=['include'],
        library_dirs=['lib'],
        libraries=['sdk-lib', 'sdk-lib2',],
        runtime_library_dirs=['lib'],
    )]
)

My question is, how do I package a executable dependency (ffmpeg in this case) with my extension? The executable file was provided with the SDK.

1

There are 1 answers

0
phd On

I think package_data can be used for this:

setup(
    …
    package_data={'': ['ffmpeg']},
    …
)

package_data is a dict. Keys are submodule names; an empty string means the root of the package. Values are lists that list file patterns for named submodules. See the docs.