On Posix targets, the file names for extensionsions are currently
foo.cpython-39-x86_64-linux-gnu.so
foo.abi3.so
for platforms which have PLATFORM_TRIPLET defined. This makes it clear which extension belongs to which interpreter, and at least on Debian and Ubuntu, it allowes cross-building of extensions by installing both the required build and host (or host and target) packages in the same environment.
Of course, the stable ABI is stable, so introducing another extension suffix to lookup has to be optional. Having such a lookup only as a local patch in a CPython build would make these extensions not loadable by other CPython builds.
Proposing to also look up an extension with the stable ABI as
foo.x86_64-linux-gnu.abi3.so
Not using foo.x86_64-linux-gnu-abi3.so (with a dash) to keep possible .endswith() matches working.
Adding this new lookup to _PyImport_DynLoadFiletab, before or after the original .abi3.so should be possible.
- Adding it after the original one has the advantage that lookups won't get penalized with one extra lookup for people not using it.
- Adding it before the original one has the advantage that the more specific one is looked up before the more general one. That behavior could also become the default on Debian builds using a local patch.
One more question would be how to document that change, or if the platform specific extension file name should be the preferred name for the future. Adding here just a minimal patch for discussion.
|