[PyKDE] [PATCH] Compiling SIP with distutils

Phil Thompson phil at riverbankcomputing.co.uk
Thu Oct 27 12:27:58 BST 2005


> Hello,
>
> I have attached sipdistutils.py which gives preliminar support for
> compiling
> SIP extensions with distutils. It is based on Pyrex's distutils support.
>
>
> When you build an extension, the following happens:
>
> - The list of provided files is searched for files with extension .sip.
> - The files are compiled through "sip" (looking for the correct version),
> generating the source code in the distutils build temp directory. The SIP
> build file (.sbf) is also generated.
> - The .sbf file is parsed to extract the "sources" list of generated files
> - The files are appended to the list of sources to be compiled to build
> the
> extension.
> - Distutils contains normal execution and the .pyd/.so is created.
> - In later runs, the .sbf file is used to do date-based dependency check
> across the original .sip file.
>
>
> Example of usage (setup.py file):
>
> #!/usr/bin/env python
> from distutils.core import setup
> from distutils.extension import Extension
> from sipdistutils import build_ext
>
> setup(
>   name = 'boolop',
>   ext_modules=[
>     Extension("boolop",  ["boolop.sip", "boolop.cpp"],
>     ],
>   cmdclass = {'build_ext': build_ext}  # use sip's build_ext
> )
>
>
> Caveats:
>
> - It doesn't support building an extension with two sip files with the
> same
> basename.
> - It should run whichever SIP is installed in the Python distribution
> which
> is executing distutils. It looks for SIP in the exec_prefix directory
> (under
> Windows, this is the base directory of Python). Otherwise, it defaults to
> using the path, but if you have multiple Python/SIP versions that could be
> incorrect. I could run a version check between the output of "sip -V" and
> sip.SIP_VERSION_STR, but it looks just too hard. There ought to be a
> better
> way to find the right sip executable, even under Linux. Suggestions?
>
> Comments?

Is the swig_sources() method so called because it hooks into standard
wrapper support in distutils? Or were you just trying to hurt my feelings?
:)

You can get the name of the sip executable from the sipconfig module.

Should this be added to sipconfig.py rather than being a separate module?

Any chance of some documentation?

Thanks,
Phil




More information about the PyQt mailing list