Debian Codegraph @

cmake/modules/FindSIP.py

raw symbols SCIP
1 # FindSIP.py
2 #
3 # SPDX-FileCopyrightText: 2007 Simon Edwards <[email protected]>
4 # SPDX-FileCopyrightText: 2021 L. E. Segovia <[email protected]>
5 #
6 # SPDX-License-Identifier: BSD-3-Clause
7 #
8
9 import os
10
11 def osAwareExecutable(filename):
12 return filename if os.name != 'nt' else filename + ".exe"
13
14 def osAwareSuffix():
15 return os.path.join("lib", "python3.8", "site-packages","sipconfig.py") if os.name != 'nt' else os.path.join("lib","krita-python-libs","sipconfig.py")
16
17 try:
18 import sipbuild
19
20 print("sip_version:%06.0x" % sipbuild.version.SIP_VERSION)
21 print("sip_version_str:%s" % sipbuild.version.SIP_VERSION_STR)
22
23 import shutil
24
25 # sip v5 and higher need to invoke sip-build
26 print("sip_bin:%s" % shutil.which("sip-build"))
27 except ImportError: # Code for SIP <5
28 import sipconfig
29
30 sipcfg = sipconfig.Configuration()
31 sip_version = sipcfg.sip_version
32 sip_version_str = sipcfg.sip_version_str
33 sip_bin = sipcfg.sip_bin
34 default_sip_dir = sipcfg.default_sip_dir
35 sip_inc_dir = sipcfg.sip_inc_dir
36 if not os.path.isfile(osAwareExecutable(sip_bin)):
37 # Relocated deps, attempt to fix the paths...
38 sipconfig_path = os.path.abspath(sipconfig.__file__)
39 sipconfig_expected_suffix = osAwareSuffix()
40 if sipconfig_path.endswith(sipconfig_expected_suffix):
41 deps_prefix = sipconfig_path[:-len(sipconfig_expected_suffix)]
42 sip_bin_expected_suffix = os.path.join("bin","sip")
43 if sip_bin.endswith(sip_bin_expected_suffix):
44 orig_prefix = sip_bin[:-len(sip_bin_expected_suffix)]
45 if os.path.isfile(osAwareExecutable(sip_bin.replace(orig_prefix, deps_prefix, 1))):
46 sip_bin = sip_bin.replace(orig_prefix, deps_prefix, 1)
47 default_sip_dir = default_sip_dir.replace(orig_prefix, deps_prefix, 1)
48 sip_inc_dir = sip_inc_dir.replace(orig_prefix, deps_prefix, 1)
49 print("sip_version:%06.0x" % sip_version)
50 print("sip_version_str:%s" % sip_version_str)
51 print("sip_bin:%s" % sip_bin)
52 print("default_sip_dir:%s" % default_sip_dir)
53 print("sip_inc_dir:%s" % sip_inc_dir)
54