18
18
depending on your platform) you should then check for any ``README`` files
19
19
that relate to your platform.
21
Next you need to configure SIP by executing the ``configure.py`` script. For
21
Next you need to configure SIP by executing the :program:`configure.py` script.
24
24
python configure.py
26
26
This assumes that the Python interpreter is on your path. Something like the
27
27
following may be appropriate on Windows::
29
c:\python32\python configure.py
29
c:\python34\python configure.py
31
31
If you have multiple versions of Python installed then make sure you use the
32
32
interpreter for which you wish SIP to generate bindings for.
54
54
The SIP code generator will be installed in the directory ``<DIR>``.
56
.. cmdoption:: --configuration <FILE>
58
.. versionadded:: 4.16
60
``<FILE>`` contains the configuration of the SIP build to be used instead
61
of dynamically introspecting the system and is typically used when
62
cross-compiling. See :ref:`ref-configuration-files`.
56
64
.. cmdoption:: -d <DIR>, --destdir <DIR>
58
66
The SIP module will be installed in the directory ``<DIR>``.
120
134
``package.sub-package.module``. See :ref:`ref-private-sip` for how to
121
135
use this to create a private copy of the SIP module.
123
The ``configure.py`` script takes many other options that allows the build
124
system to be finely tuned. These are of the form ``name=value`` or
137
.. cmdoption:: --sysroot <DIR>
139
.. versionadded:: 4.16
141
``<DIR>`` is the name of an optional directory that replaces ``sys.prefix``
142
in the names of other directories (specifically those specifying where the
143
various SIP components will be installed and where the Python include
144
directories can be found). It is typically used when cross-compiling or
145
when building a static version of SIP. See :ref:`ref-configuration-files`.
147
.. cmdoption:: --target-py-version <VERSION>
149
.. versionadded:: 4.16
151
``<VERSION>`` is the major and minor version (e.g. ``3.4``) of the version
152
of Python being targetted. By default the version of Python being used to
153
run the :program:`configure.py` script is used. It is typically used when
154
cross-compiling. See :ref:`ref-configuration-files`.
156
.. cmdoption:: --use-qmake
158
.. versionadded:: 4.16
160
Normally the :program:`configure.py` script uses SIP's own build system to
161
create the Makefiles for the code generator and module. This option causes
162
project files (``.pro`` files) used by Qt's :program:`qmake` program to be
163
generated instead. :program:`qmake` should then be run to generate the
164
Makefiles. This is particularly useful when cross-compiling.
166
The :program:`configure.py` script takes many other options that allows the
167
build system to be finely tuned. These are of the form ``name=value`` or
125
168
``name+=value``. The :option:`--show-build-macros <configure.py
126
169
--show-build-macros>` option will display each supported ``name``, although not
127
170
all are applicable to all platforms.
138
181
python configure.py CXXFLAGS+=-fno-exceptions
140
A pure Python module called ``sipconfig.py`` is generated by ``configure.py``.
141
This defines each ``name`` and its corresponding ``value``. Looking at it will
142
give you a good idea of how the build system uses the different options. It is
143
covered in detail in :ref:`ref-build-system`.
183
A pure Python module called ``sipconfig.py`` is generated by
184
:program:`configure.py`. This defines each ``name`` and its corresponding
185
``value``. Looking at it will give you a good idea of how the build system
186
uses the different options. It is covered in detail in
187
:ref:`ref-build-system`.
146
190
Configuring for MinGW
160
204
compiler. You must use the :option:`--platform <configure.py -p>` command line
161
205
option to specify the correct platform. For example::
163
c:\python32\python configure.py --platform win32-borland
207
c:\python34\python configure.py --platform win32-borland
165
209
You must also make sure you have a Borland-compatible version of the Python
166
210
library. If you are using the standard Python distribution (built using the
167
211
Microsoft compiler) then you must convert the format of the Python library.
170
coff2omf python32.lib python32_bcpp.lib
214
coff2omf python34.lib python34_bcpp.lib
185
229
(Depending on your system you may require root or administrator privileges.)
187
231
This will install the various SIP components.
234
.. _ref-configuration-files:
236
Configuring with Configuration Files
237
------------------------------------
239
The :program:`configure.py` script normally introspects the Python installation
240
of the interpreter running it in order to determine the names of the various
241
files and directories it needs. This is fine for a native build of SIP but
242
isn't appropriate when cross-compiling. In this case it is possible to supply
243
a configuration file, specified using the
244
:option:`--configuration <configure.py --configuration>` option, which contains
245
definitions of all the required values.
247
The format of a configuration file is as follows:
249
- a configuration item is a single line containing a name/value pair separated
252
- a value may include another value by embedding the name of that value
253
surrounded by ``%(`` and ``)``
255
- comments begin with ``#`` and continue to the end of the line
257
- blank lines are ignored.
259
:program:`configure.py` provides the following preset values for a
263
is the major version number of the target Python installation.
266
is the minor version number of the target Python installation.
269
is the name of the system root directory. This is specified with the
270
:option:`--sysroot <configure.py --sysroot>` option.
272
The following is an example configuration file::
274
# The target Python installation.
276
py_inc_dir = %(sysroot)/usr/include/python%(py_major)%(py_minor)
278
# Where SIP will be installed.
279
sip_bin_dir = %(sysroot)/usr/bin
280
sip_module_dir = %(sysroot)/usr/lib/python%(py_major)/dist-packages
282
The following values can be specified in the configuration file:
285
is the target Python platform.
288
is the target Python include directory containing the ``Python.h`` file.
291
is the target Python include directory containing the ``pyconfig.h`` file.
292
If this isn't specified then it defaults to the value of ``py_inc_dir``.
295
is the target Python library directory.
298
is the name of the target directory where the SIP code generator will be
299
installed. It can be overridden by the
300
:option:`--bindir <configure.py -b>` option.
303
is the name of the target directory where the ``sip.h`` file will be
304
installed. If this isn't specified then it defaults to the value of
305
``py_inc_dir``. It can be overridden by the
306
:option:`--incdir <configure.py -e>` option.
309
is the target directory where the SIP module will be installed. It can be
310
overridden by the :option:`--destdir <configure.py -d>` option.
313
is the name of the target directory where generated ``.sip`` files will be
314
installed by default. It is only used when creating the :mod:`sipconfig`
315
module. It can be overridden by the :option:`--sipdir <configure.py -v>`