コード例 #1
0
 def find_module(self, fullname, path=None):
     # Python's default import implementation doesn't handle builtins with '.' in them well, so we handle them here
     # as well.
     # We allow freeze_overrides to give prefixes that although may be frozen we'll skip so they can be found in
     # the PYTHONPATH - this is good for development.
     if (not any(fullname.startswith(override) for override in freeze_overrides)) and \
        (imp.is_frozen('freezer_package.' + fullname) or imp.is_frozen('freezer.' + fullname) or
             (fullname.find('.') != -1 and imp.is_builtin(fullname))):
         return self
     else:
         return None
コード例 #2
0
def main_is_frozen():
    """Returns True if maijn function is frozen
    (e.g. PyInstaller/Py2Exe executable)
    """
    return (hasattr(sys, "frozen") or  # new py2exe
            hasattr(sys, "importers") or  # old py2exe
            imp.is_frozen("__main__"))  # tools/freeze
コード例 #3
0
ファイル: common.py プロジェクト: jmrbcu/foundation
def main_is_frozen():
    """Return True if we are running from an executable, False otherwise"""
    return (
        hasattr(sys, 'frozen') or  # new py2exe
        hasattr(sys, 'importers') or  # old py2exe
        imp.is_frozen('__main__')  # tools/freeze
    )
コード例 #4
0
    def loadUi(self, ui):
        """
        desc:
            Dynamically loads a UI file.
            
        arguments:
            ui:
                desc:   The name of a UI file, which should match.
                        libqnotero/ui/[name].ui
                type:   str
        """

        path = os.path.dirname(__file__)
        # If we are running from a frozen state (i.e. packaged by py2exe), we
        # need to find the UI files relative to the executable directory,
        # because the modules are packaged into library.zip.
        if os.name == 'nt':
            import imp
            import sys
            if (hasattr(sys, 'frozen') or hasattr(sys, 'importers') or \
                imp.is_frozen('__main__')):
                path = os.path.join(os.path.dirname(sys.executable),
                                    'libqnotero')
        uiPath = os.path.join(path, 'ui', '%s.ui' % ui)
        self.ui = uic.loadUi(uiPath, self)
コード例 #5
0
ファイル: uiloader.py プロジェクト: Coshibu/qnotero
    def loadUi(self, ui):
        
        """
        desc:
            Dynamically loads a UI file.
            
        arguments:
            ui:
                desc:   The name of a UI file, which should match.
                        libqnotero/ui/[name].ui
                type:   str
        """

        path = os.path.dirname(__file__)
        # If we are running from a frozen state (i.e. packaged by py2exe), we
        # need to find the UI files relative to the executable directory,
        # because the modules are packaged into library.zip.
        if os.name == 'nt':
            import imp
            import sys
            if (hasattr(sys, 'frozen') or hasattr(sys, 'importers') or \
                imp.is_frozen('__main__')):
                path = os.path.join(os.path.dirname(sys.executable),
                    'libqnotero')
        uiPath = os.path.join(path, 'ui', '%s.ui' % ui)
        self.ui = uic.loadUi(uiPath, self)
コード例 #6
0
def get_main_dir():
    '''Returns the directory name of the script or the directory name of the exe if py2exe was used
    Code from http://www.py2exe.org/index.cgi/HowToDetermineIfRunningFromExe
    '''
    if (hasattr(sys, "frozen") or hasattr(sys, "importers") or imp.is_frozen("__main__")):
        return os.path.dirname(sys.executable)
    return os.path.dirname(sys.argv[0])
コード例 #7
0
def main_is_frozen():
    """ main_is_frozen() -> bool
    Returns True when running the exe, or False when running from a script. 
    """
    return (hasattr(sys, "frozen") or # new py2exe
            hasattr(sys, "importers") # old py2exe
            or imp.is_frozen("__main__")) # tools/freeze
コード例 #8
0
ファイル: appconfig.py プロジェクト: KarolBedkowski/mna
def is_frozen():
    """ Check if application is frozen. """
    if __file__.startswith(sys.prefix):
        return True
    return (hasattr(sys, "frozen")      # new py2exe
            or hasattr(sys, "importers")        # old py2exe
            or imp.is_frozen("__main__"))       # tools/freeze
コード例 #9
0
ファイル: utility_path.py プロジェクト: hermanwu/jira-status
def main_is_frozen():
    """
  Determine if the main script is frozen.
  """
    return (hasattr(sys, "frozen") or  # new py2exe
            hasattr(sys, "importers")  # old py2exe
            or imp.is_frozen("__main__"))  # tools/freeze
コード例 #10
0
ファイル: ihooks.py プロジェクト: webiumsk/WOT-0.9.15.1
 def find_builtin_module(self, name):
     if imp.is_builtin(name):
         return (None, '', ('', '', BUILTIN_MODULE))
     elif imp.is_frozen(name):
         return (None, '', ('', '', FROZEN_MODULE))
     else:
         return None
コード例 #11
0
ファイル: misc.py プロジェクト: kiistala/OpenSesame
def opensesame_folder():
    """
	Determines the folder that contains the OpenSesame executable. This is only
	applicable under Windows.

	Returns:
	The OpenSesame folder or None if the os is not Windows.
	"""

    if os.name != u'nt':
        return None
    # Determines the directory name of the script or the directory name
    # of the executable after being packaged with py2exe. This has to be
    # done so the child process can find all relevant modules too.
    # See http://www.py2exe.org/index.cgi/HowToDetermineIfRunningFromExe
    #
    # There are two scenarios: Either OpenSesame is run from a frozen state,
    # in which case the OpenSesame folder is the folder containing the
    # executable, or OpenSesame is run from source, in which case we go to
    # the OpenSesame folder by going two levels up from the __file__ folder.
    import imp
    if (hasattr(sys, u'frozen') or hasattr(sys, u'importers') or \
     imp.is_frozen(u'__main__')):
        path = os.path.dirname(sys.executable).decode( \
         sys.getfilesystemencoding())
    else:
        # To get the opensesame folder, simply jump to levels up
        path = os.path.dirname(__file__).decode( \
         sys.getfilesystemencoding())
        path = os.path.normpath(os.path.join(path, u'..'))
    return path
コード例 #12
0
 def find_builtin_module(self, name):
     if imp.is_builtin(name):
         return (None, '', ('', '', BUILTIN_MODULE))
     else:
         if imp.is_frozen(name):
             return (None, '', ('', '', FROZEN_MODULE))
         return None
コード例 #13
0
ファイル: access.py プロジェクト: AlecChou/ldoce5viewer
def _load_static_data(filename):
    """Load a static file from the 'static' directory"""

    is_frozen = (hasattr(sys, 'frozen')  # new py2exe
                 or imp.is_frozen('__main__'))  # tools/freeze

    if is_frozen:
        if sys.platform.startswith("darwin"):
            path = os.path.join(os.path.dirname(sys.executable),
                                "../Resources",
                                STATIC_REL_PATH, filename)
        else:
            path = os.path.join(os.path.dirname(sys.executable),
                                STATIC_REL_PATH, filename)
        with open(path, 'rb') as f:
            data = f.read()
    else:
        try:
            from pkgutil import get_data as _get
        except ImportError:
            from pkg_resources import resource_string as _get

        data = _get(basepkgname, os.path.join(STATIC_REL_PATH, filename))

    if filename.endswith('.css'):
        s = data.decode('utf-8')
        s = fontfallback.css_replace_fontfamily(s)
        data = s.encode('utf-8')
    elif filename.endswith('.html'):
        s = data.decode('utf-8')
        s = s.replace('{% current_version %}', __version__)
        data = s.encode('utf-8')

    return data
コード例 #14
0
    def process_template(self, template_path, dest_filename):
        """
        Generates a file from a template.
        """
        domain_name_escaped = self.domain_name.replace(".", "\\.")
        template = pkg_resources.resource_string("reviewboard", template_path)
        sitedir = os.path.abspath(self.install_dir).replace("\\", "/")

        # Check if this is a .exe.
        if (hasattr(sys, "frozen") or    # new py2exe
            hasattr(sys, "importers") or # new py2exe
            imp.is_frozen("__main__")):  # tools/freeze
            rbsite_path = sys.executable
        else:
            rbsite_path = '"%s" "%s"' % (sys.executable, sys.argv[0])

        data = {
            'rbsite': rbsite_path,
            'sitedir': sitedir,
            'sitedomain': self.domain_name,
            'sitedomain_escaped': domain_name_escaped,
            'siteid': self.site_id,
        }

        template = re.sub("@([a-z_]+)@", lambda m: data.get(m.group(1)),
                          template)

        fp = open(dest_filename, "w")
        fp.write(template)
        fp.close()
コード例 #15
0
def get_exe_dir():
    import imp, sys
    if (getattr(sys, "frozen", False) or # new py2exe
            hasattr(sys, "importers") # old py2exe
            or imp.is_frozen("__main__")): # tools/freeze
        return os.path.dirname(sys.executable)
    return None
コード例 #16
0
ファイル: access.py プロジェクト: rubyu/ldoce5viewer
def _load_static_data(filename):
    """Load a static file from the 'static' directory"""

    is_frozen = (
        hasattr(sys, 'frozen')  # new py2exe
        or imp.is_frozen('__main__'))  # tools/freeze

    if is_frozen:
        if sys.platform.startswith("darwin"):
            path = os.path.join(os.path.dirname(sys.executable),
                                "../Resources", STATIC_REL_PATH, filename)
        else:
            path = os.path.join(os.path.dirname(sys.executable),
                                STATIC_REL_PATH, filename)
        with open(path, 'rb') as f:
            data = f.read()
    else:
        try:
            from pkgutil import get_data as _get
        except ImportError:
            from pkg_resources import resource_string as _get

        data = _get(basepkgname, os.path.join(STATIC_REL_PATH, filename))

    if filename.endswith('.css'):
        s = data.decode('utf-8')
        s = fontfallback.css_replace_fontfamily(s)
        data = s.encode('utf-8')
    elif filename.endswith('.html'):
        s = data.decode('utf-8')
        s = s.replace('{% current_version %}', __version__)
        data = s.encode('utf-8')

    return data
コード例 #17
0
ファイル: ihooks.py プロジェクト: IamMomotaros/grailbrowser
 def find_builtin_module(self, name):
     # XXX frozen packages?
     if imp.is_builtin(name):
         return None, '', ('', '', BUILTIN_MODULE)
     if imp.is_frozen(name):
         return None, '', ('', '', FROZEN_MODULE)
     return None
コード例 #18
0
def main_is_frozen():
    """ Return T if running from an exe, F otherwise
    """
    return (hasattr(sys, "frozen")  # new py2exe
            or hasattr(sys, "importers")  # old py2exe
            or imp.is_frozen("__main__")  # tools/freeze
            or os.path.isfile(sys.path[0]))  # cxfreeze
コード例 #19
0
def main_is_frozen():
    """ Return T if running from an exe, F otherwise
    """
    return (hasattr(sys, "frozen")  # new py2exe
           or hasattr(sys, "importers") # old py2exe
           or imp.is_frozen("__main__") # tools/freeze
            or os.path.isfile(sys.path[0])) # cxfreeze
コード例 #20
0
def main_is_frozen():
	"Return True if it runs from a frozen script (py2exe, cx_Freeze...)"
	return (
		hasattr(sys, "frozen") or    # new py2exe
		hasattr(sys, "importers") or # old py2exe
		imp.is_frozen("__main__")    # tools/freeze
	)
コード例 #21
0
ファイル: ihooks.py プロジェクト: zbx91/PyDataBindUI
 def find_builtin_module(self, name):
     # XXX frozen packages?
     if imp.is_builtin(name):
         return None, '', ('', '', BUILTIN_MODULE)
     if imp.is_frozen(name):
         return None, '', ('', '', FROZEN_MODULE)
     return None
コード例 #22
0
ファイル: utilities.py プロジェクト: msarch/py
def run_as_app():
    """ returns True when running the exe, and False when running from a script. -> boolean
    """
    import imp, sys
    return (hasattr(sys, "frozen") or  # new py2exe
            hasattr(sys, "importers")  # old py2exe
            or imp.is_frozen("__main__"))  # tools/freeze
コード例 #23
0
ファイル: utilities.py プロジェクト: msarch/py
def run_as_app():
    """ returns True when running the exe, and False when running from a script. -> boolean
    """
    import imp, sys
    return (hasattr(sys, "frozen") or # new py2exe
        hasattr(sys, "importers") # old py2exe
            or imp.is_frozen("__main__") ) # tools/freeze
コード例 #24
0
ファイル: micro.py プロジェクト: wty0512/micropylis
def mainIsFrozen():
    '''
        Returns True if running from .exe
    '''
    return (hasattr(sys, "frozen") or # new py2exe
            hasattr(sys, "importers") # old py2exe
            or imp.is_frozen("__main__")) # tools/freeze
コード例 #25
0
ファイル: misc.py プロジェクト: amandinerey/OpenSesame
def opensesame_folder():

	"""
	Determines the folder that contains the OpenSesame executable. This is only
	applicable under Windows.

	Returns:
	The OpenSesame folder or None if the os is not Windows.
	"""
	# Determines the directory name of the script or the directory name
	# of the executable after being packaged with py2exe. This has to be
	# done so the child process can find all relevant modules too.
	# See http://www.py2exe.org/index.cgi/HowToDetermineIfRunningFromExe
	#
	# There are two scenarios: Either OpenSesame is run from a frozen state,
	# in which case the OpenSesame folder is the folder containing the
	# executable, or OpenSesame is run from source, in which case we go to
	# the OpenSesame folder by going two levels up from the __file__ folder.
	if platform.system() == u'Darwin':
		return os.getcwd()
	elif platform.system() == u'Windows':
		import imp
		if (hasattr(sys, u'frozen') or hasattr(sys, u'importers') or \
			imp.is_frozen(u'__main__')):
			path = safe_decode(os.path.dirname(sys.executable),
				enc=sys.getfilesystemencoding())
		else:
			# To get the opensesame folder, simply jump to levels up
			path = safe_decode(os.path.dirname(__file__),
				enc=sys.getfilesystemencoding())
			path = os.path.normpath(os.path.join(path, u'..'))
		return path
	else:
		return None
コード例 #26
0
def vfp_sys(funcnum, *args):
    if funcnum == 16:
        import imp
        if hasattr(sys, "frozen") or hasattr(
                sys, "importers") or imp.is_frozen("__main__"):
            return os.path.dirname(sys.executable)
        return os.path.dirname(sys.argv[0])
コード例 #27
0
ファイル: scripting.py プロジェクト: scijava/bioimagexd
def main_is_frozen():
    """
	Checks if the application is "frozen", ie. packaged with py2exe for windows, py2app for mac or freeze for linux.
	"""
    return (hasattr(sys, "frozen") or  # new py2exe
            hasattr(sys, "importers")  # old py2exe
            or imp.is_frozen("__main__"))  # tools/freeze
コード例 #28
0
def main_is_frozen():
	"""
	Checks if the application is "frozen", ie. packaged with py2exe for windows, py2app for mac or freeze for linux.
	"""
	return (hasattr(sys, "frozen") or # new py2exe
			hasattr(sys, "importers") # old py2exe
			or imp.is_frozen("__main__")) # tools/freeze
コード例 #29
0
def get_program_path():
    if hasattr(sys, "frozen") or imp.is_frozen("__main__"):
        return os.path.dirname(sys.executable)
    else:
        try:
            return os.path.dirname(__file__)
        except NameError:
            return os.path.dirname(sys.argv[0])
コード例 #30
0
def main_is_frozen():
    """
    Return True if we are running in a py2exe environment, else
    return False
    """
    return (hasattr(sys, "frozen") or  # new py2exe
            hasattr(sys, "importers") or  # old py2exe
            imp.is_frozen("__main__"))  # tools/freeze
コード例 #31
0
ファイル: dhnio.py プロジェクト: vesellov/datahaven
def main_is_frozen():
    """
    Return True if DataHaven.NET is started from .exe not from sources.
        http://www.py2exe.org/index.cgi/HowToDetermineIfRunningFromExe
    """
    return (hasattr(sys, "frozen") or       # new py2exe
            hasattr(sys, "importers") or    # old py2exe
            imp.is_frozen("__main__"))      # tools/freeze
コード例 #32
0
def main_is_frozen():
    """
    Return True if we are running in a py2exe environment, else
    return False
    """
    return (hasattr(sys, "frozen") or # new py2exe
            hasattr(sys, "importers") or # old py2exe
            imp.is_frozen("__main__")) # tools/freeze
コード例 #33
0
def get_main_dir():
    '''Returns the directory name of the script or the directory name of the exe if py2exe was used
    Code from http://www.py2exe.org/index.cgi/HowToDetermineIfRunningFromExe
    '''
    if (hasattr(sys, "frozen") or hasattr(sys, "importers")
            or imp.is_frozen("__main__")):
        return os.path.dirname(sys.executable)
    return os.path.dirname(sys.argv[0])
コード例 #34
0
ファイル: patcher.py プロジェクト: L0FKA/PyPatcher
 def _isFrozen(self):
     """
     This should return true if the program that is being run is a compiled
     exe
     """
     return (hasattr(sys, "frozen") # new py2exe
             or hasattr(sys, "importers") # old py2exe
             or imp.is_frozen("__main__")) # tools/freeze
def main_is_frozen():
    """Return ``True`` if we're running from a frozen program."""
    import imp
    return (
        # new py2exe
        hasattr(sys, "frozen") or
        # tools/freeze
        imp.is_frozen("__main__"))
コード例 #36
0
ファイル: itrade_config.py プロジェクト: amremam2004/itrade
def main_is_frozen():
    if sys.platform == 'darwin':
        # this is a temporary hack for bundlebuilder
        return not sys.executable == '/System/Library/Frameworks/Python.framework/Versions/2.3/Resources/Python.app/Contents/MacOS/Python'
    else:
        return (hasattr(sys, "frozen") or # new py2exe, McMillan
                hasattr(sys, "importers") # old py2exe
                or imp.is_frozen("__main__")) # tools/freeze, cx_freeze
コード例 #37
0
ファイル: util.py プロジェクト: 3kings/Minecraft-Overviewer
def get_program_path():
    if hasattr(sys, "frozen") or imp.is_frozen("__main__"):
        return os.path.dirname(sys.executable)
    else:
        try:
            return os.path.dirname(__file__)
        except NameError:
            return os.path.dirname(sys.argv[0])
コード例 #38
0
ファイル: ToolDir.py プロジェクト: chinatjnet/python-scripts
def main_is_frozen():
    """Return ``True`` if we're running from a frozen program."""
    import imp
    return (
        # new py2exe
        hasattr(sys, "frozen") or
        # tools/freeze
        imp.is_frozen("__main__"))
コード例 #39
0
ファイル: __init__.py プロジェクト: justincbagley/pasta
def pasta_is_frozen():
    """Will return True if PASTA is frozen.
    """
    import imp
    return (hasattr(sys, "frozen")  # new py2exe
            or hasattr(sys, "importers")  # old py2exe
            or imp.is_frozen("__main__")  # tools/freeze
            )
コード例 #40
0
def isExe ():
    """
    Indicates whether the execution is exe with py2exe or. py with the Python interpreter

    @return:
    @rtype: boolean
    """
    return imp.is_frozen("__main__") # cx_freeze
コード例 #41
0
def main_is_frozen():
    """detect if the script is running from frozen
    distribution. i.e: from a py2exe build or others
    """
    import imp
    return (hasattr(sys, "frozen") or # new py2exe
        hasattr(sys, "importers") or # old py2exe
        imp.is_frozen("__main__")) # tools/freeze
コード例 #42
0
def main_is_frozen():
    """
    执行环境判断
    :return:
    """
    return (hasattr(sys, "frozen") or       # new py2exe
            hasattr(sys, "importers") or    # old py2exe
            imp.is_frozen("__main__"))      # tools/freeze
コード例 #43
0
def main_is_frozen():

    """ Return T if running from an exe, F otherwise
    """

    return (hasattr(sys, "frozen")  
           or hasattr(sys, "importers") 
           or imp.is_frozen("__main__") 
            or os.path.isfile(sys.path[0]))
コード例 #44
0
ファイル: __init__.py プロジェクト: rohanmaddamsetti/lib
def sate_is_frozen():
    """Will return True if SATe is frozen.
    """
    import imp
    return (
        hasattr(sys, "frozen")          # new py2exe
        or hasattr(sys, "importers")    # old py2exe
        or imp.is_frozen("__main__")    # tools/freeze
    )
コード例 #45
0
def main_is_frozen():
    """
    Return True if BitDust is started from .exe not from sources.

    http://www.py2exe.org/index.cgi/HowToDetermineIfRunningFromExe
    """
    return (hasattr(sys, "frozen") or       # new py2exe
            hasattr(sys, "importers") or    # old py2exe
            imp.is_frozen("__main__"))      # tools/freeze
コード例 #46
0
def main_is_frozen():
    """
    To determine whether the script is launched from the interpreter or if it
    is an executable compiled with py2exe.
    See http://www.py2exe.org/index.cgi/HowToDetermineIfRunningFromExe
    """
    return (hasattr(sys, "frozen")  # new py2exe
            or hasattr(sys, "importers")  # old py2exe
            or imp.is_frozen("__main__"))  # tools/freeze
コード例 #47
0
def mainfrozen():
    """return True if we are a frozen executable.

    The code supports py2exe (most common, Windows only) and tools/freeze
    (portable, not much used).
    """
    return (pycompat.safehasattr(sys, "frozen") or  # new py2exe
            pycompat.safehasattr(sys, "importers") or  # old py2exe
            imp.is_frozen(u"__main__"))  # tools/freeze
コード例 #48
0
def main_is_frozen():
    """return True if we are a frozen executable.

    The code supports py2exe (most common, Windows only) and tools/freeze
    (portable, not much used).
    """
    return (hasattr(sys, "frozen") or # new py2exe
            hasattr(sys, "importers") or # old py2exe
            imp.is_frozen("__main__")) # tools/freeze
コード例 #49
0
ファイル: plx.py プロジェクト: decalage2/exefilter
def main_is_frozen():
    """
    To determine whether the script is launched from the interpreter or if it
    is an executable compiled with py2exe.
    See http://www.py2exe.org/index.cgi/HowToDetermineIfRunningFromExe
    """
    return (hasattr(sys, "frozen") # new py2exe
        or hasattr(sys, "importers") # old py2exe
        or imp.is_frozen("__main__")) # tools/freeze
コード例 #50
0
ファイル: paths.py プロジェクト: odalissalazar/bauble.classic
def main_is_frozen():
    """
    Returns True/False if Bauble is being run from a py2exe
    executable.  This method duplicates bauble.main_is_frozen in order
    to make paths.py not depend on any other Bauble modules.
    """
    import imp
    return (hasattr(sys, "frozen") or  # new py2exe
            hasattr(sys, "importers") or  # old py2exe
            imp.is_frozen("__main__"))  # tools/freeze
コード例 #51
0
ファイル: selfdel.py プロジェクト: themson/cleanup
def is_frozen_main():
    """Freeze detection Bool

    From www.py2exe.org/index.cgi/HowToDetermineIfRunningFromExe
    ThomasHeller posted to the py2exe mailing list
    :return: bool
    """
    return (hasattr(sys, "frozen") or  # new py2exe
            hasattr(sys, "importers")  # old py2exe
            or is_frozen("__main__"))  # tools/freeze
コード例 #52
0
ファイル: paths.py プロジェクト: Ghini/ghini.desktop
def main_is_frozen():
    """
    Returns True/False if Ghini is being run from a py2exe
    executable.  This method duplicates bauble.main_is_frozen in order
    to make paths.py not depend on any other Ghini modules.
    """
    import imp
    return (hasattr(sys, "frozen") or  # new py2exe
            hasattr(sys, "importers") or  # old py2exe
            imp.is_frozen("__main__"))  # tools/freeze
コード例 #53
0
def get_program_path():
    if hasattr(sys, "frozen") or imp.is_frozen("__main__"):
        return os.path.dirname(sys.executable)
    else:
        try:
            # normally, we're in ./overviewer_core/util.py
            # we want ./
            return os.path.dirname(os.path.dirname(__file__))
        except NameError:
            return os.path.dirname(sys.argv[0])
コード例 #54
0
def get_program_path():
    if hasattr(sys, "frozen") or imp.is_frozen("__main__"):
        return os.path.dirname(sys.executable)
    else:
        try:
            # normally, we're in ./overviewer_core/util.py
            # we want ./
            return os.path.dirname(os.path.dirname(__file__))
        except NameError:
            return os.path.dirname(sys.argv[0])
コード例 #55
0
def app_is_frozen():
    """
    Checks if the app is stadalone

    @return: True / False
    @rtype: bool
    """
    return (hasattr(sys, "frozen") or  # new py2exe
            hasattr(sys, "importers")  # old py2exe
            or imp.is_frozen("__main__"))  # tools/freeze
コード例 #56
0
def program_dir():
    """
    This gets the full pathname of the directory containing the program.
    It is used for referring to other files (binaries, images, etc.).
    """
    if (Win32() and (hasattr(sys, 'frozen') or imp.is_frozen('__main__'))):
        # running from exe generated by py2exe
        return os.path.dirname(sys.executable)
    else:
        return sys.path[0]
コード例 #57
0
    def find_module(self, fullname, path=None):
        """Return mpiloader if 'fullname' is in sys.path (and isn't a builtin or
        frozen module)."""

        # Don't override builtin/frozen modules. TODO: Windows registry?
        if (fullname not in sys.builtin_module_names
                and not imp.is_frozen(fullname) and fullname in self._cache):

            return self
        return None