Skip to content

[Feasibility] Add optional stub generation to bypass build-time linker issues on Android/Termux #35

Description

Description

When attempting to install python-soxr on Termux (Android), the build fails during the stub generation phase.

The nanobind stub generation in CMakeLists.txt attempts to immediately import the newly compiled shared library (soxr_ext.abi3.so) into the build-time Python interpreter. On Termux, this triggers a dynamic linker error:

ImportError: dlopen failed: cannot locate symbol "PyExc_ImportError" referenced by .../soxr_ext.abi3.so

This occurs because the linker cannot resolve Python C-API symbols when loading the module at build time in an isolated context on Android.

Suggested Solution

Similar to the approach used in shap/shap#5067, could you make the stub generation optional via a CMake flag (e.g., SOXR_NO_STUBGEN)?

This would allow users in restricted environments like Termux to build the library successfully by setting:
pip install . -v --no-build-isolation -Ccmake.define.SOXR_NO_STUBGEN=ON

This approach is both elegant and highly compatible with restricted build environments. Thank you for your consideration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions