[英]Cannot compile two .py files into stand alone executable using py2exe
[英]python py2exe compile two py files at once to two separate exe files
我正在使用此安裝腳本將一個py文件編譯為exe。
# -*- coding: utf-8 -*-
from distutils.core import setup
import py2exe
import sys
import os
dataFiles = []
sampleDir = r'.\\lang'
for root, dirs, files in os.walk(sampleDir):
sampleList = []
if files:
for filename in files:
#ignore SVN dirs
if ".svn" not in root:
sampleList.append(os.path.join(root, filename))
if sampleList:
dataFiles.append((root, sampleList))
class Target:
def __init__(self, **kw):
self.__dict__.update(kw)
self.version = "1.5.5.000"
self.company_name = "company"
self.copyright = 'Copyright (c) '
target = Target(
script = "script.py",
icon_resources=[(1, 'ico.ico')],
)
setup(
name = 'PROGNAME',
author='me',
author_email='me@me.com',
description = 'desc',
windows = [target],
options = {
'py2exe': {
'packages': 'encodings, kinterbasdb',
'includes': 'cairo, pango, pangocairo, atk, gobject, gio, glib, gtk',
}
},
data_files=dataFiles,
)
但是現在我有兩個py文件 ,我想一次編譯它,但是每個文件都應該有:
我應該如何更改設置腳本才能立即執行此操作?
我發現了怎么做! 希望這對大家有幫助:
# -*- coding: utf-8 -*-
from distutils.core import setup
import py2exe
import sys
import os
dataFiles = []
sampleDir = r'.\\lang'
for root, dirs, files in os.walk(sampleDir):
sampleList = []
if files:
for filename in files:
#ignore SVN dirs
if ".svn" not in root:
sampleList.append(os.path.join(root, filename))
if sampleList:
dataFiles.append((root, sampleList))
class Target:
def __init__(self, **kw):
self.__dict__.update(kw)
target = Target(
script = "script.py",
icon_resources=[(1, 'ico.ico')],
version = "1.5.5.000",
company_name = "company",
copyright = 'Copyright (c) ',
name = 'PROGNAME',
)
target2 = Target(
script = "script2.py",
icon_resources=[(1, 'ico.ico')],
version = "1.0.0.000",
company_name = "company",
copyright = 'Copyright (c) ',
name = 'SECOND PROGNAME',
)
setup(
author='me',
author_email='me@me.com',
description = 'desc',
windows = [target, target2],
options = {
'py2exe': {
'packages': 'encodings, kinterbasdb',
'includes': 'cairo, pango, pangocairo, atk, gobject, gio, glib, gtk',
}
},
data_files=dataFiles,
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.