[PyKDE] SIP %Version Directive

Phil Thompson phil at river-bank.demon.co.uk
Fri Dec 1 11:33:34 GMT 2000

Christian Reyes wrote:
> Phil, I've recently upgraded to your SIP tool version 2.2 and I'm having
> trouble getting a hang of your new %version directive.
> Could you please provide an explanation of it?
> Thanks,
> christian

The syntax of the %Version directive is...

%Version	version-id	C++-test	Python-test

The version-id is the symbolic ID given to the version used in any %If

C++-test is a valid C++ pre-processor expression that should be true if
the version is this *or a later one* (assuming this is a primary
version, see below).

Python-test is a valid Python expression that does the same test. The
Python-test isn't always needed - you can omit it and SIP will complain
if it needs it.

Versions can either be primary or secondary. Primary versions form a
timeline and are identified with the %PrimaryVersions directive, eg.

%PrimaryVersions {version1-id version2-id version3-id}

The order represents the order in which the versions were released.

Any other version is a secondary version. All secondary versions are
assumed to be mutually exclusive. PyQt uses them to distinguish between
X11 and Windows.

When using the %If directive it is possible to specify a range of
primary versions, eg.

%If Version(version1-id)
	version1 only

%If Version(version1-id - version2-id)
	versions from version1 up to *but not including* version2 (ie. version1

%If Version(- version3-id)
	all versions up to but not including version3

%If Version(version2-id -)
	version2 and all subsequent versions

You can nest %If directives to produce logical ands of conditions. There
is no way to produce logical ors.

Versions don't (yet) work properly with imported modules.


More information about the PyQt mailing list