Python3_add_library should get defined even if libpython not present

Python3_add_library doesn’t get defined unless the “Development” component is requested in find_package, but “Development” will fail to be defined if libpython*.so is not present. For example, the manylinux project docker images don’t have the libpython shared objects or python development packages.

However, it is completely possible to create valid python extensions without libpython*.so. I can set Python3_LIBRARY to something invalid and it will build perfectly fine. I can look at all the resulting makefiles from a successful build and there’s no usage of libpython*.so. Is there a way I can force Python3_add_library to be defined without searching for the “development” component?

Cc: @marc.chevrier

You can use COMPONENT Development.Module rather than Development.
On platforms other than Windows, the library is not required fir this component.

But anyway, I think your docker image is broken if you have python headers files but not the library…

1 Like

It’s not my docker image, it’s the pypa team’s own manylinux image

To complete my answer, Python3_add_library must be used with type MODULE to use target Python3::Module.

thanks @marc.chevrier !