How sip works

Sip is in fact two things: a program, sip, that can be used to generate C++ wrapper code, and a small runtime library that handles much of the C++ functionality, such as signals and slots.

The program sip takes a set of input files that are created by the developer (.sip files) and uses them to generate a set of .h and .cpp files which are compiled and installed into a C++ library that Python knows how to communicate with.

In most cases, sip generates all C++ code automatically, but in some special cases it is necessary to manually write some wrapper code.

If you have the PyQt source distribution, you'll notice that you have a set of files whose names end with the .sip suffix, and another set of .h/.cpp files whose names begin with sip.

The .h/.cpp C++ files were generated from the .sip files using sip. These C++ files were then compiled to produce libraries that can be installed in the Python site-packages directory. Python can use these files to access the Qt library classes, methods and variables.