regsetup.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:CodeReader 作者: jasonrbr 项目源码 文件源码
def SetupCore(searchPaths):
    """Setup the core Python information in the registry.

       This function makes no assumptions about the current state of sys.path.

       After this function has completed, you should have access to the standard
       Python library, and the standard Win32 extensions
    """

    import sys
    for path in searchPaths:
        sys.path.append(path)

    import os
    import regutil, win32api,win32con

    installPath, corePaths = LocatePythonCore(searchPaths)
    # Register the core Pythonpath.
    print(corePaths)
    regutil.RegisterNamedPath(None, ';'.join(corePaths))

    # Register the install path.
    hKey = win32api.RegCreateKey(regutil.GetRootKey() , regutil.BuildDefaultPythonKey())
    try:
        # Core Paths.
        win32api.RegSetValue(hKey, "InstallPath", win32con.REG_SZ, installPath)
    finally:
        win32api.RegCloseKey(hKey)

    # Register the win32 core paths.
    win32paths = os.path.abspath( os.path.split(win32api.__file__)[0]) + ";" + \
                 os.path.abspath( os.path.split(LocateFileName("win32con.py;win32con.pyc", sys.path ) )[0] )

    # Python has builtin support for finding a "DLLs" directory, but
    # not a PCBuild.  Having it in the core paths means it is ignored when
    # an EXE not in the Python dir is hosting us - so we add it as a named
    # value
    check = os.path.join(sys.prefix, "PCBuild")
    if "64 bit" in sys.version:
        check = os.path.join(check, "amd64")
    if os.path.isdir(check):
        regutil.RegisterNamedPath("PCBuild",check)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号