2 from distutils.spawn
import find_executable
9 from PyQt5
import QtCore
15 env = copy(os.environ)
16 env[
'QT_SELECT'] =
'5' 17 qmake_exe =
'qmake-qt5' if find_executable(
'qmake-qt5')
else 'qmake' 18 qtconfig = subprocess.check_output(
19 [qmake_exe,
'-query'], env=env, universal_newlines=
True)
20 qtconfig = dict(line.split(
':', 1)
for line
in qtconfig.splitlines())
22 'qt_archdata_dir': qtconfig[
'QT_INSTALL_DATA'],
23 'qt_data_dir': qtconfig[
'QT_INSTALL_DATA'],
24 'qt_dir': qtconfig[
'QT_INSTALL_PREFIX'],
25 'qt_inc_dir': qtconfig[
'QT_INSTALL_HEADERS'],
26 'qt_lib_dir': qtconfig[
'QT_INSTALL_LIBS'],
28 'qt_version': QtCore.QT_VERSION,
29 'qt_winconfig':
'shared exceptions',
31 if sys.platform ==
'darwin':
32 pyqtconfig[
'qt_framework'] = 1
33 sipconfig.Configuration.__init__(self, [pyqtconfig])
35 macros = sipconfig._default_macros.copy()
36 macros[
'INCDIR_QT'] = qtconfig[
'QT_INSTALL_HEADERS']
37 macros[
'LIBDIR_QT'] = qtconfig[
'QT_INSTALL_LIBS']
38 macros[
'MOC'] =
'moc-qt5' 39 self.set_build_macros(macros)
44 Get the extra SIP flags needed by the imported qt module, and locate PyQt5 sip install files. 46 Note that this normally only includes those flags (-x and -t) that relate to SIP's versioning 50 sip_dir = config.pyqt_sip_dir
51 sip_flags = config.pyqt_sip_flags
52 return sip_dir, sip_flags
53 except AttributeError:
55 sip_flags = QtCore.PYQT_CONFIGURATION[
'sip_flags']
57 default_sip_dir = os.path.join(sipconfig._pkg_config[
'default_sip_dir'],
'PyQt5')
58 if os.path.exists(default_sip_dir):
59 return default_sip_dir, sip_flags
62 default_sip_dir = os.path.join(sipconfig._pkg_config[
'default_sip_dir'],
'Qt5')
63 if os.path.exists(default_sip_dir):
64 return default_sip_dir, sip_flags
65 raise FileNotFoundError(
'The sip directory for PyQt5 could not be located. Please ensure' +
66 ' that PyQt5 is installed')
69 if len(sys.argv) != 8:
70 print(
'usage: %s build-dir sip-file output_dir include_dirs libs lib_dirs ldflags' %
77 build_dir, sip_file, output_dir, include_dirs, libs, lib_dirs, ldflags = sys.argv[1:]
80 build_file =
'pyqtscripting.sbf' 88 os.makedirs(build_dir)
95 sip_bin = config.sip_bin
97 if sys.platform ==
'win32' and os.path.isdir(sip_bin):
103 '-b', os.path.join(build_dir, build_file),
107 cmd += sip_flags.split(
' ')
109 subprocess.check_call(cmd)
114 makefile = sipconfig.SIPModuleMakefile(
116 configuration=config,
117 build_file=build_file,
118 qt=[
'QtCore',
'QtGui']
123 default_platform_lib_function = sipconfig.SIPModuleMakefile.platform_lib
127 if not clib
or clib.isspace():
130 if os.path.isabs(clib)
or clib.startswith(
'-l'):
135 sipconfig.SIPModuleMakefile.platform_lib = custom_platform_lib_function
141 paths = re.split(
'(?<=[^\\\\]) ', paths)
146 include_dir = include_dir.replace(
'\\',
'')
147 makefile.extra_include_dirs.append(include_dir)
149 makefile.extra_libs.append(lib)
151 lib_dir = lib_dir.replace(
'\\',
'')
152 makefile.extra_lib_dirs.append(lib_dir)
153 for ldflag
in ldflags.split(
'\\ '):
154 makefile.LFLAGS.append(ldflag)
157 makefile._target =
'"%s"' % os.path.join(output_dir, makefile._target)
160 if sys.platform ==
'win32':
161 makefile.extra_cxxflags.append(
'/std:c++14')
164 makefile.CXXFLAGS.append(
'/Zc:__cplusplus')
166 makefile.extra_cxxflags.append(
'-std=c++14')
172 libs = makefile.LIBS.as_list()
173 for i
in range(len(libs)):
174 libs[i] = libs[i].replace(
'$$[QT_INSTALL_LIBS]', config.build_macros()[
'LIBDIR_QT'])
175 makefile.LIBS.set(libs)