An excellent documentation on replacing distutils was found at https://peps.python.org/pep-0632/#migration-advice
However, I had a problem with the proposed solution to replace distutils.sysconfig, it basically didn't work for me. I didn't get the same PATH as with distutils. I found a bug report about it: https://lists.ubuntu.com/archives/foundations-bugs/2017-June/323130.html
Based on what was documented there, I found the solution that I detailed at How to resolve a conflict between Debian 12 and Automake regarding the directory where compiled and packaged Python modules are installed?