Changeset 128

Show
Ignore:
Timestamp:
Mon Sep 26 12:35:41 2005
Author:
williamcaban
Message:

Cleaner port to distutils

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/source/linux/Make.py

    r122 r128  
    35 35 import pprint  
    36 36  
    37    
    38   # NOTE: This is an temporary incomplete fix. Distutils should be used to get all the values  
    39   # of all these variable to make it more portable.  
    40   # (William Caban will work on completing this during the next few days)  
    41 37 try:  
    42           import distutils.sysconfig  
      38         from distutils import sysconfig  
    42 38 except:  
    43           print "ERROR: distutils required"  
      39         print "ERROR: distutils with sysconfig required"  
    43 39         sys.exit(1)  
    44 40  
     
    58 54          sys.platform[:3] == 'win' or  
    59 55          sys.platform[:7] == 'freebsd' or  
      56          sys.platform[:7] == 'darwin' or  
    60 57          sys.platform[:6] == 'cygwin' ):  
    61 58         non_elf = 0                         # settable with -n option  
     
    84 81             exec_prefix = prefix  
    85 82         else:  
    86               exec_prefix = sys.exec_prefix  
      83             exec_prefix = sysconfig.EXEC_PREFIX  
    86 83     if not prefix:  
    87           prefix = sys.prefix  
      84         prefix = sysconfig.PREFIX  
    87 84     # determine whether -p points to the Python source tree  
    88 85     ishome = os.path.exists(os.path.join(prefix, 'Python', 'ceval.c'))  
    89 86     cygwin = sys.platform == 'cygwin'  
      87     darwin = sys.platform[:7] == 'darwin'  
    90 88  
    91 89     if ishome:  
     
    98 96         makefile_in = os.path.join(exec_prefix, 'Modules', 'Makefile')  
    99 97     else:  
    100           if cygwin:  
    101               binlib = os.path.join('/lib', 'python%s' % sys.version[:3], 'config')  
    102           else:  
    103               binlib = os.path.join (distutils.sysconfig.get_python_lib(True, True, exec_prefix), 'config')  
      98         binlib = os.path.join (sysconfig.get_python_lib(True, True, exec_prefix), 'config')  
    104 99         # TODO: Is it possible to have more than one path returned? if so fix "includes" list  
    105           incldir =  distutils.sysconfig.get_config_vars('INCLUDEDIR')[0]  
    106           config_h_dir =  os.path.join (distutils.sysconfig.get_python_inc(True,exec_prefix))  
    107           makefile_in = distutils.sysconfig.get_makefile_filename()  
      100         incldir_list =  sysconfig.get_config_vars('INCLUDEDIR')  
      101         includes = []  
      102         for dir in incldir_list:  
      103                 if dir != None:  
      104                         includes.append('-I' + dir)  
      105         config_h_dir =  os.path.join (sysconfig.get_python_inc(True,exec_prefix))  
      106         includes.append('-I' + config_h_dir)  
      107         makefile_in = sysconfig.get_makefile_filename()  
    108 108  
    109 109     # salt config.dat with the exe type  
     
    121 121     targets[1] = os.path.join('../../support/loader/', 'run_d')  
    122 122  
    123       includes = ['-I../common', '-I' + incldir, '-I' + config_h_dir]  
      123     # include local 'common' dir  
      124     includes.append('-I../common')  
    124 125  
    125 126     have_warnings = 0  
     
    148 149         outfp.close()  
    149 150  
    150       cflags = includes + ['$(OPT)']  
      151     includes.append('$(OPT)')  
      152     cflags = includes  
      153     cflags.append(sysconfig.get_config_vars('CFLAGS')[0]) #save sysconfig CFLAGS  
      154  
    151 155     if have_warnings:  
    152 156         cflags.append('-DHAVE_WARNINGS')  
     
    156 160     if non_elf:  
    157 161         cflags.append('-DNONELF')  
    158       if cygwin:  
    159           libs = [os.path.join(binlib, 'libpython$(VERSION).dll.a')]  
    160       else:  
    161           libs = [os.path.join(binlib, 'libpython$(VERSION).a')]  
      162  
      163     libs = [os.path.join(binlib, sysconfig.get_config_vars('INSTSONAME')[0])]  
    162 164  
    163 165     somevars = {}  
    164 166     if os.path.exists(makefile_in):  
    165           makevars = parsesetup.getmakevars(makefile_in)  
      167         makevars = sysconfig.parse_makefile(makefile_in)  
    165 167     else:  
    166 168         raise ValueError, "Makefile '%s' not found" % makefile_in