1. pygame
  2. Untitled project
  3. pygame

Commits

Lenard Lindstrom  committed 98ea1dc

Furthur changes supporting Windows dependency transition

  • Participants
  • Parent commits 5f9a798
  • Branches default

Comments (0)

Files changed (3)

File Setup.in

View file
 PNG = -lpng
 JPEG = -ljpeg
 SCRAP = -lX11
-COPYLIB_SDL -lSDL -Lprebuilt/lib/SDL.dll
-COPYLIB_FONT -lSDL_ttf -Lprebuilt/lib/SDL_ttf.dll
-COPYLIB_IMAGE -lSDL_image -Lprebuilt/lib/SDL_image.dll
-COPYLIB_MIXER -lSDL_mixer -Lprebuilt/lib/SDL_mixer.dll
-COPYLIB_SMPEG -lsmpeg -Lprebuilt/lib/smpeg.dll
-COPYLIB_TIFF -ltiff -Lprebuilt/lib/libtiff.dll
-COPYLIB_PNG -lpng -Lprebuilt/lib/libpng13.dll
-COPYLIB_JPEG -ljpeg -Lprebuilt/lib/jpeg.dll
-COPYLIB_Z -lz -Lprebuilt/lib/zlib1.dll
-COPYLIB_VORBISFILE -lvorbisfile -Lprebuilt/lib/libvorbisfile-3.dll
-COPYLIB_VORBIS -lvorbis -Lprebuilt/lib/libvorbis-0.dll
-COPYLIB_OGG -logg -Lprebuilt/lib/libogg-0.dll
 #--EndConfig
 
 #DEBUG = -C-W -C-Wall

File config_win.py

View file
 """Config on Windows"""
 
+# **** The search part is broken. Only the prebuilt section creates
+# a correct Setup file.
+
 import dll
 import os, sys
 from glob import glob
 
 class Dependency(object):
     inc_hunt = ['include']
-    lib_hunt = ['VisualC\\SDL\\Release', 'VisualC\\Release', 'Release', 'lib', 'objs']
+    lib_hunt = ['VisualC\\SDL\\Release', 'VisualC\\Release', 'Release', 'lib']
     def __init__(self, name, wildcards, libs=None, required = 0):
         if libs is None:
             libs = [dll.name_to_root(name)]
     DependencyDLL('TIFF', ['tiff-[3-9].*']),
     DependencyDLL('VORBIS', ['libvorbis-[1-9].*']),
     DependencyDLL('OGG', ['libogg-[1-9].*']),
-#    DependencyDLL('FREETYPE', ['freetype-[2-9].*']),
     DependencyDLL('Z', ['zlib-[1-9].*']),
 ]
 
             setup_win_in = open(os.path.join('prebuilt', 'Setup_Win.in'))
         except IOError:
             # prebuilt lacks a Setup_Win.in. Use defaults.
-            setup_prebuilt_oldstyle(setup)
-        else:
-            # Copy Setup.in to Setup, replacing the BeginConfig/EndConfig
-            # block with prebuilt\Setup_Win.in .
-            setup_in = open('Setup.in')
-            try:
-                do_copy = True
-                for line in setup_in:
-                    if line.startswith('#--StartConfig'):
-                        do_copy = False
-                        setup.write(setup_win_in.read())
-                    elif line.startswith('#--EndConfig'):
-                        do_copy = True
-                    elif do_copy:
-                        setup.write(line)
-            finally:
-                setup_in.close()
+            setup_win_in = open('Default_Setup_Win.in')
+
+        # Copy Setup.in to Setup, replacing the BeginConfig/EndConfig
+        # block with prebuilt\Setup_Win.in .
+        setup_in = open('Setup.in')
+        try:
+            do_copy = True
+            for line in setup_in:
+                if line.startswith('#--StartConfig'):
+                    do_copy = False
+                    setup.write(setup_win_in.read())
+                elif line.startswith('#--EndConfig'):
+                    do_copy = True
+                elif do_copy:
+                    setup.write(line)
+        finally:
+            setup_in.close()
     finally:
         setup.close()
 
-def setup_prebuilt_oldstyle(setup):
-    # Copy setup to file 'Setup'. Use the contents of the
-    # BeginConfig/EndConfig block, with modifications.
-    for line in open('Setup.in').readlines():
-        if line[:3] == '#--': continue
-        if line[:6] == 'SDL = ':
-            line = 'SDL = -Iprebuilt/include -Iprebuilt/include/SDL -Lprebuilt/lib -lSDL\n'
-        if line[:8] == 'SMPEG = ':
-            line = 'SMPEG = -Iprebuilt/include/smpeg -lsmpeg\n'
-        if line[:8] == 'SCRAP = ':
-            line = 'SCRAP = -luser32 -lgdi32\n'
-        setup.write(line)
-
 
 def main():
     if os.path.isdir('prebuilt'):

File setup.py

View file
             pass
         
     #add dependency DLLs to the project
-    import dll
+    lib_dependencies = {}
+    for e in extensions:
+        if e.name.startswith('COPYLIB_'):
+            lib_dependencies[e.name[8:]] = e.libraries
+
+    def dependencies(roots):
+        """Return a set of dependencies for the list of library file roots
+        
+        The return set is a dictionary keyed on library root name with values of 1.
+        """
+
+        root_set = {}
+        for root in roots:
+            try:
+                deps = lib_dependencies[root]
+            except KeyError:
+                pass
+            else:
+                root_set[root] = 1
+                root_set.update(dependencies(deps))
+        return root_set
 
     the_dlls = {}
     required_dlls = {}
     for e in extensions:
         if e.name.startswith('COPYLIB_'):
-            the_dlls[e.libraries[0]] = e.library_dirs[0]
+            the_dlls[e.name[8:]] = e.library_dirs[0]
         else:
-            required_dlls.update(dll.dependencies(e.libraries))
+            required_dlls.update(dependencies(e.libraries))
     for lib in required_dlls:
         #next DLL; a distutils bug requires the paths to have Windows separators
         f = the_dlls[lib].replace('/', os.sep)