I need to compile a pyhton tool into an executable as the destination plateform (Solaris, Linux) are not deployed with Python or not all needed modules.
I found pyinstaller and follow the classical tutorial.
First executable starts correctly under Linux but not under windows.
Second it crashes right after due to unknown module that haev to be loaded.
Here is a view of my tool. The following code comes from analyzer.py I have to call to run this tool.
Expand|Select|Wrap|Line Numbers
- try:
- TOOLS_ROOT = os.environ['TOOLS_ROOT']
- sys.path.append(TOOLS_ROOT)
- except KeyError:
- print 'TOOLS_ROOT is undefined. Please set it.'
- sys.exit(1)
- import lib.globals
- from lib.parserLib import Architecture
- import thread
- import threading
- ...
/tool/__init__.py
analyzer.py
lib/__init__.py
globals.py
parserLib.py
Few questions:
- how to bypass the TOOLS_ROOT env var decalaration, that I used when I run directly analyzer.py under linux ?
Here is output of the script if I do not declare this ver
"""
vmintegration:~/pyinstaller-1.4/analyzer# ./dist/analyzer
TOOLS_ROOT is undefined. Please set it.
vmintegration:~/pyinstaller-1.4/analyzer#
"""
- how to indicate to pyinstaller that modules have to be included into the executable file, because they are currently not recognized
Here is output of the script when TOOLS_ROOT is defined (with a fake value)
"""
vmintegration:~/pyinstaller-1.4/analyzer# export TOOLS_ROOT=`pwd`
vmintegration:~/pyinstaller-1.4/analyzer# ./dist/analyzer
Traceback (most recent call last):
File "<string>", line 21, in <module>
File "/root/pyinstaller-1.4/iu.py", line 455, in importHook
raise ImportError, "No module named %s" % fqname
ImportError: No module named lib
"""
- how to integrate argument from command line if I need ?
Here is output of the script if TOOLS_ROOT is defined to the "real" root of my tool
"""
vmintegration:~/pyinstaller-1.4/analyzer# export TOOLS_ROOT=/home/stephane/tool
vmintegration:~/pyinstaller-1.4/analyzer# ./dist/analyzer
ERROR : Arg <opt> missing in command line ****
"""
I attached warnlog file to help me.
Here is the spec content file
"""
# -*- mode: python -*-
a = Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), os.path.join(HOMEPATH,'support/useUnicode.py'), '/home/stephane/python/script/analyzer.py'],
pathex=['/root/pyinstaller-1.4'])
pyz = PYZ(a.pure)
exe = EXE( pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name=os.path.join('dist', 'analyzer'),
debug=False,
strip=False,
upx=True,
console=1 )
"""
Thanks for any help.
I read some documentation about pyinstaller but it's not very clear for me and I'm not able to progress anynmore.
Regards