zwol
zwol

Reputation: 140786

C helper program for Python package

I am writing a Python package that, in normal operation, needs to run a helper program that's written in C. The helper program ships as part of the package, and it doesn't make sense to try to run it independently.

  1. How do I persuade Distutils to compile, and install to an appropriate location, an independent C program rather than a C extension module?

  2. How should the Python part of the code locate and start the helper program?

N.B. Porting the actual code (especially the C helper) to Windows would necessitate a >90% rewrite, so I only care about making installation work on Unix.

Upvotes: 1

Views: 74

Answers (1)

NG.
NG.

Reputation: 22914

This is pretty interesting. I've never done this, but I think you can use the distutils compiler directly.

I checked out github for some possible examples that might give you inspiration. Check out this one

The filter I used was distutils ccompiler language:python filename:setup.py in case you want to extend it/trim it down

Upvotes: 1

Related Questions