##// END OF EJS Templates
Respect "Connection: close" headers sent by HTTP clients....
Respect "Connection: close" headers sent by HTTP clients. A HTTP client can indicate that it doesn't support (or doesn't want) persistent connections by sending this header. This not only makes the server more compliant with the RFC, but also reduces the run time of test-http-proxy when run with python 2.3 from ~125s to ~5s (it doesn't affect it with python 2.4, which was already ~5s).

File last commit:

r2497:976b6b2a default
r2582:276de216 default
Show More
packagescan.py
125 lines | 4.3 KiB | text/x-python | PythonLexer
Thomas Arendsen Hein
Cleanup of tabs and trailing spaces.
r1308 # packagescan.py - Helper module for identifing used modules.
Volker.Kleinfeld@gmx.de
Support for the distutils extention 'py2exe' added....
r1283 # Used for the py2exe distutil.
Volker Kleinfeld
setup.py: install packagescan before any mercurial modules is imported...
r2323 # This module must be the first mercurial module imported in setup.py
Volker.Kleinfeld@gmx.de
Support for the distutils extention 'py2exe' added....
r1283 #
# Copyright 2005 Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
#
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
import glob
import os
import sys
import ihooks
Volker Kleinfeld
packagescan: handle demandload module naming changes.
r2322 import types
import string
Volker.Kleinfeld@gmx.de
Support for the distutils extention 'py2exe' added....
r1283
Volker Kleinfeld
setup.py: install packagescan before any mercurial modules is imported...
r2323 # Install this module as fake demandload module
sys.modules['mercurial.demandload'] = sys.modules[__name__]
# Requiredmodules contains the modules imported by demandload.
# Please note that demandload can be invoked before the
# mercurial.packagescan.scan method is invoked in case a mercurial
# module is imported.
requiredmodules = {}
Volker.Kleinfeld@gmx.de
Support for the distutils extention 'py2exe' added....
r1283 def demandload(scope, modules):
Volker Kleinfeld
packagescan: handle demandload module naming changes.
r2322 """ fake demandload function that collects the required modules
foo import foo
foo bar import foo, bar
foo.bar import foo.bar
foo:bar from foo import bar
foo:bar,quux from foo import bar, quux
foo.bar:quux from foo.bar import quux"""
Volker.Kleinfeld@gmx.de
Support for the distutils extention 'py2exe' added....
r1283 for m in modules.split():
mod = None
Eung-ju Park
Fix py2exe packagescan problem with new demandload
r1841 try:
Volker Kleinfeld
packagescan: handle demandload module naming changes.
r2322 module, fromlist = m.split(':')
fromlist = fromlist.split(',')
Eung-ju Park
Fix py2exe packagescan problem with new demandload
r1841 except:
module = m
Volker Kleinfeld
packagescan: handle demandload module naming changes.
r2322 fromlist = []
mod = __import__(module, scope, scope, fromlist)
if fromlist == []:
# mod is only the top package, but we need all packages
comp = module.split('.')
i = 1
mn = comp[0]
while True:
# mn and mod.__name__ might not be the same
scope[mn] = mod
requiredmodules[mod.__name__] = 1
if len(comp) == i: break
mod = getattr(mod,comp[i])
mn = string.join(comp[:i+1],'.')
i += 1
else:
# mod is the last package in the component list
requiredmodules[mod.__name__] = 1
for f in fromlist:
scope[f] = getattr(mod,f)
if type(scope[f]) == types.ModuleType:
requiredmodules[scope[f].__name__] = 1
Volker.Kleinfeld@gmx.de
Support for the distutils extention 'py2exe' added....
r1283
Vadim Gelfer
do not try to package lsprof if not available.
r2497 class SkipPackage(Exception):
def __init__(self, reason):
self.reason = reason
scan_in_progress = False
Volker Kleinfeld
setup.py: install packagescan before any mercurial modules is imported...
r2323 def scan(libpath,packagename):
Volker.Kleinfeld@gmx.de
Support for the distutils extention 'py2exe' added....
r1283 """ helper for finding all required modules of package <packagename> """
Vadim Gelfer
do not try to package lsprof if not available.
r2497 global scan_in_progress
scan_in_progress = True
Volker.Kleinfeld@gmx.de
Support for the distutils extention 'py2exe' added....
r1283 # Use the package in the build directory
libpath = os.path.abspath(libpath)
sys.path.insert(0,libpath)
Eung-Ju PARK
packagescan can't scan nested packages
r2402 packdir = os.path.join(libpath,packagename.replace('.', '/'))
Thomas Arendsen Hein
Cleanup of tabs and trailing spaces.
r1308 # A normal import would not find the package in
Volker.Kleinfeld@gmx.de
Support for the distutils extention 'py2exe' added....
r1283 # the build directory. ihook is used to force the import.
Thomas Arendsen Hein
Cleanup of tabs and trailing spaces.
r1308 # After the package is imported the import scope for
Volker.Kleinfeld@gmx.de
Support for the distutils extention 'py2exe' added....
r1283 # the following imports is settled.
p = importfrom(packdir)
globals()[packagename] = p
sys.modules[packagename] = p
# Fetch the python modules in the package
cwd = os.getcwd()
os.chdir(packdir)
pymodulefiles = glob.glob('*.py')
extmodulefiles = glob.glob('*.pyd')
os.chdir(cwd)
# Import all python modules and by that run the fake demandload
for m in pymodulefiles:
if m == '__init__.py': continue
tmp = {}
mname,ext = os.path.splitext(m)
Thomas Arendsen Hein
Cleanup of tabs and trailing spaces.
r1308 fullname = packagename+'.'+mname
Vadim Gelfer
do not try to package lsprof if not available.
r2497 try:
__import__(fullname,tmp,tmp)
except SkipPackage, inst:
print >> sys.stderr, 'skipping %s: %s' % (fullname, inst.reason)
continue
Volker.Kleinfeld@gmx.de
Support for the distutils extention 'py2exe' added....
r1283 requiredmodules[fullname] = 1
# Import all extension modules and by that run the fake demandload
for m in extmodulefiles:
tmp = {}
mname,ext = os.path.splitext(m)
fullname = packagename+'.'+mname
__import__(fullname,tmp,tmp)
requiredmodules[fullname] = 1
Volker Kleinfeld
setup.py: install packagescan before any mercurial modules is imported...
r2323
def getmodules():
return requiredmodules.keys()
Volker.Kleinfeld@gmx.de
Support for the distutils extention 'py2exe' added....
r1283
def importfrom(filename):
"""
import module/package from a named file and returns the module.
It does not check on sys.modules or includes the module in the scope.
"""
loader = ihooks.BasicModuleLoader()
path, file = os.path.split(filename)
name, ext = os.path.splitext(file)
m = loader.find_module_in_dir(name, path)
if not m:
raise ImportError, name
m = loader.load_module(name, m)
return m