r/Python • u/Emergency-Rough-6372 • Apr 12 '26
Discussion Packaging a Python library with a small C dependency —
how do you handle install reliability?
Hey folks,
I’ve run into a bit of a packaging dilemma and wanted to get some opinions from people who’ve dealt with similar situations.
I’m working on a Python library that includes a vendored C component. Nothing huge, but it does need to be compiled into a shared object (.so / .pyd) during installation. Now I’m trying to figure out the cleanest way to ship this without making installation painful for users.
Here’s where I’m stuck:
- If I rely on local compilation during
pip install, users without a proper C toolchain are going to hit installation failures. - The alternative is building and shipping wheels for multiple platforms (Linux x86_64/arm64, macOS x86_64/arm64, Windows), which is doable but adds CI/CD complexity.
- I also need to choose between something like
cffivsctypesfor the wrapper layer, and that decision affects how much build machinery I need.
There is a fallback option I’ve considered:
- Detect at import time whether the compiled extension loaded successfully.
- If not, fall back to a pure Python implementation.
But the issue is that the C component doesn’t really have a true Python equivalent — the fallback would be a weaker, approximation-based approach (probably regex-based), which feels like a compromise in correctness/security.
So I’m trying to balance:
- Ease of installation (no failures)
- Cross-platform support
- Performance/accuracy (native C vs fallback)
- Maintenance overhead (CI pipelines, wheel builds, etc.)
Questions:
- In 2026, is it basically expected to ship prebuilt wheels for all major platforms if you include any C code?
- Would you accept a degraded Python fallback, or just fail hard if the extension doesn’t compile?
- Any strong opinions on
cffivsctypesfor this kind of use case? - How much effort is “normal” to invest in multi-platform wheel builds for a small but critical C dependency
Would love to hear how others approach this tradeoff in real-world libraries.
Thanks!