Changeset 7601:9546de5282e1


Ignore:
Timestamp:
12/10/07 15:40:24 (5 years ago)
Author:
mabshoff@…
Branch:
default
Message:

Revert #1366, #1453 due to problems with "sage -ba"

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • .hgignore

    r7564 r7601  
    114114^c_lib/.sconsign.dblite$ 
    115115^c_lib/libcsage.so$ 
    116 ^.cython_dependencies$ 
  • setup.py

    r7599 r7601  
    99from distutils.extension import Extension 
    1010from Cython.Distutils import build_ext 
     11 
     12 
    1113 
    1214## Choose cblas library -- note -- make sure to update sage/misc/cython.py 
     
    919921###################################################################### 
    920922 
    921 def get_dependencies(filename): 
     923def check_dependencies( filename, outfile ): 
    922924    """ 
    923     computes everything that this file depends on 
     925    INPUT: 
     926        filename -- The name of a .pyx, .pxd, or .pxi to check dependencies in the SAGE source. 
     927        outfile -- The output file for which we are determining out-of-date-ness 
     928 
     929    OUTPUT: 
     930        bool -- whether or not outfile must be regenerated. 
    924931    """ 
    925     li = [] 
     932    if is_older(filename, outfile): 
     933        print "\nBuilding %s because it depends on %s."%(outfile, filename) 
     934        return True 
     935 
    926936    # Now we look inside the file to see what it cimports or include. 
    927937    # If any of these files are newer than outfile, we rebuild 
     
    961971        # Check to see if a/b/c/d.pxd exists and is newer than filename. 
    962972        # If so, we have to regenerate outfile.  If not, we're safe. 
    963         A = os.path.normpath(A) 
    964         if os.path.exists(A): 
    965             li.extend(get_dependencies(A)) 
    966             li.append(A) 
     973        if os.path.exists(A) and check_dependencies(A, outfile): 
     974            return True # yep we must rebuild 
    967975 
    968976    # OK, next we move on to include pxi files. 
     
    9921000            A = R # restore 
    9931001        # Finally, check to see if filename is older than A 
    994         A = os.path.normpath(A) 
    995         if os.path.exists(A): 
    996             li.extend(get_dependencies(A)) 
    997             li.append(A) 
    998              
    999     # if we get here, this file depends on nothing 
    1000     return li 
    1001  
    1002 def check_dependencies(filename, outfile, deps_of): 
    1003     """ 
    1004     INPUT: 
    1005         filename -- The name of a .pyx, .pxd, or .pxi to check dependencies in the SAGE source. 
    1006         outfile -- The output file for which we are determining out-of-date-ness 
    1007  
    1008     OUTPUT: 
    1009         bool -- whether or not outfile must be regenerated. 
    1010     """ 
    1011     # add filename to depend on filename 
    1012     try: 
    1013         deps = deps_of[filename] 
    1014     except KeyError: 
    1015         return True 
    1016  
    1017     for dep in deps: 
    1018         if is_older(dep, outfile): 
    1019             print "\nBuilding %s because it depends on %s."%(outfile, dep) 
     1002        if os.path.exists(A) and check_dependencies(A, outfile): 
    10201003            return True 
    10211004 
    1022 def need_to_cython(filename, outfile, deps): 
     1005 
     1006def need_to_cython(filename, outfile): 
    10231007    """ 
    10241008    INPUT: 
    10251009        filename -- The name of a cython file in the SAGE source tree. 
    10261010        outfile -- The name of the corresponding c or cpp file in the build directory. 
    1027         deps -- a structure containing dependency information 
    10281011 
    10291012    OUTPUT: 
     
    10341017    pxd = base+'.pxd' 
    10351018 
    1036     if check_dependencies(filename, outfile, deps): 
     1019    if check_dependencies(filename, outfile): 
    10371020        return True 
    1038     if os.path.exists(pxd) and check_dependencies(pxd, outfile, deps): 
     1021    elif os.path.exists(pxd) and check_dependencies(pxd, outfile): 
    10391022        return True 
    1040     return False 
    1041  
    1042 def process_cython_file(f, m, deps_of): 
     1023    else: 
     1024        return False 
     1025 
     1026def process_cython_file(f, m): 
    10431027    """ 
    10441028    INPUT: 
     
    10481032    # This is a cython file, so process accordingly. 
    10491033    pyx_inst_file = '%s/%s'%(SITE_PACKAGES, f) 
    1050     # if f is *more recent* than the pyx_install_file 
    10511034    if is_older(f, pyx_inst_file): 
    10521035        print "%s --> %s"%(f, pyx_inst_file) 
    10531036        os.system('cp %s %s 2>/dev/null'%(f, pyx_inst_file)) 
    1054         # we need to recompute the dependencies, here 
    1055         deps_list = get_dependencies(f) 
    1056         try: 
    1057             deps_of[f].extend(deps_list) 
    1058         except KeyError: 
    1059             deps_of[f] = deps_list 
    10601037    outfile = f[:-4] + ".c" 
    10611038    if m.language == 'c++': 
    10621039        outfile += 'pp' 
    10631040 
    1064     if need_to_cython(f, outfile, deps_of): 
     1041    if need_to_cython(f, outfile): 
    10651042        # Insert the -o parameter to specify the output file (particularly for c++) 
    1066         cmd = "cython --embed-positions --incref-local-binop -I%s -o %s %s"%(os.getcwd(), outfile, f ) 
     1043        cmd = "cython --embed-positions --incref-local-binop -I%s -o %s %s"%(os.getcwd(), outfile, f) 
    10671044        print cmd 
    10681045        ret = os.system(cmd) 
     
    10701047            print "sage: Error running cython." 
    10711048            sys.exit(1) 
    1072  
    10731049    return [outfile] 
    10741050     
    10751051 
    10761052def cython(ext_modules): 
    1077     import pickle 
    1078     deps_filename = SAGE_DEVEL + 'sage/.cython_dependencies' 
    1079     # check if the cached dependency information is there 
    1080     if os.path.exists(deps_filename): 
    1081         deps_file = open(deps_filename, 'r') 
    1082         deps_of = pickle.load(deps_file) 
    1083         deps_file.close() 
    1084         deps_file = None 
    1085         compute_all_deps = False 
    1086     else: 
    1087         compute_all_deps = True 
    1088         deps_of = {} 
    1089  
    1090     tot = 0 
    10911053    for m in ext_modules: 
    10921054        m.extra_compile_args += extra_compile_args 
     
    10951057        for i in range(len(m.sources)): 
    10961058            f = m.sources[i] 
    1097             if compute_all_deps: 
    1098                 deps_list = get_dependencies(f) 
    1099                 try: 
    1100                     deps_of[f].extend(deps_list) 
    1101                 except KeyError: 
    1102                     deps_of[f] = deps_list 
    1103                 pxd_file = f[:-4] + '.pxd' 
    1104                 if os.path.exists(pxd_file): 
    1105                     deps_list = get_dependencies(pxd_file) 
    1106                     try: 
    1107                         deps_of[pxd_file].extend(deps_list) 
    1108                     except KeyError: 
    1109                         deps_of[pxd_file] = deps_list 
    1110  
     1059#            s = open(f).read() 
    11111060            if f[-4:] == ".pyx": 
    1112                 # run cython, to output the corresponding c/cpp file, 
    1113                 # if needed 
    1114                 new_sources += process_cython_file(f, m, deps_of) 
     1061                new_sources += process_cython_file(f, m) 
    11151062            else: 
    11161063                new_sources.append(f) 
    1117  
    11181064        m.sources = new_sources 
    1119         tot +=  len(m.sources) 
    1120  
    1121     # now cache the dependencies if we just computed them 
    1122     deps_file = open(deps_filename, 'w') 
    1123     pickle.dump(deps_of, deps_file) 
    1124     deps_file.close() 
     1065 
     1066         
    11251067 
    11261068if not sdist: 
Note: See TracChangeset for help on using the changeset viewer.