[PyKDE] [PATCH] PyKDE 3.5-2 build.py options

Hans-Peter Jansen hpj at urpla.net
Mon Apr 21 17:34:06 BST 2003


Hi Jim,

I'm sure, you noticed some new build options in latest sip & PyQt.
While playing with PyKDE a bit, I thought, it would be nice to
build PyKDE on SMP systems more efficiently, too (-j). The rest 
enables building PyKDE on lib64 systems more easily (which I cannot
test ATM, unfortunately). At least, they allow me to get rid of any
lib64 related patches in my rpm specs...

I would be happy to find this included in your next release.

Pete

--- build.py.orig	2003-04-20 19:49:54.000000000 +0200
+++ build.py	2003-04-21 17:03:12.000000000 +0200
@@ -22,17 +22,19 @@
 
 qtDir           = None
 qtIncDir        = None
 qtVersion       = 0
 qtLib           = None
+qtLibDir        = None
 
 kdeDir          = None
 kdeIncDir       = None
 kdeVersion      = 0
 kdeLib          = None
 pyQtSipDir      = None
 
+platPyBaseDir   = None
 platPyScriptDir = None
 platPyDLLDir    = None
 platPySiteDir   = None
 platPyIncDir    = None
 platPyLib       = None
@@ -56,10 +58,11 @@
 tempBuildDir    = None
 usingTmake      = 0
 enableOldPython = 0
 catCppFiles     = 0
 qpeTag          = None
+catSplit        = 1
 
 FALSE      = 0
 TRUE       = not FALSE
 
 Release    = "3.5-2"
@@ -94,29 +97,32 @@
 def usage(rcode = 2):
     """Display a usage message and exit.
 
     rcode is the return code passed back to the calling process.
     """
-    global progName, platBinDir, platMake, modDir, platQTDIRName, sipIncDir
+    global progName, platBinDir, platMake, modDir, platQTDIRName, platPyBaseDir, sipIncDir
 
     print "Usage:"
     print "    %s [-h] " % (progName)
     print "    %s [options]\n" % (progName)
     print "where:"
     print "    -h             display this help message\n"
 
     print "  options:\n"
+    print "    -a dir         Python base directory [default %s]" % (platPyBaseDir)
     print "    -c             concatenate each module's C++ source files"
     print "    -d dir         where PyKDE will be installed [default %s]" % (modDir)
     print "    -e dir         the directory containing the SIP header files [default %s]" % (sipIncDir)
     print "    -g prog        the name of the Makefile generator"
     print "    -i dir         the directory containing the Qt header files [default %s%sinclude]" % (platQTDIRName,os.sep)
+    print "    -j #           split concatenated C++ source files in # pieces [default 1]"
     print "    -k dir         the KDE base directory [default %s]" % (platKDEDIRName)
     print "    -l Qt-library  explicitly specify the type of Qt library, either qt, qt-mt or qte"
     print "    -m prog        the name of the Make program [default %s]" % (platMake)
     print "    -p dir         the name of the SIP code generator [default sip]"
     print "    -q dir         the Qt base directory [default %s]" % (platQTDIRName)
+    print "    -r dir         the Qt lib directory [default %s%slib]" % (platQTDIRName, os.sep)
     print "    -s dir         the directory containing the SIP module"
     print "    -t dir         the directory containing the KDE header files [default %s/include]" % (platKDEDIRName)
     print "    -u dir         the directory containing the KDE lib files [default %s/lib]" % (platKDEDIRName)
     print "    -v dir         the directory containing the PyQt sip files\n"
     print "    -z file        the name of a file containing command line flags"
@@ -183,11 +189,11 @@
         return ver
 
 def initGlobals():
     """Sets the values of globals that need more than a simple assignment.
     """
-    global platMake, platCopy, platPyScriptDir, platPyDLLDir, platPySiteDir
+    global platMake, platCopy, platPyBaseDir, platPyScriptDir, platPyDLLDir, platPySiteDir
     global platPyIncDir, platPyLib, platQTDIRName, platBinDir, platMkdir
     global modDir, pyFullVers, sipIncDir, platKDEDIRName
 
     pyFullVers = string.split(sys.version)[0]
 
@@ -202,13 +208,21 @@
         pyVers = vl[0] + "." + vl[1]
 
         platMake = "make"
         platCopy = "cp"
         platMkdir = "mkdir"
-        platPyScriptDir = sys.prefix + "/lib/python" + pyVers
-        platPyDLLDir = sys.prefix + "/lib/python" + pyVers + "/lib-dynload"
-        platPySiteDir = sys.prefix + "/lib/python" + pyVers + "/site-packages"
+
+        if not platPyBaseDir:
+            platPyBaseDir = sys.prefix + "/lib/python" + pyVers
+        platPyScriptDir = platPyBaseDir
+        platPyDLLDir = platPyBaseDir + "/lib-dynload"
+
+        if pyVersNr < 20:
+            platPySiteDir = platPyBaseDir
+        else:
+            platPySiteDir = platPyBaseDir + "/site-packages"
+
         platPyIncDir = sys.prefix + "/include/python" + pyVers
         platQTDIRName = "$QTDIR"
         platKDEDIRName = "$KDEDIR"
         platBinDir = "/usr/local/bin"
 
@@ -604,13 +618,16 @@
 
 
 def checkQtLibrary():
     """Check which Qt library is to be used.
     """
-    global qtDir, qtLib
+    global qtDir, qtLibDir, qtLib
 
-    qtlibdir = qtDir + os.sep + "lib"
+    if qtLibDir:
+        qtlibdir = qtLibDir
+    else:
+        qtlibdir = qtDir + os.sep + "lib"
 
     if qtLib is None:
         mtlib = isQtLibrary(qtlibdir,"qt-mt")
         stlib = isQtLibrary(qtlibdir,"qt")
 
@@ -826,13 +843,13 @@
     inform("%s contains sipQt.h." % (sipIncDir))
 
     global sipModuleDir
 
     if sipModuleDir is None:
-		global platPyScriptDir, platPyDLLDir, platPySiteDir
+        global platPyScriptDir, platPyDLLDir, platPySiteDir
 
-		dirlist = [platPyDLLDir, platPyScriptDir, platPySiteDir]
+        dirlist = [platPyDLLDir, platPyScriptDir, platPySiteDir]
     else:
         dirlist = [sipModuleDir]
         sipModuleDir = None
 
     for d in dirlist:
@@ -1234,21 +1251,35 @@
     srclist = srclist[13:-1]
     srclist = string.replace(srclist,"\\\n\t","")
     srclist = string.split(srclist," ")
 
     # Concatenate the files.
-    d = open(mname + "huge.cpp","w")
+    global catSplit
+
+    p = 0
+    plist = []
+    nrinpiece = len(srclist) / catSplit
+
+    # Do each piece.
+    while srclist:
+        pname = "%shuge%d.cpp" % (mname, p)
+        plist.append(pname)
+
+        d = open(pname,"w")
+
+        for cppfile in srclist[:nrinpiece]:
+            f = open(cppfile,"r")
+            d.write(f.read())
+            f.close()
 
-    for cppfile in srclist:
-        f = open(cppfile,"r")
-        d.write(f.read())
-        f.close()
+        d.close()
 
-    d.close()
+        srclist = srclist[nrinpiece:]
+        p = p + 1
 
     # Replace the C++ file names in the project file.
-    buf = re.sub(pat,"SOURCES = " + mname + "huge.cpp\n",buf)
+    buf = re.sub(pat,"SOURCES = " + string.join(plist," ") + "\n",buf)
 
     f = open(pro + ".new","w")
     f.write(buf)
     f.close()
 
@@ -1314,11 +1345,11 @@
     progName = os.path.basename(argv[0])
 
     initGlobals()
 
     try:
-        optlist, args = getopt.getopt(argv[1:],"hcd:e:g:i:k:l:m:p:q:s:t:u:v:z:")
+        optlist, args = getopt.getopt(argv[1:],"ha:cd:e:g:i:j:k:l:m:p:q:r:s:t:u:v:z:")
     except getopt.GetoptError:
         usage()
 
     # Look for '-z' first and process that switch
     # (command line switches override file switches)
@@ -1331,10 +1362,13 @@
     explicitMake = 0
 
     for opt, arg in optlist:
         if opt == "-h":
             usage(0)
+        elif opt == "-a":
+            global platPyBaseDir
+            platPyBaseDir = arg
         elif opt == "-c":
             global catCppFiles
             catCppFiles = 1
         elif opt == "-d":
             global modDir
@@ -1346,10 +1380,18 @@
             global makefileGen
             makefileGen = arg
         elif opt == "-i":
             global qtIncDir
             qtIncDir = arg
+        elif opt == "-j":
+            global catSplit
+            try:
+                catSplit = int(arg)
+            except:
+                catSplit = 0
+            if catSplit < 1:
+                usage()
         elif opt == "-k":
             global kdeDir
             kdeDir = arg
         elif opt == "-l":
             if arg in ("qt", "qt-mt"):
@@ -1363,10 +1405,13 @@
             global sipBin
             sipBin = arg
         elif opt == "-q":
             global qtDir
             qtDir = arg
+        elif opt == "-r":
+            global qtLibDir
+            qtLibDir = arg
         elif opt == "-s":
             global sipModuleDir
             sipModuleDir = arg
         elif opt == "-t":
             global kdeIncDir
@@ -1378,10 +1423,12 @@
             global pyQtSipDir
             pyQtSipDir = arg
         elif opt == "-z":
             pass
 
+    initGlobals()
+
     installChecks()
     maindir = mkTempBuildDir()
     compileChecks()
 
     # Work out the platform and Qt version tags to pass to SIP to generate the




More information about the PyQt mailing list