code
stringlengths
1
1.72M
language
stringclasses
1 value
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys from PyQt4 import Qt def main(): app = Qt.QApplication(sys.argv) label = Qt.QLabel("Hello World from PyQt4", None) label.setWindowTitle("Hello World from PyQt4") label.show() app.exec_() if __name__ == "__main__": main()
Python
string = "I hope you see this!"
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #nasty import time time.sleep(5) x = 5
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA print "test2 - version, icon, no zlib (should run same as test1)" e1 = 'a_func from pkg2.a' e2 = 'b_func from pkg2.b (pkg2/extra/b.py)' e3 = 'notamodule from pkg2.__init__' from pkg1 import * t1 = a.a_func() if t1 != e1: print "expected:", e1 print " got:", t1 t2 = b.b_func() if t2 != e2: print "expected:", e2 print " got:", t2 t3 = notamodule() if t3 != e3: print "expected:", e3 print " got:", t3 print "test2 complete"
Python
import wx app = wx.App(0) frame = wx.Frame(None, title="Hello World from wxPython", size=(320, 240))
Python
# -*- mode: python -*- __testname__ = 'test-pyqt4_i' a = Analysis([os.path.join(HOMEPATH,'support', '_mountzlib.py'), os.path.join(HOMEPATH,'support', 'useUnicode.py'), __testname__ + '.py']) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, exclude_binaries=1, name=os.path.join('build', 'pyi.' + config['target_platform'], __testname__, __testname__ + '.exe'), debug=False, strip=False, upx=False, console=True ) coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, strip=False, upx=False, name=os.path.join('dist', __testname__))
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA print "test12 - xml.com" from xml.dom import pulldom print "test12 - done"
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA import sys, os import data6 print "data6.x is", data6.x txt = """\ x = %d """ % (data6.x + 1) if hasattr(sys, 'frozen'): open(os.path.join(os.path.dirname(sys.executable), 'data6.py'), 'w').write(txt) else: open(data6.__file__, 'w').write(txt) reload(data6) print "data6.x is now", data6.x
Python
# -*- mode: python -*- __testname__ = 'test5' a = Analysis(['../support/_mountzlib.py', 'test5.py'], pathex=[]) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, [('W ignore', '', 'OPTION')], exclude_binaries=1, name=os.path.join('build', 'pyi.' + config['target_platform'], __testname__ + '.exe'), debug=0, console=1) coll = COLLECT( exe, a.binaries, name=os.path.join('dist', __testname__),)
Python
""" pkg1.a.py is never imported """ print " %s" % __doc__ print " %s %s" % (__name__, __file__)
Python
""" pkg1 replaces itself with pkg2""" __all__ = ["a", "b"] import pkg2 import sys sys.modules[__name__] = pkg2 from pkg2 import *
Python
# -*- mode: python -*- __testname__ = 'test8' a = Analysis([os.path.join(HOMEPATH,'support', '_mountzlib.py'), os.path.join(HOMEPATH,'support', 'useUnicode.py'), 'test8.py'], pathex=['.']) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, exclude_binaries=1, name=os.path.join('build', 'pyi.' + config['target_platform'], __testname__ + '.exe'), debug=0, strip=0, upx=0, console=1 ) coll = COLLECT( exe, a.binaries, strip=0, upx=0, name=os.path.join('dist', __testname__),)
Python
# Verify packagin of PIL.Image. Specifically, the hidden import of FixTk # importing tkinter is causing some problems. try: from Image import fromstring except ImportError: fromstring = "PIL missing!! Install PIL before running this test!" print fromstring
Python
import os os.environ["qwiejioqwjeioqwjeioqwje"]
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA import sys import threading def doit(nm): print nm, 'started' import data7 print nm, data7.x t1 = threading.Thread(target=doit, args=('t1',)) t2 = threading.Thread(target=doit, args=('t2',)) t1.start() t2.start() doit('main') t1.join() t2.join()
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA print "test1 - hooks / strange pkg structures" e1 = 'a_func from pkg2.a' e2 = 'b_func from pkg2.b (pkg2/extra/b.py)' e3 = 'notamodule from pkg2.__init__' from pkg1 import * t1 = a.a_func() if t1 != e1: print "expected:", e1 print " got:", t1 t2 = b.b_func() if t2 != e2: print "expected:", e2 print " got:", t2 t3 = notamodule() if t3 != e3: print "expected:", e3 print " got:", t3 print "test1 complete"
Python
import relimp2.bar import relimp2.bar.bar2 relimp2.bar.say_hello_please() relimp2.bar.bar2.say_hello_please()
Python
from Tkinter import * root = Tk() w = Label(root, text="Hello, world!") w.pack() root.mainloop()
Python
# -*- mode: python -*- __testname__ = 'test-matplotlib_i' if config['target_platform'] == 'win32' and sys.version_info[:2] >= (2, 6): manifest = '''<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity> </dependentAssembly> </dependency> </assembly>''' else: manifest = None a = Analysis([os.path.join(HOMEPATH,'support', '_mountzlib.py'), os.path.join(HOMEPATH,'support', 'useUnicode.py'), __testname__ + '.py']) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, exclude_binaries=1, name=os.path.join('build', 'pyi.' + config['target_platform'], __testname__, __testname__ + '.exe'), debug=False, strip=False, upx=False, console=True, manifest=manifest ) coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, strip=False, upx=False, name=os.path.join('dist', __testname__))
Python
# -*- mode: python -*- __testname__ = 'test7' a = Analysis(['../support/_mountzlib.py', 'test7.py'], pathex=[]) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, exclude_binaries=1, name=os.path.join('build', 'pyi.' + config['target_platform'], __testname__ + '.exe'), debug=0, console=1) coll = COLLECT( exe, a.binaries, name=os.path.join('dist', __testname__),)
Python
# -*- mode: python -*- __testname__ = 'test-wx_i' a = Analysis([os.path.join(HOMEPATH,'support', '_mountzlib.py'), os.path.join(HOMEPATH,'support', 'useUnicode.py'), __testname__ + '.py']) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, exclude_binaries=1, name=os.path.join('build', 'pyi.' + config['target_platform'], __testname__, __testname__ + '.exe'), debug=False, strip=False, upx=False, console=True ) coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, strip=False, upx=False, name=os.path.join('dist', __testname__))
Python
#!/usr/bin/env python try: import ctypes except ImportError: # ctypes unavailable, testing ctypes support is pointless. sys.exit(0) import test15a assert test15a.dummy(42) == 42
Python
# same test of test-ctypes-cdll-c.py, but built in one-file mode import ctypes, ctypes.util # Make sure we are able to load the MSVCRXX.DLL we are currently bound # to through ctypes. lib = ctypes.CDLL(ctypes.util.find_library('c')) print lib
Python
# -*- mode: python -*- a = Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), os.path.join(HOMEPATH,'support/useUnicode.py'), 'test-encoders.py'], pathex=['/home/rasky/src/pyinstaller/buildtests']) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, exclude_binaries=1, name=os.path.join('build/pyi.linux2/test-email', 'test-encoders.exe'), debug=False, strip=False, upx=False, console=1 ) coll = COLLECT( exe, a.binaries, a.zipfiles, a.datas, strip=False, upx=False, name=os.path.join('dist', 'test-encoders'))
Python
# -*- mode: python -*- __testname__ = 'test6' a = Analysis(['../support/_mountzlib.py', 'test6.py'], pathex=[]) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, exclude_binaries=1, name=os.path.join('build', 'pyi.' + config['target_platform'], __testname__ + '.exe'), debug=0, console=1) coll = COLLECT( exe, a.binaries, name=os.path.join('dist', __testname__),)
Python
# -*- mode: python -*- a = Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), os.path.join(HOMEPATH,'support/useUnicode.py'), 'test-wx.py'], pathex=[]) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, exclude_binaries=1, name=os.path.join('build/pyi.win32/test-wx', 'test-wx.exe'), debug=True, strip=False, upx=True, console=True ) coll = COLLECT( exe, a.binaries, a.zipfiles, a.datas, strip=False, upx=True, name=os.path.join('dist', 'test-wx'))
Python
# -*- mode: python -*- __testname__ = 'test-tkinter_i' a = Analysis([os.path.join(HOMEPATH,'support', '_mountzlib.py'), os.path.join(HOMEPATH,'support', 'useUnicode.py'), __testname__ + '.py']) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, exclude_binaries=1, name=os.path.join('build', 'pyi.' + config['target_platform'], __testname__, __testname__ + '.exe'), debug=False, strip=False, upx=False, console=1 ) coll = COLLECT( exe, a.binaries, a.zipfiles, strip=False, upx=False, name=os.path.join('dist', __testname__))
Python
# -*- mode: python -*- __testname__ = 'test-ctypes-cdll-c2' a = Analysis([os.path.join(HOMEPATH,'support', '_mountzlib.py'), os.path.join(HOMEPATH,'support', 'useUnicode.py'), __testname__ + '.py']) pyz = PYZ(a.pure) exe = EXE(pyz, a.binaries, a.zipfiles, a.scripts, name=os.path.join('dist', __testname__ + '.exe'), debug=True, strip=False, upx=False, console=1 )
Python
raise RuntimeError
Python
x = 2
Python
# -*- mode: python -*- __testname__ = 'test_f_option' a = Analysis(['../support/_mountzlib.py', 'test_f_option.py'], pathex=[]) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, [('f','','OPTION')], exclude_binaries=1, name=os.path.join('build', 'pyi.' + config['target_platform'], __testname__ + '.exe'), debug=0, console=1) coll = COLLECT( exe, a.binaries, name=os.path.join('dist', __testname__),)
Python
""" pkg2.a defines overridden and a_func """ def a_func(): return "a_func from pkg2.a" print "pkg2.a imported"
Python
""" pkg2 does various namespace tricks, __path__ append """ def notamodule(): return "notamodule from pkg2.__init__" import os __path__.append(os.path.join( os.path.dirname(__file__), 'extra')) __all__ = ["a", "b", "notamodule"]
Python
""" b.py lives in extra, but shows as pkg2.b (and pkg1.b)""" def b_func(): return "b_func from pkg2.b (pkg2/extra/b.py)"
Python
# -*- mode: python -*- __testname__ = 'test_filename' a = Analysis(['../support/_mountzlib.py', '../support/useUnicode.py', __testname__ + '.py'], pathex=[]) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, exclude_binaries=1, name=os.path.join('build', 'pyi.' + config['target_platform'], __testname__ + '.exe'), debug=False, strip=False, upx=False, console=1 ) coll = COLLECT( exe, a.binaries, strip=False, upx=False, name=os.path.join('dist', __testname__),)
Python
# -*- mode: python -*- a = Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), os.path.join(HOMEPATH,'support/useUnicode.py'), 'test-nestedlaunch1.py'], pathex=['']) pyz = PYZ(a.pure) exe = EXE( pyz, a.scripts, a.binaries, a.zipfiles, name=os.path.join('dist', 'test-nestedlaunch1', 'test-nestedlaunch1.exe'), debug=False, strip=False, upx=False, console=1 )
Python
# -*- mode: python -*- __testname__ = 'test_getfilesystemencoding' a = Analysis(['../support/_mountzlib.py', '../support/useUnicode.py', 'test_getfilesystemencoding.py'], pathex=[]) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, exclude_binaries=1, name=os.path.join('build', 'pyi.' + config['target_platform'], __testname__ + '.exe'), debug=False, strip=False, upx=False, console=1 ) coll = COLLECT(exe, a.binaries, strip=False, upx=False, name=os.path.join('dist', __testname__),)
Python
import relimp.B.C from relimp.F import H import relimp.relimp1 assert relimp.relimp1.name == 'relimp.relimp1' assert relimp.B.C.name == 'relimp.B.C' assert relimp.F.H.name == 'relimp.F.H'
Python
# Verify packagin of PIL.Image. Specifically, the hidden import of FixTk # importing tkinter is causing some problems. try: from PIL.Image import fromstring except ImportError: fromstring = "PIL missing!! Install PIL before running this test!" print fromstring
Python
from .relimp3b import b1 from .relimp3c import c1 def getString(): return b1.string + c1.string
Python
class c1: string = "... and this"
Python
raise ValueError
Python
raise ValueError
Python
# -*- mode: python -*- __testname__ = 'test-ctypes-cdll-c' a = Analysis([os.path.join(HOMEPATH,'support', '_mountzlib.py'), os.path.join(HOMEPATH,'support', 'useUnicode.py'), __testname__ + '.py']) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, exclude_binaries=1, name=os.path.join('build', 'pyi.' + config['target_platform'], __testname__, __testname__ + '.exe'), debug=True, strip=False, upx=False, console=1 ) coll = COLLECT( exe, a.binaries, a.zipfiles, strip=False, upx=False, name=os.path.join('dist', __testname__))
Python
# -*- mode: python -*- __testname__ = 'test_error_during_import' a = Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), os.path.join(HOMEPATH,'support/useUnicode.py'), __testname__ + '.py'], ) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, name = os.path.join('dist', __testname__, __testname__ +'.exe'), debug=False, strip=False, upx=False, console=1 )
Python
# -*- mode: python -*- __testname__ = 'test-zipimport2' a = Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), os.path.join(HOMEPATH,'support/useUnicode.py'), __testname__ + '.py'], ) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, name = os.path.join('dist', __testname__, __testname__ +'.exe'), debug=False, strip=False, upx=False, console=1 )
Python
# -*- mode: python -*- __testname__ = 'test-numpy' a = Analysis([os.path.join(HOMEPATH,'support', '_mountzlib.py'), os.path.join(HOMEPATH,'support', 'useUnicode.py'), __testname__ + '.py']) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, exclude_binaries=1, name=os.path.join('build', 'pyi.' + config['target_platform'], __testname__, __testname__ + '.exe'), debug=False, strip=False, upx=False, console=True ) coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, strip=False, upx=False, name=os.path.join('dist', __testname__))
Python
# -*- mode: python -*- a = Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), os.path.join(HOMEPATH,'support/useUnicode.py'), 'test-email.py'], pathex=['/home/rasky/src/pyinstaller/buildtests']) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, exclude_binaries=1, name=os.path.join('build/pyi.linux2/test-email', 'test-email.exe'), debug=False, strip=False, upx=False, console=1 ) coll = COLLECT( exe, a.binaries, a.zipfiles, a.datas, strip=False, upx=False, name=os.path.join('dist', 'test-email'))
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- import binascii from Crypto.Cipher import AES BLOCK_SIZE = 16 def main(): print "AES null encryption, block size", BLOCK_SIZE # Just for testing functionality after all print "HEX", binascii.hexlify(AES.new("\0" * BLOCK_SIZE).encrypt("\0" * BLOCK_SIZE)) if __name__ == "__main__": main()
Python
import cmath if __name__ == "__main__": print dir()
Python
from ..baz import *
Python
def say_hello_please(): print "Hello World!"
Python
from .baz import *
Python
# -*- mode: python -*- import sys import os CTYPES_DIR = "ctypes" TEST_LIB = os.path.join(CTYPES_DIR, "testctypes") if sys.platform == "linux2": TEST_LIB += ".so" elif sys.platform[:6] == "darwin": TEST_LIB += ".dylib" elif sys.platform == "win32": TEST_LIB += ".dll" else: raise NotImplementedError # If the required dylib does not reside in the current directory, the Analysis # class machinery, based on ctypes.util.find_library, will not find it. This was # done on purpose for this test, to show how to give Analysis class a clue. if sys.platform == "win32": os.environ["PATH"] = os.path.abspath(CTYPES_DIR) + ";" + os.environ["PATH"] else: os.environ["DYLD_LIBRARY_PATH"] = CTYPES_DIR os.environ["LD_LIBRARY_PATH"] = CTYPES_DIR os.chdir(CTYPES_DIR) if sys.platform[:6] == "darwin": os.system("gcc -Wall -dynamiclib testctypes.c -o testctypes.dylib -headerpad_max_install_names") id_dylib = os.path.abspath("testctypes.dylib") os.system("install_name_tool -id %s testctypes.dylib" % (id_dylib,)) elif sys.platform == "linux2": os.system("gcc -fPIC -shared testctypes.c -o testctypes.so") else: ret = os.system("cl /LD testctypes-win.c") if ret != 0: ret = os.system("gcc -shared testctypes-win.c -o testctypes.dll") if ret != 0: raise NotImplementedError("Cannot find either MinGW or Visual Studio in PATH") os.chdir("..") __testname__ = 'test15' a = Analysis(['../support/_mountzlib.py', '../support/useUnicode.py', 'test15.py'], pathex=[]) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, a.binaries, name=os.path.join('dist', __testname__ + '.exe'), debug=False, strip=False, upx=False, console=1 )
Python
# -*- mode: python -*- __testname__ = 'test4i' a = Analysis(['../support/_mountzlib.py', 'test4i.py'], pathex=[]) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, [('u', '', 'OPTION')], exclude_binaries=1, name=os.path.join('build', 'pyi.' + config['target_platform'], __testname__ + '.exe'), debug=0, console=1) coll = COLLECT( exe, a.binaries, name=os.path.join('dist', __testname__),)
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA print "test4 - unbufferred" print "type: 123456<enter>" print "should see: 12345" print "type: <enter>" print "if unbuffered should see: 6" print "if NOT unbuffered, should see nothing" print "Q to quit" import sys while 1: data = sys.stdin.read(5) sys.stdout.write(data) if 'Q' in data: break print "test4i - done"
Python
# -*- mode: python -*- __testname__ = 'test12' a = Analysis(['../support/_mountzlib.py', 'test12.py'], pathex=[]) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, exclude_binaries=1, name=os.path.join('build', 'pyi.' + config['target_platform'], __testname__ + '.exe'), debug=0, console=1) coll = COLLECT( exe, a.binaries, name=os.path.join('dist', __testname__),)
Python
""" import xml.etree.ElementTree from copy import copy, deepcopy import _elementtree import xml.etree.cElementTree print dir(xml.etree.cElementTree) """ from xml.etree.cElementTree import ElementTree print "OK"
Python
# -*- mode: python -*- __testname__ = 'test14' a = Analysis(['../support/_mountzlib.py', '../support/useUnicode.py', 'test14.py'], pathex=[]) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, exclude_binaries=1, name=os.path.join('build', 'pyi.' + config['target_platform'], __testname__ + '.exe'), debug=False, strip=False, upx=False, console=1 ) coll = COLLECT( exe, a.binaries, strip=False, upx=False, name=os.path.join('dist', __testname__),)
Python
# -*- mode: python -*- #!/usr/bin/env python # # Copyright (C) 2008 Hartmut Goebel <h.goebel@goebel-consult.de> # Licence: GNU General Public License version 3 (GPL v3) # # This file is part of PyInstaller <http://www.pyinstaller.org> # # pyinstaller is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # pyinstaller is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # """ test for zipimport - use a more complex import """ import os import sys print __name__, 'is running' print 'sys.path:', sys.path print 'dir contents .exe:', os.listdir(os.path.dirname(sys.executable)) if hasattr(sys, 'frozen') and sys.frozen: print '-----------' print 'dir contents _MEIPASS2:', os.listdir(os.environ['_MEIPASS2']) print '-----------' print 'now importing pkg_resources' import pkg_resources print '-----------' print 'now importing setuptools.dist' import setuptools.dist print '-----------' print 'now importing setuptools.command' import setuptools.command
Python
# -*- mode: python -*- __testname__ = 'test11' a = Analysis([os.path.join(HOMEPATH,'support', '_mountzlib.py'), os.path.join(HOMEPATH,'support', 'useUnicode.py'), 'test11.py'], pathex=['.']) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, exclude_binaries=1, name=os.path.join('build', 'pyi.' + config['target_platform'], __testname__ + '.exe'), debug=False, strip=False, upx=False, console=True ) coll = COLLECT( exe, a.binaries, strip=False, upx=False, name=os.path.join('dist', __testname__),)
Python
# -*- mode: python -*- __testname__ = 'test-relative-import3' a = Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), __testname__ + '.py'], ) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, name = os.path.join('dist', __testname__, __testname__ +'.exe'), debug=False, strip=False, upx=False, console=1 )
Python
# -*- mode: python -*- __testname__ = 'test-relative-import' a = Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), __testname__ + '.py'], ) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, name = os.path.join('dist', __testname__, __testname__ +'.exe'), debug=False, strip=False, upx=False, console=1 )
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- import wx def main(): app = wx.App(0) frame = wx.Frame(None, title="Hello World from wxPython") panel = wx.Panel(frame) label = wx.StaticText(panel, -1, "Hello World from wxPython") frame.Fit() frame.Show() app.MainLoop() if __name__ == "__main__": main()
Python
#!/usr/bin/env python # # Copyright (C) 2009, Florian Hoech # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA # DEV NOTES # # Currently not implemented in the Manifest class: # * Validation (only very basic sanity checks are currently in place) # * comClass, typelib, comInterfaceProxyStub and windowClass child elements of # the file element # * comInterfaceExternalProxyStub and windowClass child elements of the # assembly element # * Application Configuration File and Multilanguage User Interface (MUI) # support when searching for assembly files # # Isolated Applications and Side-by-side Assemblies: # http://msdn.microsoft.com/en-us/library/dd408052%28VS.85%29.aspx # # Changelog: # 2009-12-17 fix: small glitch in toxml / toprettyxml methods (xml declaration # wasn't replaced when a different encodig than UTF-8 was used) # chg: catch xml.parsers.expat.ExpatError and re-raise as # ManifestXMLParseError # chg: support initialize option in parse method also # # 2009-12-13 fix: fixed os import # fix: skip invalid / empty dependent assemblies # # 2009-08-21 fix: Corrected assembly searching sequence for localized # assemblies # fix: Allow assemblies with no dependent files # # 2009-07-31 chg: Find private assemblies even if unversioned # add: Manifest.same_id method to check if two manifests have the # same assemblyIdentity # # 2009-07-30 fix: Potential failure in File.calc_hash method if hash # algorythm not supported # add: Publisher configuration (policy) support when searching for # assembly files # fix: Private assemblies are now actually found if present (and no # shared assembly exists) # add: Python 2.3 compatibility (oldest version supported by # pyinstaller) # # 2009-07-28 chg: Code cleanup, removed a bit of redundancy # add: silent mode (set silent attribute on module) # chg: Do not print messages in silent mode # # 2009-06-18 chg: Use glob instead of regular expression in Manifest.find_files # # 2009-05-04 fix: Don't fail if manifest has empty description # fix: Manifests created by the toxml, toprettyxml, writexml or # writeprettyxml methods are now correctly recognized by # Windows, which expects the XML declaration to be ordered # version-encoding-standalone (standalone being optional) # add: 'encoding' keyword argument in toxml, toprettyxml, writexml # and writeprettyxml methods # chg: UpdateManifestResourcesFromXML and # UpdateManifestResourcesFromXMLFile: set resource name # depending on file type ie. exe or dll # fix: typo in __main__: UpdateManifestResourcesFromDataFile # should have been UpdateManifestResourcesFromXMLFile # # 2009-03-21 First version """ winmanifest.py Create, parse and write MS Windows Manifest files. Find files which are part of an assembly, by searching shared and private assemblies. Update or add manifest resources in Win32 PE files. Commandline usage: winmanifest.py <dstpath> <xmlpath> Updates or adds manifest <xmlpath> as resource in Win32 PE file <dstpath>. """ try: import hashlib except ImportError, detail: hashlib = None import md5 import sha import os from glob import glob import re import sys import xml from xml.dom import Node, minidom from xml.dom.minidom import Document, Element try: import winresource except ImportError, detail: winresource = None print "W:", detail print "W: Cannot check for assembly dependencies - resource access " print "W: unavailable. To enable resource access, please install " print "W: http://sourceforge.net/projects/pywin32/" try: sys.getwindowsversion except AttributeError: def getwindowsversion(): import win32api return win32api.GetVersionEx(0) sys.getwindowsversion = getwindowsversion silent = False # True suppresses all messages LANGUAGE_NEUTRAL_NT5 = "x-ww" LANGUAGE_NEUTRAL_NT6 = "none" RT_MANIFEST = 24 Document.aChild = Document.appendChild Document.cE = Document.createElement Document.cT = Document.createTextNode Document.getEByTN = Document.getElementsByTagName Element.aChild = Element.appendChild Element.getA = Element.getAttribute Element.getEByTN = Element.getElementsByTagName Element.remA = Element.removeAttribute Element.setA = Element.setAttribute def getChildElementsByTagName(self, tagName): """ Return child elements of type tagName if found, else [] """ result = [] for child in self.childNodes: if isinstance(child, Element): if child.tagName == tagName: result.append(child) return result def getFirstChildElementByTagName(self, tagName): """ Return the first element of type tagName if found, else None """ for child in self.childNodes: if isinstance(child, Element): if child.tagName == tagName: return child return None Document.getCEByTN = getChildElementsByTagName Document.getFCEByTN = getFirstChildElementByTagName Element.getCEByTN = getChildElementsByTagName Element.getFCEByTN = getFirstChildElementByTagName class _Hash(object): def __init__(self): self.md5 = md5.new self.sha = sha.new if hashlib is None: hashlib = _Hash() class _Dummy: pass if winresource: _File = winresource.File else: _File = _Dummy class File(_File): """ A file referenced by an assembly inside a manifest. """ def __init__(self, filename="", hashalg=None, hash=None, comClasses=None, typelibs=None, comInterfaceProxyStubs=None, windowClasses=None): if winresource: winresource.File.__init__(self, filename) else: self.filename = filename self.name = os.path.basename(filename) if hashalg: self.hashalg = hashalg.upper() else: self.hashalg = None if os.path.isfile(filename) and hashalg and hashlib and \ hasattr(hashlib, hashalg.lower()): self.calc_hash() else: self.hash = hash self.comClasses = comClasses or [] # TO-DO: implement self.typelibs = typelibs or [] # TO-DO: implement self.comInterfaceProxyStubs = comInterfaceProxyStubs or [] # TO-DO: implement self.windowClasses = windowClasses or [] # TO-DO: implement def calc_hash(self, hashalg=None): """ Calculate the hash of the file. Will be called automatically from the constructor if the file exists and hashalg is given (and supported), but may also be called manually e.g. to update the hash if the file has changed. """ fd = open(self.filename, "rb") buf = fd.read() fd.close() if hashalg: self.hashalg = hashalg.upper() self.hash = getattr(hashlib, self.hashalg.lower())(buf).hexdigest() def find(self, searchpath): if not silent: print "I: Searching for file", self.name fn = os.path.join(searchpath, self.name) if os.path.isfile(fn): if not silent: print "I: Found file", fn return fn else: if not silent: print "W: No such file", fn return None class InvalidManifestError(Exception): pass class ManifestXMLParseError(InvalidManifestError): pass class Manifest(object): # Manifests: # http://msdn.microsoft.com/en-us/library/aa375365%28VS.85%29.aspx """ Manifest constructor. To build a basic manifest for your application: mf = Manifest(type='win32', name='YourAppName', language='*', processorArchitecture='x86', version=[1, 0, 0, 0]) To write the XML to a manifest file: mf.writexml("YourAppName.exe.manifest") or mf.writeprettyxml("YourAppName.exe.manifest") """ def __init__(self, manifestVersion=None, noInheritable=False, noInherit=False, type_=None, name=None, language=None, processorArchitecture=None, version=None, publicKeyToken=None, description=None, requestedExecutionLevel=None, uiAccess=None, dependentAssemblies=None, files=None, comInterfaceExternalProxyStubs=None): self.filename = None self.optional = None self.manifestType = "assembly" self.manifestVersion = manifestVersion or [1, 0] self.noInheritable = noInheritable self.noInherit = noInherit self.type = type_ self.name = name self.language = language self.processorArchitecture = processorArchitecture self.version = version self.publicKeyToken = publicKeyToken # publicKeyToken: # A 16-character hexadecimal string that represents the last 8 bytes # of the SHA-1 hash of the public key under which the assembly is # signed. The public key used to sign the catalog must be 2048 bits # or greater. Required for all shared side-by-side assemblies. # http://msdn.microsoft.com/en-us/library/aa375692(VS.85).aspx self.applyPublisherPolicy = None self.description = None self.requestedExecutionLevel = requestedExecutionLevel self.uiAccess = uiAccess self.dependentAssemblies = dependentAssemblies or [] self.bindingRedirects = [] self.files = files or [] self.comInterfaceExternalProxyStubs = comInterfaceExternalProxyStubs or [] # TO-DO: implement def add_dependent_assembly(self, manifestVersion=None, noInheritable=False, noInherit=False, type_=None, name=None, language=None, processorArchitecture=None, version=None, publicKeyToken=None, description=None, requestedExecutionLevel=None, uiAccess=None, dependentAssemblies=None, files=None, comInterfaceExternalProxyStubs=None): """ Shortcut for self.dependentAssemblies.append(Manifest(*args, **kwargs)) """ self.dependentAssemblies.append(Manifest(manifestVersion, noInheritable, noInherit, type_, name, language, processorArchitecture, version, publicKeyToken, description, requestedExecutionLevel, uiAccess, dependentAssemblies, files, comInterfaceExternalProxyStubs)) if self.filename: # Enable search for private assembly by assigning bogus filename # (only the directory has to be correct) self.dependentAssemblies[-1].filename = ":".join((self.filename, name)) def add_file(self, name="", hashalg="", hash="", comClasses=None, typelibs=None, comInterfaceProxyStubs=None, windowClasses=None): """ Shortcut for manifest.files.append """ self.files.append(File(name, hashalg, hash, comClasses, typelibs, comInterfaceProxyStubs, windowClasses)) def find_files(self, ignore_policies=True): """ Search shared and private assemblies and return a list of files. If any files are not found, return an empty list. IMPORTANT NOTE: For the purpose of getting the dependent assembly files of an executable, the publisher configuration (aka policy) should be ignored (which is the default). Setting ignore_policies=False is only useful to find out which files are actually loaded at runtime. """ # Shared Assemblies: # http://msdn.microsoft.com/en-us/library/aa375996%28VS.85%29.aspx # # Private Assemblies: # http://msdn.microsoft.com/en-us/library/aa375674%28VS.85%29.aspx # # Assembly Searching Sequence: # http://msdn.microsoft.com/en-us/library/aa374224%28VS.85%29.aspx # # NOTE: # Multilanguage User Interface (MUI) support not yet implemented files = [] languages = [] if self.language not in (None, "", "*", "neutral"): languages.append(self.getlanguage()) if "-" in self.language: # language-culture syntax, e.g. en-us # Add only the language part languages.append(self.language.split("-")[0]) if self.language not in ("en-us", "en"): languages.append("en-us") if self.language != "en": languages.append("en") languages.append(self.getlanguage("*")) winsxs = os.path.join(os.getenv("SystemRoot"), "WinSxS") if not os.path.isdir(winsxs) and not silent: print "W: No such dir", winsxs manifests = os.path.join(winsxs, "Manifests") if not os.path.isdir(manifests) and not silent: print "W: No such dir", manifests if not ignore_policies and self.version: if sys.getwindowsversion() < (6, ): # Windows XP pcfiles = os.path.join(winsxs, "Policies") if not os.path.isdir(pcfiles) and not silent: print "W: No such dir", pcfiles else: # Vista or later pcfiles = manifests for language in languages: version = self.version # Search for publisher configuration if not ignore_policies and version: # Publisher Configuration (aka policy) # A publisher configuration file globally redirects # applications and assemblies having a dependence on one # version of a side-by-side assembly to use another version of # the same assembly. This enables applications and assemblies # to use the updated assembly without having to rebuild all of # the affected applications. # http://msdn.microsoft.com/en-us/library/aa375680%28VS.85%29.aspx # # Under Windows XP and 2003, policies are stored as # <version>.policy files inside # %SystemRoot%\WinSxS\Policies\<name> # Under Vista and later, policies are stored as # <name>.manifest files inside %SystemRoot%\winsxs\Manifests redirected = False if os.path.isdir(pcfiles): if not silent: print ("I: Searching for publisher configuration %s..." % self.getpolicyid(True, language=language)) if sys.getwindowsversion() < (6, ): # Windows XP policies = os.path.join(pcfiles, self.getpolicyid(True, language=language) + ".policy") else: # Vista or later policies = os.path.join(pcfiles, self.getpolicyid(True, language=language) + ".manifest") for manifestpth in glob(policies): if not os.path.isfile(manifestpth): if not silent: print "W: Not a file", manifestpth continue if not silent: print "I: Found", manifestpth try: policy = ManifestFromXMLFile(manifestpth) except Exception, exc: print "E: Could not parse file", manifestpth print "E:", str(exc) else: if not silent: print ("I: Checking publisher policy for " "binding redirects") for assembly in policy.dependentAssemblies: if not assembly.same_id(self, True) or \ assembly.optional: continue for redirect in \ assembly.bindingRedirects: if not silent: old = "-".join([".".join([str(i) for i in part]) for part in redirect[0]]) new = ".".join([str(i) for i in redirect[1]]) print "I: Found redirect for " \ "version(s)", old, "->", new if version >= redirect[0][0] and \ version <= redirect[0][-1] and \ version != redirect[1]: if not silent: print "I: Applying redirect", \ ".".join([str(i) for i in version]), \ "->", new version = redirect[1] redirected = True if not redirected and not silent: print "I: Publisher configuration not used" # Search for assemblies according to assembly searching sequence paths = [] if os.path.isdir(manifests): # Add winsxs search paths paths.extend(glob(os.path.join(manifests, self.getid(language=language, version=version) + "_*.manifest"))) if self.filename: # Add private assembly search paths dirnm = os.path.dirname(self.filename) if language in (LANGUAGE_NEUTRAL_NT5, LANGUAGE_NEUTRAL_NT6): for ext in (".dll", ".manifest"): paths.extend(glob(os.path.join(dirnm, self.name + ext))) paths.extend(glob(os.path.join(dirnm, self.name, self.name + ext))) else: for ext in (".dll", ".manifest"): paths.extend(glob(os.path.join(dirnm, language, self.name + ext))) for ext in (".dll", ".manifest"): paths.extend(glob(os.path.join(dirnm, language, self.name, self.name + ext))) if not silent: print ("I: Searching for assembly %s..." % self.getid(language=language, version=version)) for manifestpth in paths: if not os.path.isfile(manifestpth): if not silent: print "W: Not a file", manifestpth continue assemblynm = os.path.basename( os.path.splitext(manifestpth)[0]) if not silent: if manifestpth.endswith(".dll"): print "I: Found manifest in", manifestpth else: print "I: Found manifest", manifestpth try: if manifestpth.endswith(".dll"): manifest = ManifestFromResFile(manifestpth, [1]) else: manifest = ManifestFromXMLFile(manifestpth) except Exception, exc: print "E: Could not parse manifest", manifestpth print "E:", exc else: if manifestpth.startswith(winsxs): assemblydir = os.path.join(winsxs, assemblynm) if not os.path.isdir(assemblydir): if not silent: print "W: No such dir", assemblydir print "W: Assembly incomplete" return [] else: assemblydir = os.path.dirname(manifestpth) files.append(manifestpth) for file_ in self.files or manifest.files: fn = file_.find(assemblydir) if fn: files.append(fn) else: # If any of our files does not exist, # the assembly is incomplete if not silent: print "W: Assembly incomplete" return [] return files print "W: Assembly not found" return [] def getid(self, language=None, version=None): """ Return an identification string which uniquely names a manifest. This string is a combination of the manifest's processorArchitecture, name, publicKeyToken, version and language. Arguments: version (tuple or list of integers) - If version is given, use it instead of the manifest's version. """ if not self.name: if not silent: print "W: Assembly metadata incomplete" return "" id = [] if self.processorArchitecture: id.append(self.processorArchitecture) id.append(self.name) if self.publicKeyToken: id.append(self.publicKeyToken) if version or self.version: id.append(".".join([str(i) for i in version or self.version])) if not language: language = self.getlanguage() if language: id.append(language) return "_".join(id) def getlanguage(self, language=None, windowsversion=None): """ Get and return the manifest's language as string. Can be either language-culture e.g. 'en-us' or a string indicating language neutrality, e.g. 'x-ww' on Windows XP or 'none' on Vista and later. """ if not language: language = self.language if language in (None, "", "*", "neutral"): return (LANGUAGE_NEUTRAL_NT5, LANGUAGE_NEUTRAL_NT6)[(windowsversion or sys.getwindowsversion()) >= (6, )] return language def getpolicyid(self, fuzzy=True, language=None, windowsversion=None): """ Return an identification string which can be used to find a policy. This string is a combination of the manifest's processorArchitecture, major and minor version, name, publicKeyToken and language. Arguments: fuzzy (boolean) - If False, insert the full version in the id string. Default is True (omit). windowsversion - If not specified (or None), default to (tuple or list of integers) sys.getwindowsversion(). """ if not self.name: if not silent: print "W: Assembly metadata incomplete" return "" id = [] if self.processorArchitecture: id.append(self.processorArchitecture) name = [] name.append("policy") if self.version: name.append(str(self.version[0])) name.append(str(self.version[1])) name.append(self.name) id.append(".".join(name)) if self.publicKeyToken: id.append(self.publicKeyToken) if self.version and (windowsversion or sys.getwindowsversion()) >= (6, ): # Vista and later if fuzzy: id.append("*") else: id.append(".".join([str(i) for i in self.version])) if not language: language = self.getlanguage(windowsversion=windowsversion) if language: id.append(language) id.append("*") id = "_".join(id) if self.version and (windowsversion or sys.getwindowsversion()) < (6, ): # Windows XP if fuzzy: id = os.path.join(id, "*") else: id = os.path.join(id, ".".join([str(i) for i in self.version])) return id def load_dom(self, domtree, initialize=True): """ Load manifest from DOM tree. If initialize is True (default), reset existing attributes first. """ if domtree.nodeType == Node.DOCUMENT_NODE: rootElement = domtree.documentElement elif domtree.nodeType == Node.ELEMENT_NODE: rootElement = domtree else: raise InvalidManifestError("Invalid root element node type " + str(rootElement.nodeType) + " - has to be one of (DOCUMENT_NODE, " "ELEMENT_NODE)") allowed_names = ("assembly", "assemblyBinding", "configuration", "dependentAssembly") if rootElement.tagName not in allowed_names: raise InvalidManifestError( "Invalid root element <%s> - has to be one of <%s>" % (rootElement.tagName, ">, <".join(allowed_names))) # print "I: loading manifest metadata from element <%s>" % \ # rootElement.tagName if rootElement.tagName == "configuration": for windows in rootElement.getCEByTN("windows"): for assemblyBinding in windows.getCEByTN("assemblyBinding"): self.load_dom(assemblyBinding, initialize) else: if initialize: self.__init__() self.manifestType = rootElement.tagName self.manifestVersion = [int(i) for i in (rootElement.getA("manifestVersion") or "1.0").split(".")] self.noInheritable = bool(rootElement.getFCEByTN("noInheritable")) self.noInherit = bool(rootElement.getFCEByTN("noInherit")) for assemblyIdentity in rootElement.getCEByTN("assemblyIdentity"): self.type = assemblyIdentity.getA("type") or None self.name = assemblyIdentity.getA("name") or None self.language = assemblyIdentity.getA("language") or None self.processorArchitecture = assemblyIdentity.getA( "processorArchitecture") or None version = assemblyIdentity.getA("version") if version: self.version = [int(i) for i in version.split(".")] self.publicKeyToken = assemblyIdentity.getA("publicKeyToken") or None for publisherPolicy in rootElement.getCEByTN("publisherPolicy"): self.applyPublisherPolicy = (publisherPolicy.getA("apply") or "").lower() == "yes" for description in rootElement.getCEByTN("description"): if description.firstChild: self.description = description.firstChild.wholeText for trustInfo in rootElement.getCEByTN("trustInfo"): for security in trustInfo.getCEByTN("security"): for requestedPrivileges in \ security.getCEByTN("requestedPrivileges"): for requestedExecutionLevel in \ requestedPrivileges.getCEByTN( "requestedExecutionLevel"): self.requestedExecutionLevel = \ requestedExecutionLevel.getA("level") self.uiAccess = ( requestedExecutionLevel.getA("uiAccess") or "").lower() == "true" if rootElement.tagName == "assemblyBinding": dependencies = [rootElement] else: dependencies = rootElement.getCEByTN("dependency") for dependency in dependencies: for dependentAssembly in dependency.getCEByTN( "dependentAssembly"): manifest = ManifestFromDOM(dependentAssembly) if not manifest.name: # invalid, skip continue manifest.optional = (dependency.getA("optional") or "").lower() == "yes" self.dependentAssemblies.append(manifest) if self.filename: # Enable search for private assembly by assigning bogus # filename (only the directory has to be correct) self.dependentAssemblies[-1].filename = ":".join( (self.filename, manifest.name)) for bindingRedirect in rootElement.getCEByTN("bindingRedirect"): oldVersion = [[int(i) for i in part.split(".")] for part in bindingRedirect.getA("oldVersion").split("-")] newVersion = [int(i) for i in bindingRedirect.getA("newVersion").split(".")] self.bindingRedirects.append((oldVersion, newVersion)) for file_ in rootElement.getCEByTN("file"): self.add_file(name=file_.getA("name"), hashalg=file_.getA("hashalg"), hash=file_.getA("hash")) def parse(self, filename_or_file, initialize=True): """ Load manifest from file or file object """ if isinstance(filename_or_file, (str, unicode)): filename = filename_or_file else: filename = filename_or_file.name try: domtree = minidom.parse(filename_or_file) except xml.parsers.expat.ExpatError, e: args = [e.args[0]] if isinstance(filename, unicode): filename = filename.encode(sys.getdefaultencoding(), "replace") args.insert(0, '\n File "%s"\n ' % filename) raise ManifestXMLParseError(" ".join([str(arg) for arg in args])) if initialize: self.__init__() self.filename = filename self.load_dom(domtree, False) def parse_string(self, xmlstr, initialize=True): """ Load manifest from XML string """ try: domtree = minidom.parseString(xmlstr) except xml.parsers.expat.ExpatError, e: raise ManifestXMLParseError(e) self.load_dom(domtree, initialize) def same_id(self, manifest, skip_version_check=False): """ Return a bool indicating if another manifest has the same identitiy. This is done by comparing language, name, processorArchitecture, publicKeyToken, type and version. """ if skip_version_check: version_check = True else: version_check = self.version == manifest.version return (self.language == manifest.language and self.name == manifest.name and self.processorArchitecture == manifest.processorArchitecture and self.publicKeyToken == manifest.publicKeyToken and self.type == manifest.type and version_check) def todom(self): """ Return the manifest as DOM tree """ doc = Document() docE = doc.cE(self.manifestType) if self.manifestType == "assemblyBinding": cfg = doc.cE("configuration") win = doc.cE("windows") win.aChild(docE) cfg.aChild(win) doc.aChild(cfg) else: doc.aChild(docE) if self.manifestType != "dependentAssembly": docE.setA("xmlns", "urn:schemas-microsoft-com:asm.v1") if self.manifestType != "assemblyBinding": docE.setA("manifestVersion", ".".join([str(i) for i in self.manifestVersion])) if self.noInheritable: docE.aChild(doc.cE("noInheritable")) if self.noInherit: docE.aChild(doc.cE("noInherit")) aId = doc.cE("assemblyIdentity") if self.type: aId.setAttribute("type", self.type) if self.name: aId.setAttribute("name", self.name) if self.language: aId.setAttribute("language", self.language) if self.processorArchitecture: aId.setAttribute("processorArchitecture", self.processorArchitecture) if self.version: aId.setAttribute("version", ".".join([str(i) for i in self.version])) if self.publicKeyToken: aId.setAttribute("publicKeyToken", self.publicKeyToken) if aId.hasAttributes(): docE.aChild(aId) else: aId.unlink() if self.applyPublisherPolicy != None: ppE = doc.cE("publisherPolicy") if self.applyPublisherPolicy: ppE.setA("apply", "yes") else: ppE.setA("apply", "no") docE.aChild(ppE) if self.description: descE = doc.cE("description") descE.aChild(doc.cT(self.description)) docE.aChild(descE) if self.requestedExecutionLevel in ("asInvoker", "highestAvailable", "requireAdministrator"): tE = doc.cE("trustInfo") tE.setA("xmlns", "urn:schemas-microsoft-com:asm.v3") sE = doc.cE("security") rpE = doc.cE("requestedPrivileges") relE = doc.cE("requestedExecutionLevel") relE.setA("level", self.requestedExecutionLevel) if self.uiAccess: relE.setA("uiAccess", "true") else: relE.setA("uiAccess", "false") rpE.aChild(relE) sE.aChild(rpE) tE.aChild(sE) docE.aChild(tE) if self.dependentAssemblies: for assembly in self.dependentAssemblies: if self.manifestType != "assemblyBinding": dE = doc.cE("dependency") if assembly.optional: dE.setAttribute("optional", "yes") daE = doc.cE("dependentAssembly") adom = assembly.todom() for child in adom.documentElement.childNodes: daE.aChild(child.cloneNode(False)) adom.unlink() if self.manifestType != "assemblyBinding": dE.aChild(daE) docE.aChild(dE) else: docE.aChild(daE) if self.bindingRedirects: for bindingRedirect in self.bindingRedirects: brE = doc.cE("bindingRedirect") brE.setAttribute("oldVersion", "-".join([".".join([str(i) for i in part]) for part in bindingRedirect[0]])) brE.setAttribute("newVersion", ".".join([str(i) for i in bindingRedirect[1]])) docE.aChild(brE) if self.files: for file_ in self.files: fE = doc.cE("file") for attr in ("name", "hashalg", "hash"): val = getattr(file_, attr) if val: fE.setA(attr, val) docE.aChild(fE) return doc def toprettyxml(self, indent=" ", newl=os.linesep, encoding="UTF-8"): """ Return the manifest as pretty-printed XML """ domtree = self.todom() # WARNING: The XML declaration has to follow the order # version-encoding-standalone (standalone being optional), otherwise # if it is embedded in an exe the exe will fail to launch! # ('application configuration incorrect') if sys.version_info >= (2,3): xmlstr = domtree.toprettyxml(indent, newl, encoding) else: xmlstr = domtree.toprettyxml(indent, newl) xmlstr = xmlstr.strip(os.linesep).replace( '<?xml version="1.0" encoding="%s"?>' % encoding, '<?xml version="1.0" encoding="%s" standalone="yes"?>' % encoding) domtree.unlink() return xmlstr def toxml(self, encoding="UTF-8"): """ Return the manifest as XML """ domtree = self.todom() # WARNING: The XML declaration has to follow the order # version-encoding-standalone (standalone being optional), otherwise # if it is embedded in an exe the exe will fail to launch! # ('application configuration incorrect') xmlstr = domtree.toxml(encoding).replace( '<?xml version="1.0" encoding="%s"?>' % encoding, '<?xml version="1.0" encoding="%s" standalone="yes"?>' % encoding) domtree.unlink() return xmlstr def update_resources(self, dstpath, names=None, languages=None): """ Update or add manifest resource in dll/exe file dstpath """ UpdateManifestResourcesFromXML(dstpath, self.toprettyxml(), names, languages) def writeprettyxml(self, filename_or_file=None, indent=" ", newl=os.linesep, encoding="UTF-8"): """ Write the manifest as XML to a file or file object """ if not filename_or_file: filename_or_file = self.filename if isinstance(filename_or_file, (str, unicode)): filename_or_file = open(filename_or_file, "wb") xmlstr = self.toprettyxml(indent, newl, encoding) filename_or_file.write(xmlstr) filename_or_file.close() def writexml(self, filename_or_file=None, indent=" ", newl=os.linesep, encoding="UTF-8"): """ Write the manifest as XML to a file or file object """ if not filename_or_file: filename_or_file = self.filename if isinstance(filename_or_file, (str, unicode)): filename_or_file = open(filename_or_file, "wb") xmlstr = self.toxml(indent, newl, encoding) filename_or_file.write(xmlstr) filename_or_file.close() def ManifestFromResFile(filename, names=None, languages=None): """ Create and return manifest instance from resource in dll/exe file """ res = GetManifestResources(filename, names, languages) pth = [] if res and res[RT_MANIFEST]: while isinstance(res, dict) and res.keys(): key = res.keys()[0] pth.append(str(key)) res = res[key] if isinstance(res, dict): raise InvalidManifestError("No matching manifest resource found in '%s'" % filename) manifest = Manifest() manifest.filename = ":".join([filename] + pth) manifest.parse_string(res, False) return manifest def ManifestFromDOM(domtree): """ Create and return manifest instance from DOM tree """ manifest = Manifest() manifest.load_dom(domtree) return manifest def ManifestFromXML(xmlstr): """ Create and return manifest instance from XML """ manifest = Manifest() manifest.parse_string(xmlstr) return manifest def ManifestFromXMLFile(filename_or_file): """ Create and return manifest instance from file """ manifest = Manifest() manifest.parse(filename_or_file) return manifest def GetManifestResources(filename, names=None, languages=None): """ Get manifest resources from file """ return winresource.GetResources(filename, [RT_MANIFEST], names, languages) def UpdateManifestResourcesFromXML(dstpath, xmlstr, names=None, languages=None): """ Update or add manifest XML as resource in dstpath """ if not silent: print "I: Updating manifest in", dstpath if dstpath.lower().endswith(".exe"): name = 1 else: name = 2 winresource.UpdateResources(dstpath, xmlstr, RT_MANIFEST, names or [name], languages or [0, "*"]) def UpdateManifestResourcesFromXMLFile(dstpath, srcpath, names=None, languages=None): """ Update or add manifest XML from srcpath as resource in dstpath """ if not silent: print "I: Updating manifest from", srcpath, "in", dstpath if dstpath.lower().endswith(".exe"): name = 1 else: name = 2 winresource.UpdateResourcesFromDataFile(dstpath, srcpath, RT_MANIFEST, names or [name], languages or [0, "*"]) if __name__ == "__main__": dstpath = sys.argv[1] srcpath = sys.argv[2] UpdateManifestResourcesFromXMLFile(dstpath, srcpath)
Python
# # Copyright (C) 2005, Giovanni Bajo # # Based on previous work under copyright (c) 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # In addition to the permissions in the GNU General Public License, the # authors give you unlimited permission to link or embed the compiled # version of this file into combinations with other programs, and to # distribute those combinations without any restriction coming from the # use of this file. (The General Public License restrictions do apply in # other respects; for example, they cover modification of the file, and # distribution when not linked into a combine executable.) # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA # # # **NOTE** This module is used during bootstrap. Import *ONLY* builtin modules. # import sys import imp import marshal try: py_version = sys.version_info except AttributeError: py_version = (1,5) try: # zipimport is supported starting with Python 2.3 import zipimport except ImportError: zipimport = None try: STRINGTYPE = basestring except NameError: STRINGTYPE = type("") def debug(msg): if 0: sys.stderr.write(msg+"\n") #=======================Owners==========================# # An Owner does imports from a particular piece of turf # That is, there's an Owner for each thing on sys.path # There are owners for directories and .pyz files. # There could be owners for zip files, or even URLs. # A shadowpath (a dictionary mapping the names in # sys.path to their owners) is used so that sys.path # (or a package's __path__) is still a bunch of strings, class OwnerError(IOError): def __str__(self): return "<OwnerError %s>" % self.message class Owner: def __init__(self, path): self.path = path def __str__(self): return self.path def getmod(self, nm): return None class DirOwner(Owner): def __init__(self, path): if path == '': path = _os_getcwd() if not pathisdir(path): raise OwnerError("%s is not a directory" % path) Owner.__init__(self, path) def getmod(self, nm, getsuffixes=imp.get_suffixes, loadco=marshal.loads, newmod=imp.new_module): pth = _os_path_join(self.path, nm) possibles = [(pth, 0, None)] if pathisdir(pth) and caseOk(pth): possibles.insert(0, (_os_path_join(pth, '__init__'), 1, pth)) py = pyc = None for pth, ispkg, pkgpth in possibles: for ext, mode, typ in getsuffixes(): attempt = pth+ext try: st = _os_stat(attempt) except OSError, e: assert e.errno == 2 #[Errno 2] No such file or directory else: # Check case if not caseOk(attempt): continue if typ == imp.C_EXTENSION: fp = open(attempt, 'rb') mod = imp.load_module(nm, fp, attempt, (ext, mode, typ)) mod.__file__ = attempt return mod elif typ == imp.PY_SOURCE: py = (attempt, st) else: pyc = (attempt, st) if py or pyc: break if py is None and pyc is None: return None while 1: if pyc is None or py and pyc[1][8] < py[1][8]: try: co = compile(open(py[0], 'r').read()+'\n', py[0], 'exec') break except SyntaxError, e: print "Invalid syntax in %s" % py[0] print e.args raise elif pyc: stuff = open(pyc[0], 'rb').read() try: co = loadco(stuff[8:]) break except (ValueError, EOFError): pyc = None else: return None mod = newmod(nm) mod.__file__ = co.co_filename if ispkg: mod.__path__ = [pkgpth] subimporter = PathImportDirector(mod.__path__) mod.__importsub__ = subimporter.getmod mod.__co__ = co return mod ZipOwner = None if zipimport: class ZipOwner(Owner): def __init__(self, path): try: self.__zip = zipimport.zipimporter(path) except zipimport.ZipImportError, e: raise OwnerError('%s: %s' % (str(e), path)) Owner.__init__(self, path) def getmod(self, nm, newmod=imp.new_module): # We cannot simply use zipimport.load_module here # because it both loads (= create module object) # and imports (= execute bytecode). Instead, our # getmod() functions are supposed to only load the modules. # Note that imp.load_module() does the right thing, instead. debug('zipimport try: %s within %s' % (nm, self.__zip)) try: co = self.__zip.get_code(nm) mod = newmod(nm) mod.__file__ = co.co_filename if self.__zip.is_package(nm): mod.__path__ = [_os_path_join(self.path, nm)] subimporter = PathImportDirector(mod.__path__) mod.__importsub__ = subimporter.getmod if self.path.endswith(".egg"): # Fixup some additional special attribute so that # pkg_resources works correctly. # TODO: couldn't we fix these attributes always, # for all zip files? mod.__file__ = _os_path_join( _os_path_join(self.path, nm), "__init__.py") mod.__loader__ = self.__zip mod.__co__ = co return mod except zipimport.ZipImportError: debug('zipimport not found %s' % nm) return None # _mountzlib.py will insert archive.PYZOwner in front later _globalownertypes = filter(None, [ ZipOwner, DirOwner, Owner, ]) #===================Import Directors====================================# # ImportDirectors live on the metapath # There's one for builtins, one for frozen modules, and one for sys.path # Windows gets one for modules gotten from the Registry # Mac would have them for PY_RESOURCE modules etc. # A generalization of Owner - their concept of "turf" is broader class ImportDirector(Owner): pass class BuiltinImportDirector(ImportDirector): def __init__(self): self.path = 'Builtins' def getmod(self, nm, isbuiltin=imp.is_builtin): if isbuiltin(nm): mod = imp.load_module(nm, None, nm, ('','',imp.C_BUILTIN)) return mod return None class FrozenImportDirector(ImportDirector): def __init__(self): self.path = 'FrozenModules' def getmod(self, nm, isfrozen=imp.is_frozen): if isfrozen(nm): mod = imp.load_module(nm, None, nm, ('','',imp.PY_FROZEN)) if hasattr(mod, '__path__'): mod.__importsub__ = lambda name, pname=nm, owner=self: owner.getmod(pname+'.'+name) return mod return None class RegistryImportDirector(ImportDirector): # for Windows only def __init__(self): self.path = "WindowsRegistry" self.map = {} try: import win32api ## import win32con except ImportError: pass else: HKEY_CURRENT_USER = -2147483647 HKEY_LOCAL_MACHINE = -2147483646 KEY_ALL_ACCESS = 983103 KEY_READ = 131097 subkey = r"Software\Python\PythonCore\%s\Modules" % sys.winver for root in (HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE): try: #hkey = win32api.RegOpenKeyEx(root, subkey, 0, KEY_ALL_ACCESS) hkey = win32api.RegOpenKeyEx(root, subkey, 0, KEY_READ) except Exception: # If the key does not exist, simply try the next one. pass else: numsubkeys, numvalues, lastmodified = win32api.RegQueryInfoKey(hkey) for i in range(numsubkeys): subkeyname = win32api.RegEnumKey(hkey, i) #hskey = win32api.RegOpenKeyEx(hkey, subkeyname, 0, KEY_ALL_ACCESS) hskey = win32api.RegOpenKeyEx(hkey, subkeyname, 0, KEY_READ) val = win32api.RegQueryValueEx(hskey, '') desc = getDescr(val[0]) self.map[subkeyname] = (val[0], desc) hskey.Close() hkey.Close() break def getmod(self, nm): stuff = self.map.get(nm) if stuff: fnm, desc = stuff fp = open(fnm, 'rb') mod = imp.load_module(nm, fp, fnm, desc) mod.__file__ = fnm return mod return None class PathImportDirector(ImportDirector): def __init__(self, pathlist=None, importers=None, ownertypes=None): self.path = pathlist if ownertypes == None: self.ownertypes = _globalownertypes else: self.ownertypes = ownertypes if importers: self.shadowpath = importers else: self.shadowpath = {} self.inMakeOwner = 0 self.building = {} def __str__(self): return str(self.path or sys.path) def getmod(self, nm): mod = None for thing in (self.path or sys.path): if isinstance(thing, STRINGTYPE): owner = self.shadowpath.get(thing, -1) if owner == -1: owner = self.shadowpath[thing] = self.makeOwner(thing) if owner: mod = owner.getmod(nm) else: mod = thing.getmod(nm) if mod: break return mod def makeOwner(self, path): if self.building.get(path): return None self.building[path] = 1 owner = None for klass in self.ownertypes: try: # this may cause an import, which may cause recursion # hence the protection owner = klass(path) except OwnerError, e: pass else: break del self.building[path] return owner def getDescr(fnm): ext = getpathext(fnm) for (suffix, mode, typ) in imp.get_suffixes(): if suffix == ext: return (suffix, mode, typ) #=================ImportManager============================# # The one-and-only ImportManager # ie, the builtin import UNTRIED = -1 class ImportManagerException(Exception): def __init__(self, args): self.args = args def __repr__(self): return "<%s: %s>" % (self.__name__, self.args) class ImportManager: # really the equivalent of builtin import def __init__(self): self.metapath = [ BuiltinImportDirector(), FrozenImportDirector(), RegistryImportDirector(), PathImportDirector() ] self.threaded = 0 self.rlock = None self.locker = None self.setThreaded() def setThreaded(self): thread = sys.modules.get('thread', None) if thread and not self.threaded: #debug("iu setting threaded") self.threaded = 1 self.rlock = thread.allocate_lock() self._get_ident = thread.get_ident def install(self): import __builtin__ __builtin__.__import__ = self.importHook __builtin__.reload = self.reloadHook def importHook(self, name, globals=None, locals=None, fromlist=None, level=-1): __globals_name = None if globals: __globals_name = globals.get('__name__') # first see if we could be importing a relative name debug("importHook(%s, %s, locals, %s, %s)" % (name, __globals_name, fromlist, level)) _sys_modules_get = sys.modules.get _self_doimport = self.doimport threaded = self.threaded # break the name being imported up so we get: # a.b.c -> [a, b, c] nmparts = namesplit(name) if not globals: contexts = [None] if level > 0: raise RuntimeError("Relative import requires 'globals'") elif level == 0: # absolute import, do not try relative contexts = [None] else: # level != 0 importernm = globals.get('__name__', '') ispkg = hasattr(_sys_modules_get(importernm), '__path__') debug('importernm %s' % importernm) if level < 0: # behaviour up to Python 2.4 (and default in Python 2.5) # add the package to searched contexts contexts = [None] else: # relative import, do not try absolute if not importernm: raise RuntimeError("Relative import requires package") # level=1 => current package # level=2 => previous package => drop 1 level if level > 1: importernm = _string_split(importernm, '.')[:-level+1] importernm = _string_join('.', importernm) contexts = [None] if importernm: if ispkg: # If you use the "from __init__ import" syntax, the package # name will have a __init__ in it. We want to strip it. if importernm[-len(".__init__"):] == ".__init__": importernm = importernm[:-len(".__init__")] contexts.insert(0,importernm) else: pkgnm = packagename(importernm) if pkgnm: contexts.insert(0, pkgnm) # so contexts is [pkgnm, None], [pkgnm] or just [None] for context in contexts: ctx = context i = 0 for i in range(len(nmparts)): nm = nmparts[i] debug(" importHook trying %s in %s" % (nm, ctx)) if ctx: fqname = ctx + '.' + nm else: fqname = nm if threaded: self._acquire() try: mod = _sys_modules_get(fqname, UNTRIED) if mod is UNTRIED: debug('trying %s %s %s' % (nm, ctx, fqname)) mod = _self_doimport(nm, ctx, fqname) finally: if threaded: self._release() if mod: ctx = fqname else: break else: # no break, point i beyond end i = i + 1 if i: break if i<len(nmparts): if ctx and hasattr(sys.modules[ctx], nmparts[i]): debug("importHook done with %s %s %s (case 1)" % (name, __globals_name, fromlist)) return sys.modules[nmparts[0]] del sys.modules[fqname] raise ImportError, "No module named %s" % fqname if not fromlist: debug("importHook done with %s %s %s (case 2)" % (name, __globals_name, fromlist)) if context: return sys.modules[context+'.'+nmparts[0]] return sys.modules[nmparts[0]] bottommod = sys.modules[ctx] if hasattr(bottommod, '__path__'): fromlist = list(fromlist) i = 0 while i < len(fromlist): nm = fromlist[i] if nm == '*': fromlist[i:i+1] = list(getattr(bottommod, '__all__', [])) if i >= len(fromlist): break nm = fromlist[i] i = i + 1 if not hasattr(bottommod, nm): if threaded: self._acquire() try: mod = self.doimport(nm, ctx, ctx+'.'+nm) finally: if threaded: self._release() debug("importHook done with %s %s %s (case 3)" % (name, __globals_name, fromlist)) return bottommod def doimport(self, nm, parentnm, fqname, reload=0): # Not that nm is NEVER a dotted name at this point debug("doimport(%s, %s, %s)" % (nm, parentnm, fqname)) if parentnm: parent = sys.modules[parentnm] if hasattr(parent, '__path__'): importfunc = getattr(parent, '__importsub__', None) if not importfunc: subimporter = PathImportDirector(parent.__path__) importfunc = parent.__importsub__ = subimporter.getmod debug("using parent's importfunc: %s" % importfunc) mod = importfunc(nm) if mod and not reload: setattr(parent, nm, mod) else: debug("..parent not a package") return None else: parent = None # now we're dealing with an absolute import for director in self.metapath: mod = director.getmod(nm) if mod: break if mod: mod.__name__ = fqname if reload: sys.modules[fqname].__dict__.update(mod.__dict__) else: sys.modules[fqname] = mod if hasattr(mod, '__co__'): co = mod.__co__ del mod.__co__ try: if reload: exec co in sys.modules[fqname].__dict__ else: exec co in mod.__dict__ except: # In Python 2.4 and above, sys.modules is left clean # after a broken import. We need to do the same to # achieve perfect compatibility (see ticket #32). if py_version >= (2,4,0): # FIXME: how can we recover from a broken reload()? # Should we save the mod dict and restore it in case # of failure? if not reload: # Some modules (eg: dbhash.py) cleanup # sys.modules themselves. We should then # be lenient and avoid errors. sys.modules.pop(fqname, None) if hasattr(parent, nm): delattr(parent, nm) raise if fqname == 'thread' and not self.threaded: #debug("thread detected!") self.setThreaded() else: sys.modules[fqname] = None debug("..found %s when looking for %s" % (mod, fqname)) return mod def reloadHook(self, mod): fqnm = mod.__name__ nm = namesplit(fqnm)[-1] parentnm = packagename(fqnm) newmod = self.doimport(nm, parentnm, fqnm, reload=1) #mod.__dict__.update(newmod.__dict__) return newmod def _acquire(self): if self.rlock.locked(): if self.locker == self._get_ident(): self.lockcount = self.lockcount + 1 #debug("_acquire incrementing lockcount to %s" % self.lockcount) return self.rlock.acquire() self.locker = self._get_ident() self.lockcount = 0 #debug("_acquire first time!") def _release(self): if self.lockcount: self.lockcount = self.lockcount - 1 #debug("_release decrementing lockcount to %s" % self.lockcount) else: self.locker = None self.rlock.release() #debug("_release releasing lock!") #========= some helper functions =============================# def packagename(s): for i in range(len(s)-1, -1, -1): if s[i] == '.': break else: return '' return s[:i] def namesplit(s): rslt = [] i = j = 0 for j in range(len(s)): if s[j] == '.': rslt.append(s[i:j]) i = j+1 if i < len(s): rslt.append(s[i:]) return rslt def getpathext(fnm): for i in range(len(fnm)-1, -1, -1): if fnm[i] == '.': return fnm[i:] return '' def pathisdir(pathname): "Local replacement for os.path.isdir()." try: s = _os_stat(pathname) except OSError: return None return (s[0] & 0170000) == 0040000 _os_stat = _os_path_join = _os_getcwd = _os_path_dirname = _os_environ = _os_listdir = _os_path_basename = None def _os_bootstrap(): "Set up 'os' module replacement functions for use during import bootstrap." global _os_stat, _os_path_join, _os_path_dirname, _os_getcwd, _os_environ, _os_listdir, _os_path_basename names = sys.builtin_module_names join = dirname = environ = listdir = basename = None mindirlen = 0 if 'posix' in names: from posix import stat, getcwd, environ, listdir sep = '/' mindirlen = 1 elif 'nt' in names: from nt import stat, getcwd, environ, listdir sep = '\\' mindirlen = 3 elif 'dos' in names: from dos import stat, getcwd, environ, listdir sep = '\\' mindirlen = 3 elif 'os2' in names: from os2 import stat, getcwd, environ, listdir sep = '\\' elif 'mac' in names: from mac import stat, getcwd, environ, listdir def join(a, b): if a == '': return b path = s if ':' not in a: a = ':' + a if a[-1:] != ':': a = a + ':' return a + b else: raise ImportError, 'no os specific module found' if join is None: def join(a, b, sep=sep): if a == '': return b lastchar = a[-1:] if lastchar == '/' or lastchar == sep: return a + b return a + sep + b if dirname is None: def dirname(a, sep=sep, mindirlen=mindirlen): for i in range(len(a)-1, -1, -1): c = a[i] if c == '/' or c == sep: if i < mindirlen: return a[:i+1] return a[:i] return '' if basename is None: def basename(p): i = p.rfind(sep) if i == -1: return p else: return p[i + len(sep):] def _listdir(dir, cache={}): # since this function is only used by caseOk, it's fine to cache the # results and avoid reading the whole contents of a directory each time # we just want to check the case of a filename. if not dir in cache: cache[dir] = listdir(dir) return cache[dir] _os_stat = stat _os_getcwd = getcwd _os_path_join = join _os_path_dirname = dirname _os_environ = environ _os_listdir = _listdir _os_path_basename = basename _string_replace = _string_join = _string_split = None def _string_bootstrap(): """ Set up 'string' module replacement functions for use during import bootstrap. During bootstrap, we can use only builtin modules since import does not work yet. For Python 2.0+, we can use string methods so this is not a problem. For Python 1.5, we would need the string module, so we need replacements. """ global _string_replace, _string_join, _string_split def join(sep, words): res = '' for w in words: res = res + (sep + w) return res[len(sep):] def split(s, sep, maxsplit=0): res = [] nsep = len(sep) if nsep == 0: return [s] ns = len(s) if maxsplit <= 0: maxsplit = ns i = j = 0 count = 0 while j+nsep <= ns: if s[j:j+nsep] == sep: count = count + 1 res.append(s[i:j]) i = j = j + nsep if count >= maxsplit: break else: j = j + 1 res.append(s[i:]) return res def replace(str, old, new): return _string_join(new, _string_split(str, old)) _string_join = getattr(STRINGTYPE, "join", join) _string_split = getattr(STRINGTYPE, "split", split) _string_replace = getattr(STRINGTYPE, "replace", replace) _os_bootstrap() if not _os_environ.has_key('PYTHONCASEOK') and sys.version_info >= (2, 1): def caseOk(filename): files = _os_listdir(_os_path_dirname(filename)) return _os_path_basename(filename) in files else: def caseOk(filename): return True _string_bootstrap()
Python
#! /usr/bin/env python # # Wrapper around Configure.py / Makespec.py / Build.py # # Copyright (C) 2010, Martin Zibricky # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA import os import sys import Configure import Makespec import Build HOME = os.path.dirname(sys.argv[0]) def run_configure(opts, args): Configure.opts = opts Configure.args = args Configure.main(opts.configfile) def run_makespec(opts, args): # Split pathex by using the path separator temppaths = opts.pathex[:] opts.pathex = [] for p in temppaths: opts.pathex.extend(p.split(os.pathsep)) spec_file = Makespec.main(args, **opts.__dict__) print "wrote %s" % spec_file return spec_file def run_build(opts, args, spec_file): Build.opts = opts Build.args = args Build.main(spec_file, configfilename=opts.configfile) def main(parser): opts, args = parser.parse_args() if not args: parser.error('Requires at least one scriptname file or exactly one .spec-file') # Skip configuring when using the same python as specified in config.dat try: config = Build._load_data(opts.configfile) if config['pythonVersion'] == sys.version: print 'I: skip Configure.py, use existing config', opts.configfile else: run_configure(opts, args) except IOError, SyntaxError: run_configure(opts, args) # Skip creating .spec when .spec file is supplied if args[0].endswith('.spec'): spec_file = args[0] else: spec_file = run_makespec(opts, args) run_build(opts, args, spec_file) if __name__ == '__main__': from pyi_optparse import OptionParser parser = OptionParser( usage="python %prog [opts] <scriptname> [ <scriptname> ...] | <specfile>" ) # Configure.py options g = parser.add_option_group('Python environment') g.add_option('--target-platform', default=None, help='Target platform, required for cross-bundling ' '(default: current platform).') g.add_option('--upx-dir', default=None, help='Directory containing UPX.') g.add_option('--executable', default=None, help='Python executable to use. Required for ' 'cross-bundling.') g.add_option('-C', '--configfile', default=os.path.join(HOME, 'config.dat'), help='Name of generated configfile (default: %default)') # Makespec.py options g = parser.add_option_group('What to generate') g.add_option("-F", "--onefile", dest="freeze", action="store_true", default=False, help="create a single file deployment") g.add_option("-D", "--onedir", dest="freeze", action="store_false", help="create a single directory deployment (default)") g.add_option("-o", "--out", type="string", default=None, dest="workdir", metavar="DIR", help="generate the spec file in the specified directory " "(default: current directory") g.add_option("-n", "--name", type="string", default=None, metavar="NAME", help="name to assign to the project " "(default: first script's basename)") g = parser.add_option_group('What to bundle, where to search') g.add_option("-p", "--paths", type="string", default=[], dest="pathex", metavar="DIR", action="append", help="set base path for import (like using PYTHONPATH). " "Multiple directories are allowed, separating them " "with %s, or using this option multiple times" % repr(os.pathsep)) g.add_option("-K", "--tk", default=False, action="store_true", help="include TCL/TK in the deployment") g.add_option("-a", "--ascii", action="store_true", default=False, help="do NOT include unicode encodings " "(default: included if available)") g = parser.add_option_group('How to generate') g.add_option("-d", "--debug", action="store_true", default=False, help="use the debug (verbose) build of the executable") g.add_option("-s", "--strip", action="store_true", default=False, help="strip the exe and shared libs " "(don't try this on Windows)") g.add_option("-X", "--upx", action="store_true", default=True, help="use UPX if available (works differently between " "Windows and *nix)") #p.add_option("-Y", "--crypt", type="string", default=None, metavar="FILE", # help="encrypt pyc/pyo files") g = parser.add_option_group('Windows specific options') g.add_option("-c", "--console", "--nowindowed", dest="console", action="store_true", help="use a console subsystem executable (Windows only) " "(default)") g.add_option("-w", "--windowed", "--noconsole", dest="console", action="store_false", default=True, help="use a Windows subsystem executable (Windows only)") g.add_option("-v", "--version", type="string", dest="version_file", metavar="FILE", help="add a version resource from FILE to the exe " "(Windows only)") g.add_option("-i", "--icon", type="string", dest="icon_file", metavar="FILE.ICO or FILE.EXE,ID", help="If FILE is an .ico file, add the icon to the final " "executable. Otherwise, the syntax 'file.exe,id' to " "extract the icon with the specified id " "from file.exe and add it to the final executable") g.add_option("-m", "--manifest", type="string", dest="manifest", metavar="FILE or XML", help="add manifest FILE or XML to the exe " "(Windows only)") g.add_option("-r", "--resource", type="string", default=[], dest="resources", metavar="FILE[,TYPE[,NAME[,LANGUAGE]]]", action="append", help="add/update resource of the given type, name and language " "from FILE to the final executable. FILE can be a " "data file or an exe/dll. For data files, atleast " "TYPE and NAME need to be specified, LANGUAGE defaults " "to 0 or may be specified as wildcard * to update all " "resources of the given TYPE and NAME. For exe/dll " "files, all resources from FILE will be added/updated " "to the final executable if TYPE, NAME and LANGUAGE " "are omitted or specified as wildcard *." "Multiple resources are allowed, using this option " "multiple times.") # Build.py options g = parser.add_option_group('Build options') g.add_option('--buildpath', default=os.path.join('SPECPATH', 'build', 'pyi.TARGET_PLATFORM', 'SPECNAME'), help='Buildpath (default: %default)') g.add_option('-y', '--noconfirm', action="store_true", default=False, help='Remove output directory (default: %s) without ' 'confirmation' % os.path.join('SPECPATH', 'dist')) main(parser)
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA attrs = [('ReleaseNode',0), ('StrStream',0), ('BaseUriResolver',0), ('BASIC_RESOLVER',0), ('Reader',0), ]
Python
hiddenimports = ['sip', 'PyQt4.QtCore', 'PyQt4._qt'] from hooks.hookutils import qt4_plugins_dir pdir = qt4_plugins_dir() datas = [ (pdir + "/script/*.so", "qt4_plugins/script"), (pdir + "/script/*.dll", "qt4_plugins/script"), (pdir + "/script/*.dylib", "qt4_plugins/script"), ]
Python
# Compiler module (see class DatabaseOperations) hiddenimports = ["django.db.backends.mysql.compiler"]
Python
# some modules use the old-style import: explicitly include # the new module when the old one is referenced hiddenimports = ["email.mime.text", "email.mime.multipart"]
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA # Forward to shared code for PIL. PIL can be imported either as a top-level package # (from PIL import Image), or not (import Image), because it installs a # PIL.pth. from hooks.shared_PIL_Image import *
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #encodings', attrs = [('search_function',0)] import os, sys, glob from distutils import sysconfig hiddenimports = [] libpath = sysconfig.get_python_lib(plat_specific=0, standard_lib=1) for f in glob.glob(os.path.join(libpath, "encodings", "*.py")): f = os.path.basename(f) f = os.path.splitext(f)[0] if f != "__init__": hiddenimports.append(f)
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA hiddenimports = [ "dns.rdtypes.*", "dns.rdtypes.ANY.*" ]
Python
from hooks.hookutils import mpl_data_dir dir = mpl_data_dir() datas = [ (dir, ""), ]
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA import string attrs = [('Node', 0), ('INDEX_SIZE_ERR', 1), ('DOMSTRING_SIZE_ERR', 2), ('HIERARCHY_REQUEST_ERR', 3), ('WRONG_DOCUMENT_ERR', 4), ('INVALID_CHARACTER_ERR ', 5), ('NO_DATA_ALLOWED_ERR', 6), ('NO_MODIFICATION_ALLOWED_ERR', 7), ('NOT_FOUND_ERR', 8), ('NOT_SUPPORTED_ERR', 9), ('INUSE_ATTRIBUTE_ERR', 10), ('INVALID_STATE_ERR', 11), ('SYNTAX_ERR', 12), ('INVALID_MODIFICATION_ERR', 13), ('NAMESPACE_ERR', 14), ('INVALID_ACCESS_ERR', 15), ('DOMException', 0), ('IndexSizeErr', 0), ('DomstringSizeErr', 0), ('HierarchyRequestErr', 0), ('WrongDocumentErr', 0), ('InvalidCharacterErr', 0), ('NoDataAllowedErr', 0), ('NoModificationAllowedErr', 0), ('NotFoundErr', 0), ('NotSupportedErr', 0), ('InuseAttributeErr', 0), ('InvalidStateErr', 0), ('SyntaxErr', 0), ('InvalidModificationErr', 0), ('NamespaceErr', 0), ('InvalidAccessErr', 0), ('getDOMImplementation', 0), ('registerDOMImplementation', 0), ] def hook(mod): if string.find(mod.__file__, '_xmlplus') > -1: mod.UNSPECIFIED_EVENT_TYPE_ERR = 0 mod.FT_EXCEPTION_BASE = 1000 mod.XML_PARSE_ERR = 1001 mod.BAD_BOUNDARYPOINTS_ERR = 1 mod.INVALID_NODE_TYPE_ERR = 2 mod.EventException = None mod.RangeException = None mod.FtException = None if hasattr(mod, 'DomstringSizeErr'): del mod.DomstringSizeErr mod.DOMStringSizeErr = None mod.UnspecifiedEventTypeErr = None mod.XmlParseErr = None mod.BadBoundaryPointsErr = None mod.InvalidNodeTypeErr = None mod.DOMImplementation = None mod.implementation = None mod.XML_NAMESPACE = None mod.XMLNS_NAMESPACE = None mod.XHTML_NAMESPACE = None mod.DOMExceptionStrings = None mod.EventExceptionStrings = None mod.FtExceptionStrings = None mod.RangeExceptionStrings = None return mod
Python
# empty (just to need Python import machinery happy)
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #xml.sax.saxexts hiddenimports = ["xml.sax.drivers2.drv_pyexpat", "xml.sax.drivers.drv_xmltok", 'xml.sax.drivers2.drv_xmlproc', "xml.sax.drivers.drv_xmltoolkit", "xml.sax.drivers.drv_xmllib", "xml.sax.drivers.drv_xmldc", 'xml.sax.drivers.drv_pyexpat', 'xml.sax.drivers.drv_xmlproc_val', 'xml.sax.drivers.drv_htmllib', 'xml.sax.drivers.drv_sgmlop', "xml.sax.drivers.drv_sgmllib", ]
Python
# Copyright (C) 2009, Lorenzo Berni # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA import os import glob def hook(mod): global hiddenimports modpath = mod.__path__[0] hiddenimports = [] for fn in glob.glob('%s/backends/*.py' % modpath): fn = os.path.basename(fn) fn = os.path.splitext(fn)[0] hiddenimports.append('django.contrib.sessions.backends.' + fn) return mod
Python
hiddenimports = ['sip', "PyQt4._qt"] from hooks.hookutils import qt4_plugins_dir pdir = qt4_plugins_dir() datas = [ (pdir + "/codecs/*.so", "qt4_plugins/codecs"), (pdir + "/codecs/*.dll", "qt4_plugins/codecs"), (pdir + "/codecs/*.dylib", "qt4_plugins/codecs"), ]
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA # Contributed by Don Dwiggins hiddenimports = ['datetime', 'decimal', 'locale'] try: import hashlib hiddenimports.append('hashlib') del hashlib except ImportError: hiddenimports.append('sha')
Python
# Copyright (C) 2010, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA hiddenimports = ['decimal']
Python
# Copyright (C) 2009, Lorenzo Berni # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA from hookutils import django_dottedstring_imports, find_django_root import glob import sys import os python_path = os.environ.get("PYTHONPATH") if python_path: python_path = os.pathsep.join([python_path] + sys.pathex) else: python_path = os.pathsep.join(sys.pathex) django_root_dirs = [] for path in python_path.split(os.pathsep): django_root_dirs += find_django_root(path) if not django_root_dirs: raise RuntimeError("No django root directory found. Please check your pathex definition in the project spec file.") if django_root_dirs[0] in sys.pathex: raise RuntimeError("The django root directory is defined in the pathex. You have to define the parent directory instead of the django root directory.") os.environ["PYTHONPATH"] = python_path hiddenimports = [] for django_root_dir in django_root_dirs: hiddenimports += django_dottedstring_imports(django_root_dir)
Python
# In the new consolidated mode any PyQt depends on _qt hiddenimports = ['sip', 'PyQt4._qt']
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA hiddenimports = [] def install_Image(lis): import Image # PIL uses lazy initialization. # you candecide if you want only the # default stuff: Image.preinit() # or just everything: Image.init() import sys for name in sys.modules: if name[-11:] == "ImagePlugin": lis.append(name) install_Image(hiddenimports)
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA hiddenimports = ['copy_reg']
Python
hiddenimports = [ "backend_agg", "backend_cairo", "backend_cocaagg", "backend_emf", "backend_fltkagg", "backend_gdk", "backend_gtkagg", "backend_gtkcairo", "backend_macosx", "backend_mixed", "backend_pdf", "backend_ps", "backend_qt4agg", "backend_qt4", "backend_qtagg", "backend_qt", "backend_svg", "backend_template", "backend_tkagg", "backend_wxagg", "backend_wx", ]
Python
# Copyright (C) 2007, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA # cElementTree has a hidden import hiddenimports = ['elementtree.ElementTree']
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA import os def hook(mod): pth = str(mod.__path__[0]) if os.path.isdir(pth): mod.__path__.append( os.path.normpath(os.path.join(pth, '../win32comext'))) return mod
Python
# Copyright (C) 2007, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA # Contributed by Greg Copeland from hookutils import exec_statement databases = exec_statement("import sqlalchemy.databases;print sqlalchemy.databases.__all__") databases = eval(databases) hiddenimports = [] for n in databases: hiddenimports.append("sqlalchemy.databases." + n)
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA # Forward to shared code for PIL. PIL can be imported either as a top-level package # (from PIL import Image), or not (import Image), because it installs a # PIL.pth. from hooks.shared_PIL_SpiderImagePlugin import *
Python
hiddenimports = ['sip', 'PyQt4.QtCore', 'PyQt4._qt'] from hooks.hookutils import qt4_plugins_dir pdir = qt4_plugins_dir() datas = [ (pdir + "/imageformats/*.so", "qt4_plugins/imageformats"), (pdir + "/imageformats/*.dll", "qt4_plugins/imageformats"), (pdir + "/imageformats/*.dylib", "qt4_plugins/imageformats"), (pdir + "/iconengines/*.so", "qt4_plugins/iconengines"), (pdir + "/iconengines/*.dll", "qt4_plugins/iconengines"), (pdir + "/iconengines/*.dylib", "qt4_plugins/iconengines"), (pdir + "/accessible/*.so", "qt4_plugins/accessible"), (pdir + "/accessible/*.dll", "qt4_plugins/accessible"), (pdir + "/accessible/*.dylib", "qt4_plugins/accessible"), ]
Python
# codegen generates Python code that is then executed through exec(). # This Python code imports the following modules. hiddenimports = ['mako.cache', 'make.runtime', 'mako.filters']
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA hiddenimports = ['pyexpat', 'xml.etree.ElementTree', 'copy']
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA hiddenimports = ['copy_reg']
Python
hiddenimports = ['lxml.etree']
Python
hiddenimports = ["django.db.backends.oracle.compiler"]
Python
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #anydbm hiddenimports = ['dbhash', 'gdbm', 'dbm', 'dumbdbm']
Python
# Copyright (C) 2009, Lorenzo Berni # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA import os if not os.environ.get("DJANGO_SETTINGS_MODULE"): os.environ["DJANGO_SETTINGS_MODULE"] = "settings" from django.conf import settings hiddenimports = list(settings.AUTHENTICATION_BACKENDS) + \ [settings.DEFAULT_FILE_STORAGE] + \ list(settings.FILE_UPLOAD_HANDLERS) + \ list(settings.INSTALLED_APPS) + \ list(settings.MIDDLEWARE_CLASSES) + \ list(settings.TEMPLATE_CONTEXT_PROCESSORS) + \ list(settings.TEMPLATE_LOADERS) + \ [settings.ROOT_URLCONF] def find_url_callbacks(urls_module): urlpatterns = urls_module.urlpatterns hid_list = [urls_module.__name__] for pattern in urlpatterns: if isinstance(pattern, RegexURLPattern): hid_list.append(pattern.callback.__module__) elif isinstance(pattern, RegexURLResolver): hid_list += find_url_callbacks(pattern.urlconf_module) return hid_list from django.core.urlresolvers import RegexURLPattern, RegexURLResolver base_module_name = ".".join(os.environ.get("DJANGO_SETTINGS_MODULE", "settings").split(".")[:-1]) if base_module_name: base_module = __import__(base_module_name, {}, {}, ["urls"]) urls = base_module.urls else: import urls hiddenimports += find_url_callbacks(urls) print repr(sorted(set(hiddenimports)))
Python
hiddenimports = ['sip', 'PyQt4.QtCore', 'PyQt4.QtGui', 'PyQt4._qt']
Python