pub fn find_all_sysconfigdata(cross: &CrossCompileConfig) -> Vec<PathBuf>
Expand description

Finds _sysconfigdata*.py files for detected Python interpreters.

From the python source for _sysconfigdata*.py is always going to be located at build/lib.{PLATFORM}-{PY_MINOR_VERSION} when built from source. The exact line is defined as:

pybuilddir = 'build/lib.%s-%s' % (get_platform(), sys.version_info[:2])

Where get_platform returns a kebab-case formatted string containing the os, the architecture and possibly the os’ kernel version (not the case on linux). However, when installed using a package manager, the _sysconfigdata*.py file is installed in the ${PREFIX}/lib/python3.Y/ directory. The _sysconfigdata*.py is generally in a sub-directory of the location of libpython3.Y.so. So we must find the file in the following possible locations:

${INSTALL_PREFIX}/lib/python3.Y/_sysconfigdata*.py
${INSTALL_PREFIX}/lib/libpython3.Y.so
${INSTALL_PREFIX}/lib/python3.Y/config-3.Y-${HOST_TRIPLE}/libpython3.Y.so

${CROSS_COMPILED_LOCATION}/build/lib.linux-x86_64-Y/_sysconfigdata*.py
${CROSS_COMPILED_LOCATION}/libpython3.Y.so

${CROSS_COMPILED_LOCATION}/build/lib.{OS}(-{OS-KERNEL-RELEASE})?-{ARCH}-Y/_sysconfigdata*.py
${CROSS_COMPILED_LOCATION}/libpython3.Y.so

${INSTALL_PREFIX}/lib/pypy3.Y/_sysconfigdata.py
${INSTALL_PREFIX}/lib_pypy/_sysconfigdata.py

Returns an empty vector when the target Python library directory is not set via PYO3_CROSS_LIB_DIR.