The purpose of the build system is to make it easy for you to write configuration scripts in Python for your own bindings. The build system takes care of the details of particular combinations of platform and compiler. It supports over 50 different platform/compiler combinations.
The build system is implemented as a pure Python module called sipconfig that contains a number of classes and functions. Using this module you can write bespoke configuration scripts (e.g. PyQt4’s configure.py) or use it with other Python based build systems (e.g. Distutils and SCons).
An important feature of SIP is the ability to generate bindings that are built on top of existing bindings. For example, both PyKDE and PyQwt are built on top of PyQt4 but all three packages are maintained by different developers. To make this easier PyQt4 includes its own configuration module, pyqtconfig, that contains additional classes intended to be used by the configuration scripts of bindings built on top of PyQt4. The SIP build system includes facilities that do a lot of the work of creating these additional configuration modules.
This creates a configuration module (e.g. pyqtconfig) from a template file and a string.
Parameters: |
|
---|
This converts a Python dictionary to a string that can be parsed by the Python interpreter and converted back to an equivalent dictionary. It is typically used to generate the content string for sipconfig.create_config_module().
Parameters: |
|
---|---|
Returns: | the string representation of the dictionary. |
This creates a platform dependent executable wrapper around a Python script.
Parameters: |
|
---|---|
Returns: | the platform specific name of the wrapper. |
This displays an error message on stderr and calls sys.exit(1).
Parameters: | msg – the text of the message and should not include any newline characters. |
---|
This formats a message by inserting newline characters at appropriate places.
Parameters: |
|
---|---|
Returns: | the formatted message. |
This displays an information message on stdout.
Parameters: | msg – the text of the message and should not include any newline characters. |
---|
This parses a qmake compatible file of build system macros and converts it to a dictionary. A macro is a name/value pair. Individual macros may be augmented or replaced.
Parameters: |
|
---|---|
Returns: | the dictionary of parsed macros or None if any of the overrides were invalid. |
This extracts version information for a package from a file, usually a C or C++ header file. The version information must each be specified as a #define of a numeric (hexadecimal or decimal) value and/or a string value.
Parameters: |
|
---|---|
Returns: | a tuple of the numeric and string versions. sipconfig.error() is called if either were required but could not be found. |
This converts a version number to a SIP version tag. SIP uses the %Timeline directive to define the chronology of the different versions of the C/C++ library being wrapped. Typically it is not necessary to define a version tag for every version of the library, but only for those versions that affect the library’s API as SIP sees it.
Parameters: |
|
---|---|
Returns: | the SIP version tag. sipconfig.error() is called if the C/C++ library version number did not correspond to a SIP version tag. |
This converts a 3 part version number encoded as a hexadecimal value to a string.
Parameters: | v – the version number. |
---|---|
Returns: | a string. |
This class encapsulates configuration values that can be accessed as instance objects. A sub-class may provide a dictionary of additional configuration values in its constructor the elements of which will have precedence over the super-class’s values.
The following configuration values are provided:
The name of the directory where executables should be installed by default.
The name of the directory where SIP generated modules should be installed by default.
The name of the base directory where the .sip files for SIP generated modules should be installed by default. A sub-directory with the same name as the module should be created and its .sip files should be installed in the sub-directory. The .sip files only need to be installed if you might want to build other bindings based on them.
The name of the platform/compiler for which the build system has been configured for.
The name of the directory containing the pyconfig.h header file.
The name of the directory containing the Python.h header file.
The name of the directory containing the Python interpreter library.
The Python version as a 3 part hexadecimal number (e.g. v2.3.3 is represented as 0x020303).
The full pathname of the SIP executable.
The command line passed to configure.py when SIP was configured.
The name of the directory containing the sip.h header file.
The name of the directory containing the SIP module.
The SIP version as a 3 part hexadecimal number (e.g. v4.0.0 is represented as 0x040000).
The SIP version as a string. For development snapshots it will start with snapshot-.
The name of the MacOS/X SDK used when creating universal binaries.
The space separated MacOS/X architectures to build.
The MacOS/X deployment target.
Parameters: | sub_cfg – an optional list of sub-class configurations. It should only be used by the __init__() method of a sub-class to append its own dictionary of configuration values before passing the list to its super-class. |
---|
Get the dictionary of platform specific build macros.
Returns: | the macros dictionary. |
---|
Set the dictionary of platform specific build macros to be used when generating Makefiles. Normally there is no need to change the default macros.
Parameters: | macros – the macros dictionary. |
---|
This class encapsulates a Makefile. It is intended to be sub-classed to generate Makefiles for particular purposes. It handles all platform and compiler specific flags, but allows them to be adjusted to suit the requirements of a particular module or program. These are defined using a number of macros which can be accessed as instance attributes.
The following instance attributes are provided to help in fine tuning the generated Makefile:
A string that will check for the existence of a directory.
A reference to the configuration argument that was passed to Makefile.__init__().
A reference to the console argument that was passed to the Makefile.__init__().
A string that will copy a file.
A list of additional flags passed to the C compiler.
A list of additional flags passed to the C++ compiler.
A list of additional macro names passed to the C/C++ preprocessor.
A list of additional include directories passed to the C/C++ preprocessor.
A list of additional flags passed to the linker.
A list of additional library directories passed to the linker.
A list of additional libraries passed to the linker. The names of the libraries must be in platform neutral form (i.e. without any platform specific prefixes, version numbers or extensions).
A string that defines the platform specific style of Makefile. The only supported values are UNIX, MSVC, MSVC.NET, MINGW and BMAKE.
A string that will create a directory.
A string that will remove a file.
Parameters: |
|
---|
This generates the Makefile commands that will remove any files generated during the build of the default target.
Parameters: |
|
---|
This is called just before the Makefile is generated to ensure that it is fully configured. It must be reimplemented by a sub-class.
This generates the Makefile.
This is the default implementation of the Makefile macros and rules generation.
Parameters: | mfile – the Python file object of the Makefile. |
---|
This is the default implementation of the Makefile clean target generation.
Parameters: | mfile – the Python file object of the Makefile. |
---|
This is the default implementation of the Makefile default target generation.
Parameters: | mfile – the Python file object of the Makefile. |
---|
This is the default implementation of the Makefile install target generation.
Parameters: | mfile – the Python file object of the Makefile. |
---|
This generates the Makefile commands to install one or more files to a directory.
Parameters: |
|
---|
This returns an optional Makefile macro as a list.
Parameters: | name – the name of the macro. |
---|---|
Returns: | the macro as a list. |
This returns an optional Makefile macro as a string.
Parameters: |
|
---|---|
Returns: | the macro as a string. |
This parses a build file (created with the -b SIP command line option) and converts it to a dictionary. It can also validate an existing dictionary created through other means.
Parameters: | filename – is the name of the build file, or is a dictionary to be validated. A valid dictionary will contain the name of the target to build (excluding any platform specific extension) keyed by target; the names of all source files keyed by sources; and, optionally, the names of all header files keyed by headers. |
---|---|
Returns: | a dictionary corresponding to the parsed build file. |
This converts a library name to a platform specific form.
Parameters: |
|
---|---|
Returns: | the platform specific name. |
This is called to ensure that the Makefile is fully configured. It is normally called automatically when needed.
This returns a required Makefile macro as a string.
Parameters: | name – the name of the macro. |
---|---|
Returns: | the macro as a string. An exception is raised if the macro does not exist or has an empty value. |
This class is derived from sipconfig.Makefile.
This class encapsulates a Makefile to build a generic Python extension module.
Parameters: |
|
---|
This is a reimplementation of sipconfig.Makefile.finalise().
This is a reimplementation of sipconfig.Makefile.generate_macros_and_rules().
This is a reimplementation of sipconfig.Makefile.generate_target_clean().
This is a reimplementation of sipconfig.Makefile.generate_target_default().
This is a reimplementation of sipconfig.Makefile.generate_target_install().
This gets the name of a SIP v3.x module for when it is used as a library to be linked against. An exception will be raised if it is used with SIP v4.x modules.
Parameters: | mname – the name of the module. |
---|---|
Returns: | the corresponding library name. |
This class is derived from sipconfig.Makefile.
This class encapsulates a Makefile that sits above a number of other Makefiles in sub-directories.
Parameters: |
|
---|
This is a reimplementation of sipconfig.Makefile.generate_macros_and_rules().
This is a reimplementation of sipconfig.Makefile.generate_target_clean().
This is a reimplementation of sipconfig.Makefile.generate_target_default().
This is a reimplementation of sipconfig.Makefile.generate_target_install().
This class is derived from sipconfig.Makefile.
This class encapsulates a Makefile to build an executable program.
Parameters: |
|
---|
This creates a single command line that will create an executable program from a single source file.
Parameters: | source – the name of the source file. |
---|---|
Returns: | a tuple of the name of the executable that will be created and the command line. |
This is a reimplementation of sipconfig.Makefile.finalise().
This is a reimplementation of sipconfig.Makefile.generate_macros_and_rules().
This is a reimplementation of sipconfig.Makefile.generate_target_clean().
This is a reimplementation of sipconfig.Makefile.generate_target_default().
This is a reimplementation of sipconfig.Makefile.generate_target_install().
This class is derived from sipconfig.Makefile.
This class encapsulates a Makefile that installs a pure Python module.
Parameters: |
|
---|
This is a reimplementation of sipconfig.Makefile.generate_macros_and_rules().
This is a reimplementation of sipconfig.Makefile.generate_target_install().
This class is derived from sipconfig.ModuleMakefile.
This class encapsulates a Makefile to build a SIP generated Python extension module.
Parameters: |
|
---|
This is a reimplementation of sipconfig.Makefile.finalise().