Ticket #12659: trac_12659.patch

File trac_12659.patch, 6.0 KB (added by mhansen, 8 years ago)
  • .hgignore

    # HG changeset patch
    # User Mike Hansen <mhansen@gmail.com>
    # Date 1331623300 25200
    # Node ID 8934271cb8daf29820bd9677f099ebeddda10ae8
    # Parent  c239be1054e01526a1b0b62da6691061b9dd5587
    #12659: build the sage library in place
    
    diff --git a/.hgignore b/.hgignore
    a b  
    4141dist
    4242sage/.*\.c$
    4343sage/.*\.cpp$
     44sage/.*\.so$
    4445c_lib/.*\.lo$
    4546c_lib/.*\.os$
    4647c_lib/libcsage.la
  • install

    diff --git a/install b/install
    a b  
    1717PATH=$SAGE_ROOT/local/bin/:$PATH
    1818export PATH
    1919
    20 if [ -n "$SAGE_DEBIAN" ]; then
    21     python setup.py install --root="$SAGE_ROOT/" --no-compile -O0
    22 else
    23     python setup.py install
    24 fi
     20python setup.py build_ext --inplace
    2521
    2622exit $?
    2723
  • setup.py

    diff --git a/setup.py b/setup.py
    a b  
    5252if not os.path.exists(SITE_PACKAGES):
    5353    raise RuntimeError, "Unable to find site-packages directory (see setup.py file in sage python code)."
    5454
    55 if not os.path.exists('build/sage'):
    56     os.makedirs('build/sage')
    5755
    5856sage_link = SITE_PACKAGES + '/sage'
    5957if not os.path.islink(sage_link) or not os.path.exists(sage_link):
    6058    os.system('rm -rf "%s"'%sage_link)
    61     os.system('cd %s; ln -sf ../../../../devel/sage/build/sage .'%SITE_PACKAGES)
     59    os.system('cd %s; ln -sf ../../../../devel/sage/sage .'%SITE_PACKAGES)
    6260
    6361# search for dependencies and add to gcc -I<path>
    6462include_dirs = ['%s/include'%SAGE_LOCAL,
     
    313311from distutils import log
    314312       
    315313class sage_build_ext(build_ext):
    316    
     314
    317315    def build_extensions(self):
    318 
     316        if not self.inplace:
     317            raise RuntimeError, "only in-place builds are currently supported"
    319318        from distutils.debug import DEBUG
    320319
    321320        if DEBUG:
     
    395394                   "a list of source filenames") % ext.name
    396395        sources = list(sources)
    397396
     397        # ignore build-lib -- put the compiled extension into
     398        # the source tree along with pure Python modules
    398399        fullname = self.get_ext_fullname(ext.name)
    399         if self.inplace:
    400             # ignore build-lib -- put the compiled extension into
    401             # the source tree along with pure Python modules
     400        modpath = fullname.split('.')
     401        package = '.'.join(modpath[0:-1])
     402        base = modpath[-1]
    402403
    403             modpath = string.split(fullname, '.')
    404             package = string.join(modpath[0:-1], '.')
    405             base = modpath[-1]
    406 
    407             build_py = self.get_finalized_command('build_py')
    408             package_dir = build_py.get_package_dir(package)
    409             ext_filename = os.path.join(package_dir,
    410                                         self.get_ext_filename(base))
    411             relative_ext_filename = self.get_ext_filename(base)
    412         else:
    413             ext_filename = os.path.join(self.build_lib,
    414                                         self.get_ext_filename(fullname))
    415             relative_ext_filename = self.get_ext_filename(fullname)
    416 
    417         # while dispatching the calls to gcc in parallel, we sometimes
    418         # hit a race condition where two separate build_ext objects
    419         # try to create a given directory at the same time; whoever
    420         # loses the race then seems to throw an error, saying that
    421         # the directory already exists. so, instead of fighting to
    422         # fix the race condition, we simply make sure the entire
    423         # directory tree exists now, while we're processing the
    424         # extensions in serial.
    425         relative_ext_dir = os.path.split(relative_ext_filename)[0]
    426         prefixes = ['', self.build_lib, self.build_temp]
    427         for prefix in prefixes:
    428             path = os.path.join(prefix, relative_ext_dir)
    429             try:
    430                 os.makedirs(path)
    431             except OSError, e:
    432                 assert e.errno==errno.EEXIST, 'Cannot create %s.' % path
     404        build_py = self.get_finalized_command('build_py')
     405        package_dir = build_py.get_package_dir(package)
     406        ext_filename = os.path.join(package_dir,
     407                                    self.get_ext_filename(base))
     408        relative_ext_filename = self.get_ext_filename(base)
     409           
    433410        depends = sources + ext.depends
    434411        if not (self.force or newer_group(depends, ext_filename, 'newer')):
    435412            log.debug("skipping '%s' extension (up-to-date)", ext.name)
     
    742719        cmd = "python `which cython` %s --old-style-globals --disable-function-redefinition --embed-positions --directive cdivision=True,autotestdict=False,fast_getattr=True -I%s -o %s %s"%(cplus, os.getcwd(), outfile, f)
    743720        r = run_command(cmd)
    744721        if r:
    745             return r
    746 
    747         # if cython worked, copy the file to the build directory
    748         pyx_inst_file = '%s/%s'%(SITE_PACKAGES, f)
    749         retval = os.system('cp %s %s 2>/dev/null'%(f, pyx_inst_file))
    750         # we could do this more elegantly -- load the files, use
    751         # os.path.exists to check that they exist, etc. ... but the
    752         # *vast* majority of the time, the copy just works. so this is
    753         # just specializing for the most common use case.
    754         if retval:
    755             dirname, filename = os.path.split(pyx_inst_file)
    756             try:
    757                 os.makedirs(dirname)
    758             except OSError, e:
    759                 assert e.errno==errno.EEXIST, 'Cannot create %s.' % dirname
    760             retval = os.system('cp %s %s 2>/dev/null'%(f, pyx_inst_file))
    761             if retval:
    762                 raise OSError, "cannot copy %s to %s"%(f,pyx_inst_file)
    763         print "%s --> %s"%(f, pyx_inst_file)
    764        
     722            return r       
    765723    elif f.endswith(('.c','.cc','.cpp')):
    766724        # process C/C++ file
    767725        cmd = "touch %s"%f
     
    787745        for f in m.sources:
    788746            if f.endswith('.pyx'):
    789747                dep_file, dep_time = deps.newest_dep(f,m)
    790                 dest_file = "%s/%s"%(SITE_PACKAGES, f)
     748                #We check against the generated file
     749                dest_file = process_filename(f,m)
    791750                dest_time = deps.timestamp(dest_file)
    792751                if dest_time < dep_time:
    793752                    if dep_file == f: