从任何IDE运行且不包括Tkinter的wxPython的py2exe安装文件

您可以通过切换"Py2Exe Version 6.3 Setup"来找到该脚本的原始作者。其中最酷的一点是,它调用了py2exe,以防您对命令行感到不舒服。我不得不在Hi和Lo上搜索如何将Tkinter排除在外的例子。即将推出:Scipy Includes和NumPy Include消除了对丢失模块的投诉,这些模块是幻影错误。

选择 | 换行 | 行号
  1. # Py2Exe version 6.3 setup file for wxPython GUI programs.
  2. # Creates a single exe file.
  3. # It's easiest to add this wxPython2Exe.py file into the same
  4. # folder with the source file and an optional iconfile like "icon.ico"
  5. # (if you add your own icon file, remove the comment in front of icon_resources).
  6. # Simply change the filename to whatever you called your source file.
  7. # Optionally edit the version info and add the name of your icon file.
  8. # Now run wxPython2Exe.py ...
  9. # Two subfolders will be created called build and dist.
  10. # The dist folder contains your .exe file, MSVCR71.dll and w9xpopen.exe
  11. # Your .exe file contains your code, all neded modules and the Python interpreter.
  12. # The MSVCR71.dll can be distributed, but is often already in the system32 folder.
  13.  
  14. from distutils.core import setup
  15. import py2exe
  16. import sys
  17.  
  18. sys.path.append(r"D:\My Documents\HETAP Project\2.05a")
  19.  
  20.  
  21. # enter the filename of your wxPython code file to compile ...
  22. filename = "App1.pyw"
  23.  
  24. # ... this creates the filename of your .exe file in the dist folder
  25. if filename.endswith(".py"):
  26.     distribution = filename[:-3]
  27. elif filename.endswith(".pyw"):
  28.     distribution = filename[:-4]
  29.  
  30.  
  31. # if run without args, build executables in quiet mode
  32. if len(sys.argv) == 1:
  33.     sys.argv.append("py2exe")
  34.     sys.argv.append("-q")
  35.  
  36. class Target:
  37.     def __init__(self, **kw):
  38.         self.__dict__.update(kw)
  39.         # for the versioninfo resources, edit to your needs
  40.         self.version = "2.0.1"
  41.         self.company_name = "BCDesigns"
  42.         self.copyright = "no copyright"
  43.         self.name = "HETAP Pro 2.01a"
  44.  
  45. ################################################################
  46. # The manifest will be inserted as resource into your .exe.  This
  47. # gives the controls the Windows XP appearance (if run on XP ;-)
  48. #
  49. # Another option would be to store it in a file named
  50. # test_wx.exe.manifest, and copy it with the data_files option into
  51. # the dist-dir.
  52. #
  53. manifest_template = '''
  54. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  55. <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  56. <assemblyIdentity
  57.     version="5.0.0.0"
  58.     processorArchitecture="x86"
  59.     name="%(prog)s"
  60.     type="win32"
  61. />
  62. <description>%(prog)s Program</description>
  63. <dependency>
  64.     <dependentAssembly>
  65.         <assemblyIdentity
  66.             type="win32"
  67.             name="Microsoft.Windows.Common-Controls"
  68.             version="6.0.0.0"
  69.             processorArchitecture="X86"
  70.             publicKeyToken="6595b64144ccf1df"
  71.             language="*"
  72.         />
  73.     </dependentAssembly>
  74. </dependency>
  75. </assembly>
  76. '''
  77.  
  78. RT_MANIFEST = 24
  79.  
  80. # description is the versioninfo resource
  81. # script is the wxPython code file
  82. # manifest_template is the above XML code
  83. # distribution will be the exe filename
  84. # icon_resource is optional, remove any comment and give it an iconfile you have
  85. #   otherwise a default icon is used
  86. # dest_base will be the exe filename
  87. test_wx = Target(
  88.     description = "A GUI app",
  89.     script = filename,
  90.     other_resources = [(RT_MANIFEST, 1, manifest_template % dict(prog=distribution))],
  91.     #icon_resources = [(1, "icon.ico")],
  92.     dest_base = distribution)
  93.  
  94. ################################################################
  95. packages = ["mx.ODBC.Windows"] #"scipy.signal", "numpy.core", "UniversalLibrary",
  96. includes = ["PMDDialog", "PMD"]
  97. excludes = ["pywin", "pywin.debugger", "pywin.debugger.dbgcon",
  98.             "pywin.dialogs", "pywin.dialogs.list",
  99.             "Tkconstants","Tkinter","tcl",
  100.             ]
  101.  
  102. setup(
  103.     options = {"py2exe": {"compressed": 1,
  104.                           "optimize": 2,
  105.                           "ascii": 1,
  106.                           "bundle_files": 1,
  107.                           "packages": packages,
  108. ##                          "includes": includes,
  109.                           "excludes": excludes}},
  110.  
  111.     zipfile = None,
  112.     windows = [test_wx],
  113.     )
  114.  

标签: python

评论已关闭