As a potential solution, or at least a temporary workaround, to make our CLI tools available in buildservice containers, we're tentatively exploring the use of PyInstaller (docs) to create standalone executables.
- Suggested by @dcaro as a way to package existing Python CLIs for injection into buildpack images
- PyInstaller bundles the Python runtime, potentially allowing for cross-platform compatibility
- Initial tests show some challenges with glibc version mismatches between build and target environments:
slavina@pyre:~$ pyenv global 3.12 slavina@pyre:~$ python --version slavina@pyre:~$ ./test [3238867] Failed to load Python shared library '/tmp/_MEIFXJYLl/libpython3.12.so.1.0': dlopen: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.38' not found (required by /tmp/_MEIFXJYLl/libpython3.12.so.1.0) slavina@pyre:~$ ldd --version ldd (Debian GLIBC 2.36-9+deb12u7) 2.36
The binary was built with glibc 2.39 on fedora, and the test was on debian bookworm. The Python version (or Python being installed at all) on the system executing the binary shouldn't matter as that is the whole point of pyinstaller – it bundles a python interpreter with all the libs.
Next steps
- Investigate building the binary in a container matching our buildpack base image (Ubuntu 22.04 LTS)
- Attempt to package one of our existing CLI tools
Considerations
- Requires rebuilding images when CLI tools are updated
- The webservice CLI might need additional testing
- Long-term, we may want to continue efforts on OpenAPI CLI generation for a more stable solution