Not.
Instead, change your extension module to provide a Python service, and then write Python code that calls os , shutil and your module.
In fact, for a lot of content in the os module, it's probably best to write your own C code rather than calling Python.
Of course, you can call Python modules from C code , it's just that it's too much for low level modules like os and shutil . When it comes to shutil file copy methods, overriding them in your C code is trivial. In fact, on Windows, copying a file is done by calling the OS, so the code does not exist even for writing to C.
If the Python module is written in C, you can even simply copy the code for the required methods.
source share