提交 93493fc4 authored 作者: Frederic Bastien's avatar Frederic Bastien

whitespace/indentation fix.

上级 7c23cdd8
"""Generate and compile C modules for Python,
"""Generate and compile C modules for Python,
"""
import os, tempfile, StringIO, sys, logging, subprocess, cPickle, atexit, time, shutil, stat
import distutils.sysconfig
......@@ -219,8 +219,8 @@ class ModuleCache(object):
will be deleted in an atexit() handler.
If the ``version`` is neither 0 nor (), then the module will be kept in the cache between
processes.
An unversioned module is not deleted by the process that creates it. Deleting such modules
does not work on NFS filesystems because the tmpdir in which the library resides is in use
until the end of the process' lifetime. Instead, unversioned modules are left in their
......@@ -233,7 +233,7 @@ class ModuleCache(object):
module_from_name = {}
"""maps a module filename to the loaded module object"""
entry_from_key = {}
"""Maps keys to the filename of a .so/.pyd.
"""
......@@ -261,7 +261,7 @@ class ModuleCache(object):
self.entry_from_key = dict(self.entry_from_key)
self.stats = [0, 0, 0]
if force_fresh is not None:
self.force_fresh = force_fresh
self.force_fresh = force_fresh
self.loaded_key_pkl = set()
self.refresh()
......@@ -363,7 +363,7 @@ class ModuleCache(object):
gone = True
if gone:
# assert that we didn't have one of the deleted files
# loaded up and in use.
# loaded up and in use.
# If so, it should not have been deleted. This should be considered a
# failure of the OTHER process, that deleted it.
if entry in self.module_from_name:
......@@ -484,7 +484,7 @@ class ModuleCache(object):
seconds ago will be erased.
"""
if age_thresh_del is None:
age_thresh_del = self.age_thresh_del
age_thresh_del = self.age_thresh_del
compilelock.get_lock()
try:
......@@ -497,7 +497,7 @@ class ModuleCache(object):
# the .items() is important here:
# we need to get a copy of the whole list of keys and entries
items_copy = list(self.entry_from_key.iteritems())
for key, entry in items_copy+too_old_to_use:
for key, entry in items_copy+too_old_to_use:
age = time_now - last_access_time(entry)
if age > age_thresh_del:
# TODO: we are assuming that modules that haven't been accessed in over
......@@ -526,7 +526,7 @@ class ModuleCache(object):
filesystem.
"""
items_copy = list(self.entry_from_key.iteritems())
for key, entry in items_copy:
for key, entry in items_copy:
version, rest = key
if not version:
del self.entry_from_key[key]
......@@ -535,13 +535,13 @@ class ModuleCache(object):
# because an unversioned entry should never have been loaded via refresh
assert entry in self.module_from_name
del self.module_from_name[entry]
del self.module_from_name[entry]
parent = os.path.dirname(entry)
assert parent.startswith(os.path.join(self.dirname, 'tmp'))
info("clear_unversioned removing cache dir", parent)
_rmtree(parent)
time_now = time.time()
for filename in os.listdir(self.dirname):
if filename.startswith('tmp'):
......@@ -658,9 +658,9 @@ def gcc_module_compile_str(module_name, src_code, location=None, include_dirs=[]
#TODO: Do not do the dlimport in this function
if preargs is None:
preargs = []
preargs = []
else:
preargs = list(preargs)
preargs = list(preargs)
if sys.platform != 'win32':
# Under Windows it looks like fPIC is useless. Compiler warning:
......@@ -668,7 +668,7 @@ def gcc_module_compile_str(module_name, src_code, location=None, include_dirs=[]
preargs.append('-fPIC')
no_opt = False
include_dirs = include_dirs + std_include_dirs()
include_dirs = include_dirs + std_include_dirs()
libs = std_libs() + libs
lib_dirs = std_lib_dirs() + lib_dirs
if sys.platform == 'win32':
......@@ -684,7 +684,7 @@ def gcc_module_compile_str(module_name, src_code, location=None, include_dirs=[]
python_inc = distutils.sysconfig.get_python_inc()
libname = os.path.basename(python_inc)
#DSE Patch 1 for supporting OSX frameworks; add -framework Python
#DSE Patch 1 for supporting OSX frameworks; add -framework Python
if sys.platform=='darwin' :
preargs.extend(['-undefined','dynamic_lookup'])
# link with the framework library *if specifically requested*
......@@ -698,11 +698,11 @@ def gcc_module_compile_str(module_name, src_code, location=None, include_dirs=[]
preargs.extend(['-m%s' % n_bits])
debug("OS X: compiling for %s bit architecture" % n_bits)
# sometimes, the linker cannot find -lpython so we need to tell it
# sometimes, the linker cannot find -lpython so we need to tell it
# explicitly where it is located
# this returns somepath/lib/python2.x
python_lib = distutils.sysconfig.get_python_lib(plat_specific=1, \
standard_lib=1)
standard_lib=1)
python_lib = os.path.dirname(python_lib)
if python_lib not in lib_dirs:
lib_dirs.append(python_lib)
......@@ -732,7 +732,7 @@ def gcc_module_compile_str(module_name, src_code, location=None, include_dirs=[]
#print >> sys.stderr, config.gcc.cxxflags.split(' ')
cmd.extend(cxxflags)
cmd.extend('-I%s'%idir for idir in include_dirs)
cmd.extend(['-o',lib_filename])
cmd.extend(['-o',lib_filename])
cmd.append(cppfilename)
cmd.extend(['-L%s'%ldir for ldir in lib_dirs])
cmd.extend(['-l%s'%l for l in libs])
......@@ -757,4 +757,3 @@ def gcc_module_compile_str(module_name, src_code, location=None, include_dirs=[]
def icc_module_compile_str(*args):
raise NotImplementedError()
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论