遵照 http://www.tribler.org/trac/wiki/BrowserPlugin 中对SwarmPlugin的说明,首先需要编译出BG Process这个东东。
下载源码 svn co http://svn.tribler.org/abc/branches/mainbranch/,将源码放到你自己指定路径后执行
1
2
3
4
5
|
C:\Python27>python.exe Tribler\Plugin\Build\Win32\setupBGexe.py py2exe
Traceback (most recent call last):
File
"Tribler\Plugin\Build\Win32\setupBGexe.py"
, line
8
,
in
<module>
import
py2exe
# Not a superfluous import!
ImportError: No module named py2exe
|
=======================================
This package is a distutils extension to build
standalone Windows executable programs from
Python scripts.
Author: Thomas Heller
Author_email: theller@python.net
Description: Build standalone executables for Windows
Maintainer: Jimmy Retzlaff
Maintainer_email: jimmy@retzlaff.com
Name: py2exe
Url: http://www.py2exe.org/
Version: 0.6.9
=======================================
重新执行得到
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
C:\Python27>python.exe Tribler\Plugin\Build\Win32\setupBGexe.py py2exe
running py2exe
creating C:\Python27\build
creating C:\Python27\build\bdist.win32
creating C:\Python27\build\bdist.win32\winexe
creating C:\Python27\build\bdist.win32\winexe\collect
-
2.7
creating C:\Python27\build\bdist.win32\winexe\bundle
-
2.7
creating C:\Python27\build\bdist.win32\winexe\temp
creating C:\Python27\dist
*
*
*
searching
for
required modules
*
*
*
C:\Python27\Tribler\Player\swarmplayer.py:
451
: SyntaxWarning: name
'START_TIME'
is
assigned to before
global
declaration
global
START_TIME
*
*
*
parsing results
*
*
*
creating python loader
for
extension
'vlc'
(C:\Python27\vlc.pyd
-
> vlc.pyd)
creating python loader
for
extension
'unicodedata'
(C:\Python27\DLLs\unicodedata.pyd
-
> unicodedata.pyd)
creating python loader
for
extension
'win32pdh'
(C:\Python27\lib\site
-
packages\win32\win32pdh.pyd
-
> win32pdh.pyd)
creating python loader
for
extension
'_ctypes'
(C:\Python27\DLLs\_ctypes.pyd
-
> _ctypes.pyd)
creating python loader
for
extension
'select'
(C:\Python27\DLLs\select.pyd
-
> select.pyd)
creating python loader
for
extension
'win32event'
(C:\Python27\lib\site
-
packages\win32\win32event.pyd
-
> win32event.pyd)
creating python loader
for
extension
'wx._controls_'
(C:\Python27\lib\site
-
packages\wx
-
2.8
-
msw
-
unicode
\wx\_controls_.pyd
-
> wx._co
ntrols_.pyd)
creating python loader
for
extension
'apsw'
(C:\Python27\lib\site
-
packages\apsw.pyd
-
> apsw.pyd)
creating python loader
for
extension
'win32evtlog'
(C:\Python27\lib\site
-
packages\win32\win32evtlog.pyd
-
> win32evtlog.pyd)
creating python loader
for
extension
'win32file'
(C:\Python27\lib\site
-
packages\win32\win32file.pyd
-
> win32file.pyd)
creating python loader
for
extension
'wx._windows_'
(C:\Python27\lib\site
-
packages\wx
-
2.8
-
msw
-
unicode
\wx\_windows_.pyd
-
> wx._wind
ows_.pyd)
creating python loader
for
extension
'_hashlib'
(C:\Python27\DLLs\_hashlib.pyd
-
> _hashlib.pyd)
creating python loader
for
extension
'bz2'
(C:\Python27\DLLs\bz2.pyd
-
> bz2.pyd)
creating python loader
for
extension
'_ssl'
(C:\Python27\DLLs\_ssl.pyd
-
> _ssl.pyd)
creating python loader
for
extension
'_sqlite3'
(C:\Python27\DLLs\_sqlite3.pyd
-
> _sqlite3.pyd)
creating python loader
for
extension
'wx._core_'
(C:\Python27\lib\site
-
packages\wx
-
2.8
-
msw
-
unicode
\wx\_core_.pyd
-
> wx._core_.pyd)
creating python loader
for
extension
'wx._misc_'
(C:\Python27\lib\site
-
packages\wx
-
2.8
-
msw
-
unicode
\wx\_misc_.pyd
-
> wx._misc_.pyd)
creating python loader
for
extension
'wx._xrc'
(C:\Python27\lib\site
-
packages\wx
-
2.8
-
msw
-
unicode
\wx\_xrc.pyd
-
> wx._xrc.pyd)
creating python loader
for
extension
'M2Crypto.__m2crypto'
(C:\Python27\lib\site
-
packages\M2Crypto\__m2crypto.pyd
-
> M2Crypto.__m2
crypto.pyd)
creating python loader
for
extension
'_win32sysloader'
(C:\Python27\lib\site
-
packages\win32\_win32sysloader.pyd
-
> _win32sysloader
.pyd)
creating python loader
for
extension
'wx._gdi_'
(C:\Python27\lib\site
-
packages\wx
-
2.8
-
msw
-
unicode
\wx\_gdi_.pyd
-
> wx._gdi_.pyd)
creating python loader
for
extension
'pyexpat'
(C:\Python27\DLLs\pyexpat.pyd
-
> pyexpat.pyd)
creating python loader
for
extension
'win32ui'
(C:\Python27\lib\site
-
packages\Pythonwin\win32ui.pyd
-
> win32ui.pyd)
creating python loader
for
extension
'win32api'
(C:\Python27\lib\site
-
packages\win32\win32api.pyd
-
> win32api.pyd)
creating python loader
for
extension
'_socket'
(C:\Python27\DLLs\_socket.pyd
-
> _socket.pyd)
*
*
*
finding dlls needed
*
*
*
error: python25.dll: No such
file
or
directory
|
先查看setupBGexe.py,没有发现特别的东西
1
2
3
4
5
6
7
8
9
10
11
12
|
import
os
from
distutils.core
import
setup
import
py2exe
# Not a superfluous import!
from
Tribler.__init__
import
LIBRARYNAME
mainfile
=
os.path.join(LIBRARYNAME,
'Plugin'
,
'SwarmEngine.py'
)
# Arno: 2009-06-09: changed from console= to make sure py2exe writes
# a BackgroundProcess.exe.log
#
setup(windows
=
[mainfile])
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# py2exe/__init__.py
# 'import py2exe' imports this package, and two magic things happen:
#
# - the 'py2exe.build_exe' submodule is imported and installed as
# 'distutils.commands.py2exe' command
#
# - the default distutils Distribution class is replaced by the
# special one contained in this module.
#
__version__
=
"0.6.9"
import
distutils.dist, distutils.core, distutils.command, build_exe, sys
class
Distribution(distutils.dist.Distribution):
def
__init__(
self
, attrs):
self
.ctypes_com_server
=
attrs.pop(
"ctypes_com_server"
, [])
self
.com_server
=
attrs.pop(
"com_server"
, [])
self
.service
=
attrs.pop(
"service"
, [])
self
.windows
=
attrs.pop(
"windows"
, [])
self
.console
=
attrs.pop(
"console"
, [])
self
.isapi
=
attrs.pop(
"isapi"
, [])
self
.zipfile
=
attrs.pop(
"zipfile"
,
"library.zip"
)
distutils.dist.Distribution.__init__(
self
, attrs)
distutils.core.Distribution
=
Distribution
distutils.command.__all__.append(
'py2exe'
)
sys.modules[
'distutils.command.py2exe'
]
=
build_exe
|
由经验知道 error: python25.dll: No such file or directory 意思是打开文件的时候出错,要么是文件路径不对,要么是文件名不对,总之未找到对应文件,搜索python27.dll,发现其位于C:\WINDOWS\system32下面,确实没有python25.dll的影子(其实不搜索也应该猜得到,毕竟我没装过python2.5嘛)
两种解决办法:
a) 下载python25.dll,放置到和python27.dll相同的目录下
b) 对build_exe.py进行修改
下载python25.dll的方法可以参考百度百科说明 http://baike.baidu.com/view/6590620.htm
这里说明下如何对build_exe.py进行修改,和这个问题有关的代码如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
......
def
bin_depends(path, images, excluded_dlls):
import
py2exe_util
warnings
=
FileSet()
images
=
FileSet(images)
dependents
=
FileSet()
others
=
FileSet()
while
images:
for
image
in
images.copy():
images.remove(image)
if
not
image
in
dependents:
dependents.add(image)
abs_image
=
os.path.abspath(image)
loadpath
=
os.path.dirname(abs_image)
+
';'
+
path
for
result
in
py2exe_util.depends(image, loadpath).items():
dll, uses_import_module
=
result
if
os.path.basename(dll).lower()
not
in
excluded_dlls:
if
isSystemDLL(dll):
others.add(dll)
continue
if
dll
not
in
images
and
dll
not
in
dependents:
images.add(dll)
if
uses_import_module:
warnings.add(dll)
return
dependents, warnings, others
# DLLs to be excluded
# XXX This list is NOT complete (it cannot be)
# Note: ALL ENTRIES MUST BE IN LOWER CASE!
EXCLUDED_DLLS
=
(
"advapi32.dll"
,
"comctl32.dll"
,
"comdlg32.dll"
,
"crtdll.dll"
,
"gdi32.dll"
,
"glu32.dll"
,
"opengl32.dll"
,
"imm32.dll"
,
"kernel32.dll"
,
"mfc42.dll"
,
"msvcirt.dll"
,
"msvcrt.dll"
,
"msvcrtd.dll"
,
"ntdll.dll"
,
"odbc32.dll"
,
"ole32.dll"
,
"oleaut32.dll"
,
"rpcrt4.dll"
,
"shell32.dll"
,
"shlwapi.dll"
,
"user32.dll"
,
"version.dll"
,
"winmm.dll"
,
"winspool.drv"
,
"ws2_32.dll"
,
"ws2help.dll"
,
"wsock32.dll"
,
"netapi32.dll"
,
"gdiplus.dll"
,
)
# XXX Perhaps it would be better to assume dlls from the systemdir are system dlls,
# and make some exceptions for known dlls, like msvcr71, pythonXY.dll, and so on?
def
isSystemDLL(pathname):
if
os.path.basename(pathname).lower()
in
(
"msvcr71.dll"
,
"msvcr71d.dll"
):
return
0
if
os.path.basename(pathname).lower()
in
EXCLUDED_DLLS:
return
1
# How can we determine whether a dll is a 'SYSTEM DLL'?
# Is it sufficient to use the Image Load Address?
import
struct
file
=
open
(pathname,
"rb"
)
if
file
.read(
2
) !
=
"MZ"
:
raise
Exception,
"Seems not to be an exe-file"
file
.seek(
0x3C
)
pe_ofs
=
struct.unpack(
"i"
,
file
.read(
4
))[
0
]
file
.seek(pe_ofs)
if
file
.read(
4
) !
=
"PE\000\000"
:
raise
Exception, (
"Seems not to be an exe-file"
, pathname)
file
.read(
20
+
28
)
# COFF File Header, offset of ImageBase in Optional Header
imagebase
=
struct.unpack(
"I"
,
file
.read(
4
))[
0
]
return
not
(imagebase <
0x70000000
)
......
|
1
|
if
os.path.basename(pathname).lower()
in
(
"msvcr71.dll"
,
"msvcr71d.dll"
):
|
1
|
if
os.path.basename(pathname).lower()
in
(
"msvcr71.dll"
,
"msvcr71d.dll"
,
"python25.dll"
):
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
C:\Python27>python.exe Tribler\Plugin\Build\Win32\setupBGexe.py py2exe
running py2exe
*
*
*
searching
for
required modules
*
*
*
C:\Python27\Tribler\Player\swarmplayer.py:
451
: SyntaxWarning: name
'START_TIME'
is
assigned to before
global
declaration
global
START_TIME
*
*
*
parsing results
*
*
*
......
......
*
*
*
finding dlls needed
*
*
*
Traceback (most recent call last):
File
"Tribler\Plugin\Build\Win32\setupBGexe.py"
, line
16
,
in
<module>
setup(windows
=
[mainfile])
File
"C:\Python27\lib\distutils\core.py"
, line
152
,
in
setup
dist.run_commands()
File
"C:\Python27\lib\distutils\dist.py"
, line
953
,
in
run_commands
self
.run_command(cmd)
File
"C:\Python27\lib\distutils\dist.py"
, line
972
,
in
run_command
cmd_obj.run()
File
"C:\Python27\lib\site-packages\py2exe\build_exe.py"
, line
243
,
in
run
self
._run()
File
"C:\Python27\lib\site-packages\py2exe\build_exe.py"
, line
305
,
in
_run
dlls
=
self
.find_dlls(extensions)
File
"C:\Python27\lib\site-packages\py2exe\build_exe.py"
, line
389
,
in
find_dlls
self
.dll_excludes)
File
"C:\Python27\lib\site-packages\py2exe\build_exe.py"
, line
1064
,
in
find_dependend_dlls
bin_depends(loadpath, images
+
[sys.executable], excludes_use)
File
"C:\Python27\lib\site-packages\py2exe\build_exe.py"
, line
1438
,
in
bin_depends
for
result
in
py2exe_util.depends(image, loadpath).items():
py2exe_util.bind_error: (
2
, '
', '
python25.dll')
|
1
2
3
4
5
6
7
8
9
|
C:\Python27>python.exe Tribler\Plugin\Build\Win32\setupBGexe.py py2exe
running py2exe
*
*
*
searching
for
required modules
*
*
*
C:\Python27\Tribler\Player\swarmplayer.py:
451
: SyntaxWarning: name
'START_TIME'
is
assigned to before
global
declaration
global
START_TIME
*
*
*
parsing results
*
*
*
......
*
*
*
finding dlls needed
*
*
*
error: MSVCP90.dll: No such
file
or
directory
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
C:\Python27>python.exe Tribler\Plugin\Build\Win32\setupBGexe.py py2exe
running py2exe
*
*
*
searching
for
required modules
*
*
*
C:\Python27\Tribler\Player\swarmplayer.py:
451
: SyntaxWarning: name
'START_TIME'
is
assigned to before
global
declaration
global
START_TIME
*
*
*
parsing results
*
*
*
......
*
*
*
finding dlls needed
*
*
*
*
*
*
create binaries
*
*
*
*
*
*
byte
compile
python files
*
*
*
......
skipping byte
-
compilation of ......
skipping byte
-
compilation of C:\Python27\Tribler\vlc.py to Tribler\vlc.pyc
byte
-
compiling C:\Python27\build\bdist.win32\winexe\temp\M2Crypto.__m2crypto.py to M2Crypto\__m2crypto.pyc
byte
-
compiling ......
......
skipping byte
-
compilation of C:\Python27\lib\zipfile.py to zipfile.pyc
*
*
*
copy extensions
*
*
*
*
*
*
copy dlls
*
*
*
copying C:\Python27\lib\site
-
packages\py2exe\run_w.exe
-
> C:\Python27\dist\SwarmEngine.exe
The following modules appear to be missing
[
'ElementC14N'
,
'Tribler.Core.BuddyCast.buddycast'
,
'_curses'
,
'_scproxy'
,
'core.bootstrap'
,
'core.identifier'
,
'core.message'
, 'c
ore.node
', '
core.ptime
', '
core.routing_table
', '
meliae
', '
netifaces
', '
prctl
', '
psyco
', '
simplejson
', '
test_const
', '
vlc.lib.vlc',
'win32com.shell'
]
*
*
*
binary dependencies
*
*
*
Your executable(s) also depend on these dlls which are
not
included,
you may
or
may
not
need to distribute them.
Make sure you have the license
if
you distribute
any
of them,
and
make sure you don't distribute files belonging to the operating system.
ole32.dll
-
C:\WINDOWS\system32\ole32.dll
OLEAUT32.dll
-
C:\WINDOWS\system32\OLEAUT32.dll
USER32.dll
-
C:\WINDOWS\system32\USER32.dll
python25.dll
-
python25.dll
SHELL32.dll
-
C:\WINDOWS\system32\SHELL32.dll
MSWSOCK.dll
-
C:\WINDOWS\system32\MSWSOCK.dll
WINMM.dll
-
C:\WINDOWS\system32\WINMM.dll
WSOCK32.dll
-
C:\WINDOWS\system32\WSOCK32.dll
COMDLG32.dll
-
C:\WINDOWS\system32\COMDLG32.dll
ADVAPI32.dll
-
C:\WINDOWS\system32\ADVAPI32.dll
mfc90.dll
-
C:\Python27\lib\site
-
packages\Pythonwin\mfc90.dll
msvcrt.dll
-
C:\WINDOWS\system32\msvcrt.dll
WS2_32.dll
-
C:\WINDOWS\system32\WS2_32.dll
WINSPOOL.DRV
-
C:\WINDOWS\system32\WINSPOOL.DRV
GDI32.dll
-
C:\WINDOWS\system32\GDI32.dll
gdiplus.dll
-
C:\Python27\lib\site
-
packages\wx
-
2.8
-
msw
-
unicode
\wx\gdiplus.dll
VERSION.dll
-
C:\WINDOWS\system32\VERSION.dll
KERNEL32.dll
-
C:\WINDOWS\system32\KERNEL32.dll
COMCTL32.dll
-
C:\WINDOWS\system32\COMCTL32.dll
RPCRT4.dll
-
C:\WINDOWS\system32\RPCRT4.dll
MSVCP90.dll
-
C:\WINDOWS\system32\MSVCP90.dll
|