SIP4 python bindings for TQt
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build.py 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. # Copyright (c) 2007
  2. # Riverbank Computing Limited <info@riverbankcomputing.co.uk>
  3. #
  4. # This file is part of PyTQt.
  5. #
  6. # This copy of PyTQt is free software; you can redistribute it and/or modify it
  7. # under the terms of the GNU General Public License as published by the Free
  8. # Software Foundation; either version 2, or (at your option) any later
  9. # version.
  10. #
  11. # PyTQt is supplied in the hope that it will be useful, but WITHOUT ANY
  12. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  13. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  14. # details.
  15. #
  16. # You should have received a copy of the GNU General Public License along with
  17. # PyTQt; see the file LICENSE. If not, write to the Free Software Foundation,
  18. # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. #
  20. # This is the build script for PyTQt. It should be run in the top level
  21. # directory of the source distribution and by the Python interpreter for which
  22. # it is being built. It uses either qmake or tmake to do the hard work of
  23. # generating the platform specific Makefiles.
  24. import sys
  25. import os
  26. import glob
  27. import tempfile
  28. import shutil
  29. import py_compile
  30. import compileall
  31. import string
  32. # Get the SIP configuration.
  33. try:
  34. from sip4_tqt import sipconfig
  35. except:
  36. print "Unable to import the sipconfig module. Please make sure you have"
  37. print "SIP v3.9 or later installed."
  38. sys.exit(1)
  39. config = sipconfig.SIPConfig("PyTQt 3.18.1")
  40. # Initialise the globals.
  41. sipMajorVersion = config.sip_version >> 16
  42. sciIncDir = config.qt_inc_dir
  43. sciLibDir = config.qt_lib_dir
  44. sciLib = None
  45. sciVersion = None
  46. binDir = config.default_bin_dir
  47. modDir = config.default_mod_dir
  48. sipDir = config.default_sip_dir
  49. buildModules = ["qt"]
  50. tempBuildDir = None
  51. catCppFiles = 0
  52. catSplit = 1
  53. qpeTag = None
  54. trace = 0
  55. releaseGIL = 0
  56. def usage(rcode = 2):
  57. """Display a usage message and exit.
  58. rcode is the return code passed back to the calling process.
  59. """
  60. print "Usage:"
  61. print " %s [-h] [-a version] [-b dir] [-c] [-d dir] [-g] [-j #] [-n dir] [-o dir] [-r] [-v dir]" % sipconfig.script()
  62. print "where:"
  63. print " -h display this help message"
  64. print " -a tag explicitly enable the qtpe module"
  65. print " -b dir where pyuic and pylupdate will be installed [default %s]" % config.default_bin_dir
  66. print " -c concatenate each module's C++ source files"
  67. print " -d dir where the PyTQt modules will be installed [default %s]" % config.default_mod_dir
  68. print " -g always release the GIL (SIP v3.x behaviour)"
  69. print " -j # split the concatenated C++ source files into # pieces [default 1]"
  70. print " -n dir the directory containing the TQScintilla header files [default %s]" % config.qt_inc_dir
  71. print " -o dir the directory containing the TQScintilla library [default %s]" % config.qt_lib_dir
  72. print " -r generate code with tracing enabled [default disabled]"
  73. print " -v dir where the PyTQt .sip files will be installed [default %s]" % config.default_sip_dir
  74. sys.exit(rcode)
  75. def mkTempBuildDir(olddir=None):
  76. """Create a temporary build directory for a console application called
  77. qttest, complete with patched Makefile. The global tempBuildDir is set to
  78. the name of the directory. The temporary directory becomes the current
  79. directory.
  80. olddir is None if the directory should be created, otherwise it is deleted.
  81. Returns the name of the previous current directory.
  82. """
  83. global tempBuildDir
  84. if olddir is None:
  85. tempBuildDir = tempfile.mktemp()
  86. try:
  87. os.mkdir(tempBuildDir)
  88. except:
  89. sipconfig.error("Unable to create temporary directory.")
  90. prevdir = sipconfig.push_dir(tempBuildDir)
  91. sipconfig.copy_to_file("qttest.pro.in",
  92. """TEMPLATE = app
  93. TARGET = qttest
  94. CONFIG += console warn_off @TEST_OPENGL@ @BLX_CONFIG_APP@
  95. INCLUDEPATH = @BLX_INCLUDEPATH@ @TEST_QSCINTILLA_INC@
  96. DEFINES = @BLX_DEFINES@
  97. SOURCES = qttest.cpp
  98. LIBS += @TEST_QUI_LIB@ @TEST_QSCINTILLA_LIB@
  99. """)
  100. # Disable OpenGL, tqui and TQScintilla support by default.
  101. config.patches["@TEST_OPENGL@"] = ""
  102. config.patches["@TEST_QUI_LIB@"] = ""
  103. config.patches["@TEST_QSCINTILLA_INC@"] = ""
  104. config.patches["@TEST_QSCINTILLA_LIB@"] = ""
  105. # Create a dummy source file to suppress a qmake warning.
  106. sipconfig.copy_to_file("qttest.cpp", "")
  107. config.create_makefile("qttest.pro")
  108. else:
  109. sipconfig.pop_dir(olddir)
  110. prevdir = None
  111. shutil.rmtree(tempBuildDir, 1)
  112. return prevdir
  113. def tryModule(maindir, mname, incfile, ctor):
  114. """See if a PyTQt module should be built and update the buildModules list
  115. accordingly.
  116. maindir is the directory containing this script.
  117. mname is the name of the PyTQt module.
  118. incfile is the C++ header file that defines the class being used for the
  119. test.
  120. ctor is the constructor of the class being used for the test.
  121. """
  122. # Check for the existence of the module .sip file.
  123. msip = os.path.join(maindir, "sip", mname, mname + "mod.sip")
  124. if not os.access(msip, os.F_OK):
  125. return
  126. sipconfig.copy_to_file("qttest.cpp",
  127. """#include <%s>
  128. int main(int argc,char **argv)
  129. {
  130. new %s;
  131. }
  132. """ % (incfile, ctor))
  133. if sipconfig.run_make(None,0) == 0:
  134. buildModules.append(mname)
  135. sipconfig.inform("The %s module will be built." % mname)
  136. else:
  137. sipconfig.inform("The %s module will not be built." % mname)
  138. sipconfig.run_make("clean")
  139. def checkTQScintilla():
  140. """See if TQScintilla can be found and what its version is.
  141. """
  142. # Find the TQScintilla header files.
  143. sciglobal = os.path.join(sciIncDir, "qextscintillaglobal.h")
  144. if os.access(sciglobal,os.F_OK):
  145. config.patches["@PYQT_QSCINTILLA_INC@"] = sciIncDir
  146. sipconfig.inform("%s contains qextscintillaglobal.h." % (sciIncDir))
  147. # Get the TQScintilla version number.
  148. global sciVersion
  149. sciVersion, sciversstr = sipconfig.read_version(sciglobal, "TQScintilla", "TQSCINTILLA_VERSION", "TQSCINTILLA_VERSION_STR")
  150. sipconfig.inform("TQScintilla %s is being used." % (sciversstr))
  151. # If we find a snapshot then set the version number to 0 as a special
  152. # case.
  153. if sciversstr[:8] == "snapshot":
  154. sciVersion = 0
  155. # Find the TQScintilla library.
  156. if sys.platform == "win32":
  157. lpatt = "qscintilla.lib"
  158. else:
  159. lpatt = "libqscintilla.*"
  160. if len(glob.glob(os.path.join(sciLibDir, lpatt))):
  161. sipconfig.inform("%s contains the TQScintilla library." % sciLibDir)
  162. global sciLib
  163. if sys.platform == "win32":
  164. sciLib = sipconfig.escape(os.path.join(sciLibDir, "qscintilla.lib"))
  165. else:
  166. sciLib = sipconfig.escape("-L" + sciLibDir) + " -lqscintilla"
  167. config.patches["@PYQT_QSCINTILLA_LIB@"] = sciLib
  168. else:
  169. sipconfig.inform("The TQScintilla library could not be found in %s and so the qtext module will not be built. If TQScintilla is installed then use the -o argument to explicitly specify the correct directory." % (sciLibDir))
  170. sciVersion = -1
  171. else:
  172. sipconfig.inform("qextscintillaglobal.h could not be found in %s and so the qtext module will not be built. If TQScintilla is installed then use the -n argument to explicitly specify the correct directory." % sciIncDir)
  173. sciVersion = -1
  174. def moduleChecks(maindir):
  175. """See which PyTQt modules to build.
  176. """
  177. sipconfig.inform("Checking which additional PyTQt modules to build.");
  178. tryModule(maindir,"qtcanvas", "qcanvas.h", "TQCanvas()")
  179. tryModule(maindir,"qtnetwork", "qsocket.h", "TQSocket()")
  180. tryModule(maindir,"qttable", "qtable.h", "TQTable()")
  181. tryModule(maindir,"qtxml", "qdom.h", "TQDomImplementation()")
  182. if config.qt_version >= 0x030000:
  183. tryModule(maindir,"qtsql", "qsql.h", "TQSql()")
  184. # We need a different Makefile for the qtgl module.
  185. config.patches["@TEST_OPENGL@"] = "opengl"
  186. config.create_makefile("qttest.pro")
  187. tryModule(maindir,"qtgl", "qgl.h", "TQGLWidget()")
  188. # Put things back.
  189. config.patches["@TEST_OPENGL@"] = ""
  190. config.create_makefile("qttest.pro")
  191. # Check for the tqui library.
  192. if config.qt_version >= 0x030000:
  193. if sys.platform == "win32":
  194. tquilib = r"$(TQTDIR)\lib\tqui.lib"
  195. else:
  196. tquilib = "-ltqui"
  197. config.patches["@PYQT_QUI_LIB@"] = tquilib
  198. config.patches["@TEST_QUI_LIB@"] = tquilib
  199. config.create_makefile("qttest.pro")
  200. tryModule(maindir,"qtui", "qwidgetfactory.h", "TQWidgetFactory()")
  201. # Put things back.
  202. config.patches["@TEST_QUI_LIB@"] = ""
  203. config.create_makefile("qttest.pro")
  204. # Check for the TQScintilla library.
  205. if sciVersion >= 0:
  206. config.patches["@TEST_QSCINTILLA_INC@"] = sciIncDir
  207. config.patches["@TEST_QSCINTILLA_LIB@"] = sciLib
  208. config.create_makefile("qttest.pro")
  209. tryModule(maindir,"qtext", "qextscintillabase.h", "QextScintillaBase()")
  210. # Put things back.
  211. config.patches["@TEST_QSCINTILLA_INC@"] = ""
  212. config.patches["@TEST_QSCINTILLA_LIB@"] = ""
  213. config.create_makefile("qttest.pro")
  214. def generateFeatures(featfile):
  215. """Generate the header file describing the TQt features that are enabled if
  216. it doesn't already exist. (If it already exists then we are probably cross
  217. compiling and generated the file through other means.)
  218. featfile is the name of the features file.
  219. """
  220. if os.access(featfile,os.F_OK):
  221. sipconfig.inform("Using existing features file.")
  222. return
  223. sipconfig.inform("Generating the features file.")
  224. # The features that a given TQt configuration may or may not support. Note
  225. # that STYLE_WINDOWSXP requires special handling.
  226. flist = ["ACTION", "CLIPBOARD", "CODECS", "COLORDIALOG", "DATASTREAM",
  227. "DIAL", "DNS", "DOM", "DRAGANDDROP", "ICONVIEW", "IMAGE_TEXT",
  228. "INPUTDIALOG", "FILEDIALOG", "FONTDATABASE", "FONTDIALOG",
  229. "MESSAGEBOX", "MIMECLIPBOARD", "NETWORKPROTOCOL", "PICTURE",
  230. "PRINTDIALOG", "PRINTER", "PROGRESSDIALOG", "PROPERTIES",
  231. "SEMIMODAL", "SIZEGRIP", "SOUND", "SPLITTER", "STYLE_CDE",
  232. "STYLE_INTERLACE", "STYLE_MOTIF", "STYLE_MOTIFPLUS",
  233. "STYLE_PLATINUM", "STYLE_SGI", "STYLE_WINDOWS", "TABDIALOG",
  234. "TABLE", "TABLEVIEW", "TRANSFORMATIONS", "TRANSLATION", "WIZARD",
  235. "WORKSPACE"]
  236. # Generate the program which will generate the features file.
  237. f = open("qttest.cpp","w")
  238. # Escape the backslashes so that the name can be embedded in a C++ string.
  239. ffstr = string.replace(featfile, "\\", "\\\\")
  240. f.write(
  241. """#include <stdio.h>
  242. #include <tqglobal.h>
  243. #include <tqapplication.h>
  244. int main(int argc,char **argv)
  245. {
  246. FILE *fp;
  247. TQApplication app(argc,argv,0);
  248. if ((fp = fopen("%s","w")) == NULL)
  249. {
  250. printf("Unable to create '%s'\\n");
  251. return 1;
  252. }
  253. #if !defined(TQT_THREAD_SUPPORT)
  254. fprintf(fp,"-x TQt_THREAD_SUPPORT\\n");
  255. #endif
  256. #if (defined(Q_OS_WIN32) || defined(Q_OS_WIN64)) && TQT_VERSION >= 0x030000
  257. if (qWinVersion() != TQt::WV_XP)
  258. fprintf(fp,"-x TQt_STYLE_WINDOWSXP\\n");
  259. #endif
  260. """ % (ffstr, ffstr))
  261. for feat in flist:
  262. f.write(
  263. """
  264. #if defined(QT_NO_%s)
  265. fprintf(fp,"-x TQt_%s\\n");
  266. #endif
  267. """ % (feat, feat))
  268. f.write(
  269. """
  270. fclose(fp);
  271. return 0;
  272. }
  273. """)
  274. f.close()
  275. sipconfig.run_make()
  276. sipconfig.run_program(os.path.join(os.getcwd(), "qttest"))
  277. sipconfig.run_make("clean")
  278. sipconfig.inform("Generated the features file.")
  279. def generateSource(mname, plattag, qttag, xtrtag):
  280. """Generate the C++ source code for a particular PyTQt module.
  281. mname is the name of the module.
  282. plattag is the SIP tag for the platform.
  283. qttag is the SIP tag for the TQt version.
  284. xtrtag is an optional extra SIP tag.
  285. """
  286. sipconfig.inform("Generating the C++ source for the %s module." % mname)
  287. try:
  288. shutil.rmtree(mname)
  289. except:
  290. pass
  291. try:
  292. os.mkdir(mname)
  293. except:
  294. sipconfig.error("Unable to create the %s directory." % mname)
  295. pro = mname + ".pro"
  296. argv = ["-t", plattag,
  297. "-t", qttag,
  298. "-z", "features",
  299. "-I", "sip",
  300. "-m", mname + "/" + pro + ".in",
  301. "-c", mname,
  302. "sip/" + mname + "/" + mname + "mod.sip"]
  303. if xtrtag:
  304. argv.insert(0,xtrtag)
  305. argv.insert(0,"-t")
  306. if trace:
  307. argv.insert(0,"-r")
  308. if releaseGIL:
  309. argv.insert(0,"-g")
  310. sipconfig.run_program(config.sip_bin, argv)
  311. # Generate the Makefile.
  312. sipconfig.inform("Generating the Makefile for the %s module." % mname)
  313. olddir = sipconfig.push_dir(mname)
  314. if catCppFiles:
  315. sipconfig.cat_source_files(mname, catSplit)
  316. config.create_makefile(pro, mname)
  317. icmds = []
  318. if sipMajorVersion == 3:
  319. icmds.append(("copy", mname + ".py", modDir))
  320. icmds.append(("copy", mname + ".pyc", modDir))
  321. config.add_install_target(icmds)
  322. if sipMajorVersion == 3:
  323. # Compile the Python part of the module.
  324. pyname = mname + ".py"
  325. sipconfig.inform("Compiling %s." % (pyname))
  326. py_compile.compile(pyname)
  327. sipconfig.pop_dir(olddir)
  328. def versionToTag(vers, tags, desc):
  329. """Convert a version number to a tag.
  330. vers is the version number.
  331. tags is the dictionary of tags keyed by version number.
  332. desc is the descriptive name of the package.
  333. Returns the corresponding tag.
  334. """
  335. tag = None
  336. vl = tags.keys()
  337. vl.sort()
  338. # For a snapshot use the latest tag.
  339. if vers == 0:
  340. tag = tags[vl[-1]]
  341. else:
  342. for v in vl:
  343. if vers < v:
  344. tag = tags[v]
  345. break
  346. if tag is None:
  347. sipconfig.error("Invalid %s version: 0x%06x." % (desc, vers))
  348. return tag
  349. def main(argv):
  350. """The main function of the script.
  351. argv is the list of command line arguments.
  352. """
  353. import getopt
  354. # Parse the command line.
  355. try:
  356. optlist, args = getopt.getopt(argv[1:],"ha:b:cd:gj:n:o:rv:")
  357. except getopt.GetoptError:
  358. usage()
  359. for opt, arg in optlist:
  360. if opt == "-h":
  361. usage(0)
  362. elif opt == "-a":
  363. global qpeTag
  364. qpeTag = arg
  365. elif opt == "-b":
  366. global binDir
  367. binDir = arg
  368. elif opt == "-c":
  369. global catCppFiles
  370. catCppFiles = 1
  371. elif opt == "-d":
  372. global modDir
  373. modDir = arg
  374. elif opt == "-g":
  375. global releaseGIL
  376. releaseGIL = 1
  377. elif opt == "-j":
  378. global catSplit
  379. try:
  380. catSplit = int(arg)
  381. except:
  382. catSplit = 0
  383. if catSplit < 1:
  384. usage()
  385. elif opt == "-n":
  386. global sciIncDir
  387. sciIncDir = arg
  388. elif opt == "-o":
  389. global sciLibDir
  390. sciLibDir = arg
  391. elif opt == "-r":
  392. global trace
  393. trace = 1
  394. elif opt == "-v":
  395. global sipDir
  396. sipDir = arg
  397. # Confirm the license.
  398. sipconfig.confirm_license()
  399. # If there should be a license file then check it is where it should be.
  400. if config.license_file:
  401. if os.access(os.path.join("sip", config.license_file), os.F_OK):
  402. sipconfig.inform("Found the license file %s.\n" % config.license_file)
  403. else:
  404. sipconfig.error("Please copy the license file %s to the sip directory.\n" % config.license_file)
  405. # Check the TQt version.
  406. if config.qt_version == 0:
  407. sipconfig.error("SIP has been built with TQt support disabled.\n")
  408. # Early versions of TQt for the Mac didn't include everything. Rather than
  409. # maintain these in the future we just mandate a later version.
  410. if sys.platform == "darwin" and config.qt_version < 0x030100:
  411. sipconfig.error("PyTQt for MacOS/X requires TQt v3.1.0 or later.\n")
  412. # Check the installation directory is valid and add it as a patch.
  413. if not os.access(modDir,os.F_OK):
  414. sipconfig.error("The %s PyTQt destination directory does not seem to exist. Use the -d argument to set the correct directory." % (modDir))
  415. config.patches["@PYQT_MODDIR@"] = sipconfig.escape(modDir)
  416. sipconfig.inform("%s is the PyTQt installation directory." % (modDir))
  417. # Enable warnings for SIP v4 generated code.
  418. if sipMajorVersion >= 4:
  419. warn = "warn_on"
  420. else:
  421. warn = "warn_off"
  422. config.patches["@PYQT_WARN@"] = warn
  423. # Create patches to allow some modules to link against others.
  424. if sipMajorVersion >= 4:
  425. modlink = ""
  426. elif sys.platform == "win32":
  427. modlink = sipconfig.escape(os.path.join(modDir, "libtqtc.lib"))
  428. else:
  429. modlink = sipconfig.escape("-L" + modDir) + " -lqtcmodule"
  430. config.patches["@PYQT_QT_MODULE@"] = modlink
  431. if sipMajorVersion >= 4:
  432. modlink = ""
  433. elif sys.platform == "win32":
  434. modlink = sipconfig.escape(os.path.join(modDir, "libtqttablec.lib")) + " " + sipconfig.escape(os.path.join(modDir, "libtqtc.lib"))
  435. else:
  436. modlink = sipconfig.escape("-L" + modDir) + " -lqttablecmodule -lqtcmodule"
  437. config.patches["@PYQT_QTTABLE_MODULE@"] = modlink
  438. # The professional edition needs special handling if XML support is needed.
  439. if config.qt_edition == "professional":
  440. rbprof = "rbprof"
  441. else:
  442. rbprof = ""
  443. config.patches["@PYQT_RBPROF@"] = rbprof
  444. # Link in the qassistantclient library for TQt v3.1+.
  445. qaclib = ""
  446. if config.qt_version >= 0x030100:
  447. if sys.platform == "win32":
  448. qaclib = r"$(TQTDIR)\lib\qassistantclient.lib"
  449. else:
  450. qaclib = "-lqassistantclient"
  451. config.patches["@PYQT_QASSISTANTCLIENT_LIB@"] = qaclib
  452. # Check for TQScintilla.
  453. if config.qt_version >= 0x030000:
  454. checkTQScintilla()
  455. # Create a build directory that we can compile test programs.
  456. maindir = mkTempBuildDir()
  457. # Check what additional modules to build.
  458. if config.qt_version >= 0x020000:
  459. moduleChecks(maindir)
  460. # Work out the platform and TQt version tags to pass to SIP to generate the
  461. # code we need.
  462. if config.qt_lib == "qte":
  463. plattag = "WS_QWS"
  464. elif sys.platform == "win32":
  465. plattag = "WS_WIN"
  466. elif sys.platform == "darwin":
  467. plattag = "WS_MACX"
  468. else:
  469. plattag = "WS_X11"
  470. qttags = {
  471. 0x020000: "TQt_1_43",
  472. 0x020100: "TQt_2_00",
  473. 0x020200: "TQt_2_1_0",
  474. 0x020300: "TQt_2_2_0",
  475. 0x020301: "TQt_2_3_0",
  476. 0x030000: "TQt_2_3_1",
  477. 0x030001: "TQt_3_0_0",
  478. 0x030002: "TQt_3_0_1",
  479. 0x030004: "TQt_3_0_2",
  480. 0x030005: "TQt_3_0_4",
  481. 0x030006: "TQt_3_0_5",
  482. 0x030100: "TQt_3_0_6",
  483. 0x030101: "TQt_3_1_0",
  484. 0x030102: "TQt_3_1_1",
  485. 0x030200: "TQt_3_1_2",
  486. 0x030300: "TQt_3_2_0",
  487. 0x040000: "TQt_3_3_0"
  488. }
  489. qttag = versionToTag(config.qt_version, qttags, "TQt")
  490. # Work out the TQScintilla tag.
  491. if sciVersion >= 0:
  492. scitags = {
  493. 0x010100: "TQScintilla_1_0",
  494. 0x010200: "TQScintilla_1_1",
  495. 0x020000: "TQScintilla_1_2"
  496. }
  497. scitag = versionToTag(sciVersion, scitags, "TQScintilla")
  498. else:
  499. scitag = None
  500. # Generate the features file.
  501. generateFeatures(os.path.join(maindir, "features"))
  502. # We don't need the temporary build directory anymore.
  503. mkTempBuildDir(maindir)
  504. subdirs = []
  505. for mname in buildModules:
  506. if mname == "qtext":
  507. xtratag = scitag
  508. else:
  509. xtratag = None
  510. generateSource(mname, plattag, qttag, xtratag)
  511. subdirs.append(mname)
  512. # We handle the qtpe module explicitly rather than auto-detect. This is
  513. # because it does things a bit differently and I'm too lazy to deal with it
  514. # properly at the moment.
  515. if qpeTag:
  516. generateSource("qtpe", plattag, qttag, qpeTag)
  517. subdirs.append("qtpe")
  518. # Install the .sip files.
  519. sipconfig.inform("Creating Makefile for .sip files.")
  520. olddir = sipconfig.push_dir("sip")
  521. sipconfig.copy_to_file("Makefile", "all:\n")
  522. icmds = []
  523. for mname in buildModules:
  524. dstdir = os.path.join(sipDir, mname)
  525. icmds.append(("mkdir", dstdir, None))
  526. for sf in os.listdir(os.path.join(olddir, "sip", mname)):
  527. icmds.append(("copy", os.path.join(mname, sf), os.path.join(dstdir, sf)))
  528. config.add_install_target(icmds)
  529. sipconfig.pop_dir(olddir)
  530. subdirs.append("sip")
  531. # See which version of pyuic to build.
  532. config.patches["@PYQT_BINDIR@"] = sipconfig.escape(binDir)
  533. if config.qt_version >= 0x030000:
  534. sipconfig.inform("Creating Makefile for pyuic3.")
  535. subdirs.append("pyuic3")
  536. olddir = sipconfig.push_dir("pyuic3")
  537. elif config.qt_version >= 0x020000:
  538. sipconfig.inform("Creating Makefile for pyuic2.")
  539. subdirs.append("pyuic2")
  540. olddir = sipconfig.push_dir("pyuic2")
  541. config.create_makefile("pyuic.pro", [])
  542. sipconfig.pop_dir(olddir)
  543. # Build pylupdate if TQt v3.0 or later.
  544. if config.qt_version >= 0x030000:
  545. sipconfig.inform("Creating Makefile for pylupdate3.")
  546. subdirs.append("pylupdate3")
  547. olddir = sipconfig.push_dir("pylupdate3")
  548. config.create_makefile("pylupdate.pro", [])
  549. sipconfig.pop_dir(olddir)
  550. # Generate the top-level Makefile.
  551. sipconfig.inform("Creating top level Makefile.")
  552. sipconfig.copy_to_file("PyTQt.pro.in", "TEMPLATE = subdirs\nSUBDIRS = " + string.join(subdirs) + "\n")
  553. config.create_makefile("PyTQt.pro")
  554. # Tell the user what to do next.
  555. msg = "The build of the PyTQt source code for your system is now complete. To compile and install PyTQt run \"%s\" and \"%s install\" with appropriate user privileges." % (config.make_bin, config.make_bin)
  556. sipconfig.inform(msg)
  557. if __name__ == "__main__":
  558. try:
  559. main(sys.argv)
  560. except SystemExit:
  561. raise
  562. except:
  563. print \
  564. """An internal error occured. Please report all the output from the program,
  565. including the following traceback, to support@riverbankcomputing.co.uk.
  566. """
  567. raise