Including PYDs/DLLs in py2exe builds

前端 未结 4 1391
眼角桃花
眼角桃花 2021-01-17 16:52

One of the modules for my app uses functions from a .pyd file. There\'s an option to exclude dlls (exclude_dlls) but is there one for including them? The build process doesn

4条回答
  •  无人共我
    2021-01-17 17:25

    You can modify the setup script to copy the files explicitly:

    script = "PyInvaders.py"        #name of starting .PY
    project_name = os.path.splitext(os.path.split(script)[1])[0]
    setup(name=project_name, scripts=[script]) #this installs the program
    
    #also need to hand copy the extra files here
    def installfile(name):
        dst = os.path.join('dist', project_name)
        print 'copying', name, '->', dst
        if os.path.isdir(name):
        dst = os.path.join(dst, name)
        if os.path.isdir(dst):
            shutil.rmtree(dst)
        shutil.copytree(name, dst)
        elif os.path.isfile(name):
        shutil.copy(name, dst)
        else:
        print 'Warning, %s not found' % name
    
    pygamedir = os.path.split(pygame.base.__file__)[0]
    installfile(os.path.join(pygamedir, pygame.font.get_default_font()))
    installfile(os.path.join(pygamedir, 'pygame_icon.bmp'))
    for data in extra_data:
        installfile(data)
    

    etc... modify to suit your needs, of course.

提交回复
热议问题