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)
42 if len(sys.argv) != 8:
43 print(
'usage: %s build-dir sip-file output_dir include_dirs libs lib_dirs ldflags' %
50 build_dir, sip_file, output_dir, include_dirs, libs, lib_dirs, ldflags = sys.argv[1:]
53 build_file =
'pyqtscripting.sbf' 62 sip_dir = config.pyqt_sip_dir
63 sip_flags = config.pyqt_sip_flags
64 except AttributeError:
66 sip_dir = os.path.join(sipconfig._pkg_config[
'default_sip_dir'],
'PyQt5')
67 sip_flags = QtCore.PYQT_CONFIGURATION[
'sip_flags']
70 os.makedirs(build_dir)
77 sip_bin = config.sip_bin
79 if sys.platform ==
'win32' and os.path.isdir(sip_bin):
85 '-b', os.path.join(build_dir, build_file),
89 cmd += sip_flags.split(
' ')
91 subprocess.check_call(cmd)
96 makefile = sipconfig.SIPModuleMakefile(
99 build_file=build_file,
100 qt=[
'QtCore',
'QtGui']
105 default_platform_lib_function = sipconfig.SIPModuleMakefile.platform_lib
110 if os.path.isabs(clib)
or clib.startswith(
'-l'):
115 sipconfig.SIPModuleMakefile.platform_lib = custom_platform_lib_function
121 paths = re.split(
'(?<=[^\\\\]) ', paths)
126 include_dir = include_dir.replace(
'\\',
'')
127 makefile.extra_include_dirs.append(include_dir)
129 makefile.extra_libs.append(lib)
131 lib_dir = lib_dir.replace(
'\\',
'')
132 makefile.extra_lib_dirs.append(lib_dir)
133 for ldflag
in ldflags.split(
'\\ '):
134 makefile.LFLAGS.append(ldflag)
137 makefile._target =
'"%s"' % os.path.join(output_dir, makefile._target)
140 if sys.platform ==
'win32':
141 makefile.extra_cxxflags.append(
'/std:c++14')
144 makefile.CXXFLAGS.append(
'/Zc:__cplusplus')
146 makefile.extra_cxxflags.append(
'-std=c++14')