mercurial/packagescan.py
changeset 1312 c9cf171f30dd
parent 1308 2073e5a71008
child 1841 7f12a63568ae
equal deleted inserted replaced
1307:3b717f27ffea 1312:c9cf171f30dd
     1 # packagescan.py - Helper module for identifing used modules. 
     1 # packagescan.py - Helper module for identifing used modules.
     2 # Used for the py2exe distutil.
     2 # Used for the py2exe distutil.
     3 #
     3 #
     4 # Copyright 2005 Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
     4 # Copyright 2005 Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
     5 #
     5 #
     6 # This software may be used and distributed according to the terms
     6 # This software may be used and distributed according to the terms
    24     """ helper for finding all required modules of package <packagename> """
    24     """ helper for finding all required modules of package <packagename> """
    25     # Use the package in the build directory
    25     # Use the package in the build directory
    26     libpath = os.path.abspath(libpath)
    26     libpath = os.path.abspath(libpath)
    27     sys.path.insert(0,libpath)
    27     sys.path.insert(0,libpath)
    28     packdir = os.path.join(libpath,packagename)
    28     packdir = os.path.join(libpath,packagename)
    29     # A normal import would not find the package in 
    29     # A normal import would not find the package in
    30     # the build directory. ihook is used to force the import.
    30     # the build directory. ihook is used to force the import.
    31     # After the package is imported the import scope for 
    31     # After the package is imported the import scope for
    32     # the following imports is settled.
    32     # the following imports is settled.
    33     p = importfrom(packdir)
    33     p = importfrom(packdir)
    34     globals()[packagename] = p
    34     globals()[packagename] = p
    35     sys.modules[packagename] = p
    35     sys.modules[packagename] = p
    36     # Fetch the python modules in the package
    36     # Fetch the python modules in the package
    44     # Import all python modules and by that run the fake demandload
    44     # Import all python modules and by that run the fake demandload
    45     for m in pymodulefiles:
    45     for m in pymodulefiles:
    46         if m == '__init__.py': continue
    46         if m == '__init__.py': continue
    47         tmp = {}
    47         tmp = {}
    48         mname,ext = os.path.splitext(m)
    48         mname,ext = os.path.splitext(m)
    49         fullname = packagename+'.'+mname 
    49         fullname = packagename+'.'+mname
    50         __import__(fullname,tmp,tmp)
    50         __import__(fullname,tmp,tmp)
    51         requiredmodules[fullname] = 1
    51         requiredmodules[fullname] = 1
    52     # Import all extension modules and by that run the fake demandload
    52     # Import all extension modules and by that run the fake demandload
    53     for m in extmodulefiles:
    53     for m in extmodulefiles:
    54         tmp = {}
    54         tmp = {}