当前位置: 首页 > 工具软件 > Py-SDL2 > 使用案例 >

python setup.py文件---打包

濮阳宜
2023-12-01

怎么使用setup.py文件

python setup.py install

打包成什么样的文件

  • .zip(等压缩文件)
  • .exe(等二进制文件)
  • .whl(python轮子,python二进制包)

怎么编写(体验一下就行,来自github)

import os
import sys
from distutils.core import setup
import py2exe

origIsSystemDLL = py2exe.build_exe.isSystemDLL
def isSystemDLL(pathname):
    # what dynamic lib is using 
    dlls = ("libfreetype-6.dll", "libogg-0.dll", "sdl_ttf.dll")
    if os.path.basename(pathname).lower() in dlls:
        return 0
    return origIsSystemDLL(pathname)
py2exe.build_exe.isSystemDLL = isSystemDLL

sys.argv.append('py2exe')

setup(
    # 
    name =    'Flappy Bird',
    version = '1.0',
    author =  'Sourabh Verma',
    options = {
        'py2exe': {
            # 
            'bundle_files': 1, # doesn't work on win64
            'compressed': True,
        }
    },

    windows = [{
        # for window platform , using what files
        'script': "flappy.py",
        'icon_resources': [
            (1, 'flappy.ico')
        ]
    }],
    # why not for mac


    zipfile=True,
)

 类似资料: