Oct-31-2023, 03:06 AM
I have a python application which I package with "python -m build", then install with "pip install mystuff.tar.gz", and that works well. In the past I've added C code that links in at runtime to extend Python, that works fine too.
But now I need to use a C++ library that doesn't play well as part of a Python application, so I'd like to write a C++ program that gets executed with Popen() at runtime, then communicates with the main Python application via stdin/stdout. I can build and run this, but I can't figure out how to bundle it with the pip package so that it gets compiled into an executable at "pip install" time. I can find lots of examples of putting ext_modules into setup.py to create linkable extensions, but is there some way to make an executable out of this? Worst case, the Python application can execute something like f"gpp {__file__}/app.o -o {tempfile.mktemp()}", then execute the tempfile...but there's got to be a better way. Right?
Thanks for any help that people can give.
But now I need to use a C++ library that doesn't play well as part of a Python application, so I'd like to write a C++ program that gets executed with Popen() at runtime, then communicates with the main Python application via stdin/stdout. I can build and run this, but I can't figure out how to bundle it with the pip package so that it gets compiled into an executable at "pip install" time. I can find lots of examples of putting ext_modules into setup.py to create linkable extensions, but is there some way to make an executable out of this? Worst case, the Python application can execute something like f"gpp {__file__}/app.o -o {tempfile.mktemp()}", then execute the tempfile...but there's got to be a better way. Right?
Thanks for any help that people can give.