SIP - Python Bindings Generator

6.15.3 · active · verified Thu Apr 16

SIP is a tool for creating Python bindings for C and C++ libraries. It is primarily used to generate Python modules that allow Python code to call C/C++ functions and classes directly. Maintained by Riverbank Computing, it is the foundation for PyQt. The current version is 6.15.3, with releases typically tied to PyQt development.

Common errors

Warnings

Install

Imports

Quickstart

While SIP is mainly a build tool for C/C++ extensions, the installed `sip` module provides introspective information about the SIP environment. The primary use case involves defining `.sip` files and leveraging the `sip-build` command-line tool to generate Python bindings for a C/C++ library, typically as part of a larger build process.

import sip

# SIP is primarily a C/C++ bindings generator, not typically used directly in applications.
# This example shows basic introspection of the installed sip module.

print(f"SIP Version: {sip.SIP_VERSION_STR}")
print(f"SIP API ID: {sip.SIP_API_ID_STR}")

# To truly 'quickstart' SIP for generating bindings, you would:
# 1. Write a .sip file defining the C/C++ API.
# 2. Use the 'sip-build' command-line tool or integrate it into your build system.
# Example (conceptual command-line use):
# # In a terminal, after setting up project.sip and C/C++ sources:
# # sip-build --build-dir=build --sip-module=my_module project.sip

view raw JSON →