[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pygame] rpm installation patch




Please find below a patch against pygame-0.4.

Short description: It modifies config.py, and creates a new
config_rpm.py file. These two files do proper dependency checking, and
allow users of any RPM-enabled unix distribution to autobuild their
Setup file.

Long description: The current method of installing pygame usually
involves manual editing of the Setup file generated by
config.py. While this is no problem, it conflicts with the RPM
philosophy of unattended, hands-off configuration of packages. In
order to satisfy this requirement, a completely autonomous method of
turning a Setup.in file into a Setup file had to be found. 

My previous method involved a bash script in the SPEC file, which
queried the RPM database for installed dependencies. This worked well,
except in the case of Numerical Python. The latest version of Numpy is
17.1.2, while the latest Numpy RPM is from 15.3 (back in May). As a
result, people who are doing work in numpy will have installed from
source, and Numpy will not be in their RPM database.

I would have liked to just write the SPEC file script in python, but
RPM have a bash-script only philosophy.

Thus, this patch. I detect whether or not rpm is present in config.py,
and if it is, config_rpm.py is run. It already examined each line of
the Setup.in file to set the SDL compilation flags, I just had it add
checks for the dependencies, and comment out those it didn't like. I
get around the Numpy issue by using python, and trying to import
Numerical instead of looking for it in the RPM database.

The patch:

diff -ubP pygame-0.4/config.py pygame-0.4b/config.py
--- pygame-0.4/config.py        Mon Nov 20 17:03:26 2000
+++ pygame-0.4b/config.py       Thu Dec 14 19:31:31 2000
@@ -10,12 +10,14 @@
 if sys.platform == 'win32':
     print 'Using WINDOWS configuration...\n'
     import config_win as CFG
+elif os.system('rpm > /dev/null') == 0:
+    print 'Using UNIX/RPM configuration...\n'
+    import config_rpm as CFG
 else:
     print 'Using UNIX configuration...\n'
     import config_unix as CFG
 

diff -ubP pygame-0.4/config_rpm.py pygame-0.4b/config_rpm.py
--- pygame-0.4/config_rpm.py    Wed Dec 31 16:00:00 1969
+++ pygame-0.4b/config_rpm.py   Thu Dec 14 20:02:13 2000
@@ -0,0 +1,64 @@
+"""Config on Unix"""
+#would be nice if it auto-discovered which other modules where available
+
+import os, sys, shutil
+from glob import glob
+
+configcommand = 'sdl-config --version --cflags --libs'
+
+
+def writesetupfile(flags):
+    origsetup = open('Setup.in', 'r')
+    newsetup = open('Setup', 'w')
+    while 1:
+        line = origsetup.readline()
+        if not line: break
+        if line.startswith('SDL = '):
+            line = 'SDL = ' + flags + '\n'
+        elif line.startswith('surfarray'):
+            try:
+                import Numeric
+            except:
+                line = '#' + line
+        elif line.startswith('font'):
+            if os.system('rpm -qa | grep SDL_ttf-devel > /dev/null') != 0:
+                line = '#' + line
+        elif line.startswith('image'):
+            if os.system('rpm -qa | grep SDL_image-devel > /dev/null') != 0:
+                line = '#' + line
+        elif line.startswith('mixer'):
+            if os.system('rpm -qa | grep SDL_mixer-devel > /dev/null') != 0:
+                line = '#' + line
+            
+        newsetup.write(line)
+    
+
+def main():
+    configinfo = "-I/usr/include/SDL -D_REENTRANT -lSDL"
+    print 'calling "sdl-config"'
+    try:
+        configinfo = os.popen(configcommand).readlines()
+        print 'Found SDL version:', configinfo[0]
+        configinfo = ' '.join(configinfo[1:])
+        configinfo = configinfo.split()
+        for w in configinfo[:]:
+            if ',' in w: configinfo.remove(w)
+        configinfo = ' '.join(configinfo)
+        print 'Flags:', configinfo
+    except:
+        raise SystemExit, """Cannot locate command, "sdl-config". Default SD
L compile
+flags have been used, which will likely require a little editing."""
+
+    # Detecting dependencies.
+    
+
+    print '\n--Creating new "Setup" file...'
+    writesetupfile(configinfo)
+    print '--Finished'
+
+
+    
+if __name__ == '__main__':
+    print """This is the configuration subscript for Unix.
+Please run "config.py" for full configuration."""
+


-- 
------------------------------------------------------------------------\
David "Futility [D!]" Clark  |   This is your life, and it's ending one |  
silenus@telus.net            |             minute at a time.            |

____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org