(Thinks to self): this is something I've done several times by now, starting off with some MIDI stuff years ago. The description of both the statically- and dynamically-linked libraries is going into a common include file, and in principle the units that make use of it could be generated automatically.
I thought an update might possibly be of interest, or at least worth getting "into the record".
Using a fairly natural format, it's possible to put library definitions into an include file in such a way that they're useful both when a library is being "consumed" but also when it's being created (this is something I've been doing for years, but it tends to be hard work). Descriptive comments placed in this are picked up by the Lazarus IDE as hover-over declaration hints.
I now have a program which will parse this file, and generate unit files for both static and dynamic linkage (i.e. interfaces to libsomething.a and libsomething.so respectively). These still need a bit of fettling, e.g. to fill in local functions which replace C macros, but for a moderate-sized library this replaces thousands of lines of systematic edits.
Using this, I can now embed a simple Python v2 script using either static or dynamic linking. Extending this to v3 should not be particularly difficult.
MarkMLl