0

When building a wheel of a Python extension module, how can I tell setup() to use an existing/precompiled shared library?

For awful horrible reasons, the SO/DLL has to be compiled by a build system that cannot be invoked by Python. (FWIW it's compiled with the stable limited ABI.) But I need my setup.py to bundle the library correctly.

Is there an option for this? Is it possible to subclass Extension somehow and just return the existing library when asked to build it?

alexchandel
  • 532
  • 6
  • 15

1 Answers1

1

You can create a MANIFEST.in (https://packaging.python.org/en/latest/guides/using-manifest-in/) and include the files when creating a wheel this way.

So if you got all the shared libs somewhere in the source tree you can do

global-include *.so

Nopileos
  • 1,976
  • 7
  • 17
  • This inspired me to use a `Command` subclass to do the copy. I had to subclass `build` to trigger the copy command when appropriate, and subclass `Distribution` to force `bdist_wheel` to build an impure/binary (as in not `none`-type) wheel. So thank you, have an upvote. – alexchandel Aug 04 '23 at 01:00