code stringlengths 1 1.72M | language stringclasses 1 value |
|---|---|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import httplib
import gzip
def main():
print "Hello World!"
if __name__ == "__main__":
main()
| Python |
# -*- mode: python -*-
'''
TESTING MULTIPROCESS FEATURE: file A (onedir pack) depends on file B (onefile pack).
'''
__testname__ = 'test_multipackage3'
__testdep__ = 'multipackage3_B'
a = Analysis([__testname__ + '.py'],
pathex=['.'])
b = Analysis([__testdep__ + '.py'],
pathex=['.'])
MERGE((b, __testdep__, os.path.join(__testdep__ + '.exe')),
(a, __testname__, os.path.join(__testname__, __testname__ + '.exe')))
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
a.dependencies,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.platform, __testname__,
__testname__ + '.exe'),
debug=False,
strip=False,
upx=True,
console=1 )
coll = COLLECT( exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name=os.path.join('dist', __testname__ ))
pyzB = PYZ(b.pure)
exeB = EXE(pyzB,
b.scripts,
b.binaries,
b.zipfiles,
b.datas,
b.dependencies,
name=os.path.join('dist', __testdep__ + '.exe'),
debug=False,
strip=False,
upx=True,
console=1 )
| Python |
# -*- mode: python -*-
'''
MULTIPROCESS FEATURE: file A (onefile pack) depends on file B (onedir pack)
'''
__testname__ = 'test_multipackage2'
__testdep__ = 'multipackage2_B'
a = Analysis([__testname__ + '.py'],
pathex=['.'])
b = Analysis([__testdep__ + '.py'],
pathex=['.'])
MERGE((b, __testdep__, os.path.join(__testdep__, __testdep__ + '.exe')),
(a, __testname__, __testname__ + '.exe'))
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
a.dependencies,
name=os.path.join('dist', __testname__ + '.exe'),
debug=False,
strip=False,
upx=True,
console=1 )
pyzB = PYZ(b.pure)
exeB = EXE(pyzB,
b.scripts,
b.dependencies,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.platform, __testdep__,
__testdep__ + '.exe'),
debug=False,
strip=False,
upx=True,
console=1 )
coll = COLLECT( exeB,
b.binaries,
b.zipfiles,
b.datas,
strip=False,
upx=True,
name=os.path.join('dist', __testdep__))
| Python |
# -*- mode: python -*-
__testname__ = 'test_Image'
a = Analysis([__testname__ + '.py'],
pathex=[])
pyz = PYZ(a.pure)
TOC_custom = [('tinysample.tiff','tinysample.tiff','DATA')]
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.platform, __testname__ + '.exe'),
debug=True,
strip=False,
upx=True,
console=True )
coll = COLLECT( exe,
a.binaries,
a.zipfiles,
a.datas,
TOC_custom,
strip=False,
upx=True,
name=os.path.join('dist', __testname__),)
| Python |
# -*- mode: python -*-
__testname__ = 'test_numpy'
a = Analysis([__testname__ + '.py'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.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 -*-
__testname__ = 'test_pycrypto'
a = Analysis([__testname__ + '.py'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.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 -*-
__testname__ = 'test_wx'
a = Analysis([__testname__ + '.py'],
pathex=[])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.platform, __testname__ + '.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', __testname__),)
| Python |
# -*- mode: python -*-
__testname__ = 'test_Image2'
a = Analysis([__testname__ + '.py'],
pathex=['.'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.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_PIL'
a = Analysis([__testname__ + '.py'],
pathex=[])
pyz = PYZ(a.pure)
TOC_custom = [('tinysample.tiff','tinysample.tiff','DATA')]
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.platform, __testname__ + '.exe'),
debug=True,
strip=False,
upx=True,
console=True )
coll = COLLECT( exe,
a.binaries,
a.zipfiles,
a.datas,
TOC_custom,
strip=False,
upx=True,
name=os.path.join('dist', __testname__),)
| Python |
# -*- mode: python -*-
__testname__ = 'test_PIL2'
a = Analysis([__testname__ + '.py'],
pathex=['.'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.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_pygame'
a = Analysis([__testname__ + '.py'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.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__))
import sys
if sys.platform.startswith("darwin"):
app = BUNDLE(coll,
name=os.path.join('dist', __testname__ + '.app'),
version='0.0.1')
| Python |
# -*- mode: python -*-
__testname__ = 'test_matplotlib'
if sys.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([__testname__ + '.py'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.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__ = 'test_tix'
a = Analysis([__testname__ + '.py'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.platform, __testname__,
__testname__ + '.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', __testname__))
| Python |
# -*- mode: python -*-
__testname__ = 'test_pyqt4'
a = Analysis([__testname__ + '.py'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.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__))
import sys
if sys.platform.startswith("darwin"):
app = BUNDLE(coll,
name=os.path.join('dist', __testname__ + '.app'),
version='0.0.1')
| Python |
# -*- mode: python -*-
__testname__ = 'test_wx'
a = Analysis([__testname__ + '.py'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.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 -*-
__testname__ = 'test_tkinter'
a = Analysis([__testname__ + '.py'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.platform, __testname__,
__testname__ + '.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', __testname__))
| Python |
# -*- mode: python -*-
__testname__ = 'test_buffering'
a = Analysis([__testname__ + '.py'],
pathex=[])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
[('u', '', 'OPTION')],
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.platform, __testname__ + '.exe'),
debug=0,
console=1)
coll = COLLECT( exe,
a.binaries,
name=os.path.join('dist', __testname__),)
| Python |
#! /usr/bin/env python
#
# Wrapper around Configure.py / Makespec.py / Build.py
#
# Copyright (C) 2010, Martin Zibricky
# Copyright (C) 2011, Hartmut Goebel
#
# 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 optparse
import PyInstaller.makespec
import PyInstaller.build
import PyInstaller.compat
import PyInstaller.log
# Warn when old command line option is used
from PyInstaller import get_version
from PyInstaller.log import logger
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 = PyInstaller.makespec.main(args, **opts.__dict__)
logger.info('wrote %s' % spec_file)
return spec_file
def run_build(opts, spec_file):
PyInstaller.build.main(spec_file, **opts.__dict__)
def __add_options(parser):
parser.add_option('-v', '--version', default=False, action='store_true',
help='show program version')
def main():
parser = optparse.OptionParser(
usage='python %prog [opts] <scriptname> [ <scriptname> ...] | <specfile>'
)
__add_options(parser)
PyInstaller.makespec.__add_options(parser)
PyInstaller.build.__add_options(parser)
PyInstaller.log.__add_options(parser)
PyInstaller.compat.__add_obsolete_options(parser)
opts, args = parser.parse_args()
PyInstaller.log.__process_options(parser, opts)
# Print program version and exit
if opts.version:
print get_version()
raise SystemExit(0)
if not args:
parser.error('Requires at least one scriptname file '
'or exactly one .spec-file')
# 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, spec_file)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
raise SystemExit("Aborted by user request.")
| Python |
#! /usr/bin/env python
# Viewer for archives packaged by archive.py
# Copyright (C) 2005-2011, 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.
#
# 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
try:
import PyInstaller
except ImportError:
# if importing PyInstaller fails, try to load from parent
# directory to support running without installation
import imp, os
if not hasattr(os, "getuid") or os.getuid() != 0:
imp.load_module('PyInstaller', *imp.find_module('PyInstaller',
[os.path.dirname(os.path.dirname(__file__))]))
from PyInstaller.loader import archive, carchive
import PyInstaller.log
import tempfile, os
try:
import zlib
except ImportError:
zlib = archive.DummyZlib()
import pprint
import optparse
stack = []
cleanup = []
name = None
debug = False
rec_debug = False
brief = False
def main(opts, args):
global stack
global debug
global rec_debug
global name
global brief
name = args[0]
debug = opts.log
rec_debug = opts.rec
brief = opts.brief
if not os.path.isfile(name):
print "%s is an invalid file name!" % name
return 1
arch = getArchive(name)
stack.append((name, arch))
if debug or brief:
show_log(name, arch)
raise SystemExit(0)
else:
show(name, arch)
while 1:
try:
toks = raw_input('? ').split(None, 1)
except EOFError:
# Ctrl-D
print # clear line
break
if not toks:
usage()
continue
if len(toks) == 1:
cmd = toks[0]
arg = ''
else:
cmd, arg = toks
cmd = cmd.upper()
if cmd == 'U':
if len(stack) > 1:
arch = stack[-1][1]
arch.lib.close()
del stack[-1]
nm, arch = stack[-1]
show(nm, arch)
elif cmd == 'O':
if not arg:
arg = raw_input('open name? ')
arg = arg.strip()
arch = getArchive(arg)
if arch is None:
print arg, "not found"
continue
stack.append((arg, arch))
show(arg, arch)
elif cmd == 'X':
if not arg:
arg = raw_input('extract name? ')
arg = arg.strip()
data = getData(arg, arch)
if data is None:
print "Not found"
continue
fnm = raw_input('to filename? ')
if not fnm:
print `data`
else:
open(fnm, 'wb').write(data)
elif cmd == 'Q':
break
else:
usage()
for (nm, arch) in stack:
arch.lib.close()
stack = []
for fnm in cleanup:
try:
os.remove(fnm)
except Exception, e:
print "couldn't delete", fnm, e.args
def usage():
print "U: go Up one level"
print "O <nm>: open embedded archive nm"
print "X <nm>: extract nm"
print "Q: quit"
def getArchive(nm):
if not stack:
if nm[-4:].lower() == '.pyz':
return ZlibArchive(nm)
return carchive.CArchive(nm)
parent = stack[-1][1]
try:
return parent.openEmbedded(nm)
except KeyError, e:
return None
except (ValueError, RuntimeError):
ndx = parent.toc.find(nm)
dpos, dlen, ulen, flag, typcd, nm = parent.toc[ndx]
x, data = parent.extract(ndx)
tfnm = tempfile.mktemp()
cleanup.append(tfnm)
open(tfnm, 'wb').write(data)
if typcd == 'z':
return ZlibArchive(tfnm)
else:
return carchive.CArchive(tfnm)
def getData(nm, arch):
if type(arch.toc) is type({}):
(ispkg, pos, lngth) = arch.toc.get(nm, (0, None, 0))
if pos is None:
return None
arch.lib.seek(arch.start + pos)
return zlib.decompress(arch.lib.read(lngth))
ndx = arch.toc.find(nm)
dpos, dlen, ulen, flag, typcd, nm = arch.toc[ndx]
x, data = arch.extract(ndx)
return data
def show(nm, arch):
if type(arch.toc) == type({}):
print " Name: (ispkg, pos, len)"
toc = arch.toc
else:
print " pos, length, uncompressed, iscompressed, type, name"
toc = arch.toc.data
pprint.pprint(toc)
def show_log(nm, arch, output=[]):
if type(arch.toc) == type({}):
toc = arch.toc
if brief:
for name,_ in toc.items():
output.append(name)
else:
pprint.pprint(toc)
else:
toc = arch.toc.data
for el in toc:
if brief:
output.append(el[5])
else:
output.append(el)
if rec_debug:
if el[4] in ('z', 'a'):
show_log(el[5], getArchive(el[5]), output)
stack.pop()
pprint.pprint(output)
class ZlibArchive(archive.ZlibArchive):
def checkmagic(self):
""" Overridable.
Check to see if the file object self.lib actually has a file
we understand.
"""
self.lib.seek(self.start) #default - magic is at start of file
if self.lib.read(len(self.MAGIC)) != self.MAGIC:
raise RuntimeError("%s is not a valid %s archive file"
% (self.path, self.__class__.__name__))
if self.lib.read(len(self.pymagic)) != self.pymagic:
print "Warning: pyz is from a different Python version"
self.lib.read(4)
parser = optparse.OptionParser('%prog [options] pyi_archive')
parser.add_option('-l', '--log',
default=False,
action='store_true',
dest='log',
help='Print an archive log (default: %default)')
parser.add_option('-r', '--recursive',
default=False,
action='store_true',
dest='rec',
help='Recusively print an archive log (default: %default). Can be combined with -r')
parser.add_option('-b', '--brief',
default=False,
action='store_true',
dest='brief',
help='Print only file name. (default: %default). Can be combined with -r')
PyInstaller.log.__add_options(parser)
opts, args = parser.parse_args()
PyInstaller.log.__process_options(parser, opts)
if len(args) != 1:
parser.error('Requires exactly one pyinstaller archive')
try:
raise SystemExit(main(opts, args))
except KeyboardInterrupt:
raise SystemExit("Aborted by user request.")
| Python |
#! /usr/bin/env python
#
# Build packages using spec files
#
# Copyright (C) 2005-2011, Giovanni Bajo
#
# 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
try:
import PyInstaller
except ImportError:
# if importing PyInstaller fails, try to load from parent
# directory to support running without installation
import imp, os
if not hasattr(os, "getuid") or os.getuid() != 0:
imp.load_module('PyInstaller', *imp.find_module('PyInstaller',
[os.path.dirname(os.path.dirname(__file__))]))
import PyInstaller.bindepend
from PyInstaller import is_win
import PyInstaller.log
import optparse
import glob, sys
parser = optparse.OptionParser(usage="python %prog <executable_or_dynamic_library> [ <executable_or_dynamic_library> ... ]")
PyInstaller.log.__add_options(parser)
opts, args = parser.parse_args()
PyInstaller.log.__process_options(parser, opts)
if len(args) == 0:
parser.error('Requires one or more executables or dynamic libraries')
# Suppress all informative messages from the dependency code
PyInstaller.log.getLogger('PyInstaller.build.bindepend').setLevel(PyInstaller.log.WARN)
try:
for a in args:
for fn in glob.glob(a):
imports = PyInstaller.bindepend.getImports(fn)
if is_win:
imports.update([a.getid() for a in PyInstaller.bindepend.getAssemblies(fn)])
print fn, imports
except KeyboardInterrupt:
raise SystemExit("Aborted by user request.")
| 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.
#
# 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
try:
import PyInstaller
except ImportError:
# if importing PyInstaller fails, try to load from parent
# directory to support running without installation
import imp, os
if not hasattr(os, 'getuid') or os.getuid() != 0:
imp.load_module('PyInstaller', *imp.find_module('PyInstaller',
[os.path.dirname(os.path.dirname(__file__))]))
import PyInstaller.makespec as makespec
import os, sys, win32api
import optparse
tmplt = '''\
import sys
import os
import pythoncom
pythoncom.frozen = 1
inprocess = getattr(sys, "frozen", None)
%(modules)s
klasses = (%(klasses)s,)
def DllRegisterServer():
import win32com.server.register
win32com.server.register.RegisterClasses(*klasses)
return 0
def DllUnregisterServer():
import win32com.server.register
win32com.server.register.UnregisterClasses(*klasses)
return 0
if sys.frozen != "dll":
import win32com.server.localserver
for i in range(1, len(sys.argv)):
arg = sys.argv[i].lower()
if arg.find("/reg") > -1 or arg.find("--reg") > -1:
DllRegisterServer()
break
if arg.find("/unreg") > -1 or arg.find("--unreg") > -1:
DllUnregisterServer()
break
# MS seems to like /automate to run the class factories.
if arg.find("/automate") > -1:
clsids = []
for k in klasses:
clsids.append(k._reg_clsid_)
win32com.server.localserver.serve(clsids)
break
else:
# You could do something else useful here.
import win32api
win32api.MessageBox(0,
"This program hosts a COM Object and\\r\\n"
"is started automatically",
"COM Object")
'''
def create(scripts, debug, verbose, workdir, ascii=0):
infos = [] # (path, module, klasses)
for script in scripts:
infos.append(analscriptname(script))
if not os.path.exists(workdir):
os.makedirs(workdir)
outfnm = 'drive%s.py' % infos[0][1]
outfnm = os.path.join(workdir, outfnm)
outf = open(outfnm, 'w')
klassspecs = []
modimports = []
flags = 'debug=%s, quiet=%s' % (debug, not verbose)
paths = []
for path, module, klasses in infos:
if path:
paths.append(win32api.GetShortPathName(os.path.normpath(path)))
modimports.append("import %s" % (module,))
for klass in klasses:
klassspecs.append("%s.%s" % (module, klass))
modimports = '\n'.join(modimports)
klassspecs = ', '.join(klassspecs)
d = { 'modules':modimports,
'klasses':klassspecs,
}
outf.write( tmplt % d )
outf.close()
print "**********************************"
print "Driver script %s created" % outfnm
specfnm = makespec.main([outfnm], console=debug, debug=debug,
workdir=workdir, pathex=paths, comserver=1, ascii=ascii)
print "Spec file %s created" % specfnm
def analscriptname(script):
# return (path, module, klasses)
path, basename = os.path.split(script)
module = os.path.splitext(basename)[0]
while ispkgdir(path):
path, basename = os.path.split(path)
module = '%s.%s' % (basename, module)
try:
__import__(module)
except ImportError:
oldpath = sys.path[:]
sys.path.insert(0, path)
try:
__import__(module)
finally:
sys.path = oldpath
else:
path = None
m = sys.modules[module]
klasses = []
for nm, thing in m.__dict__.items():
if hasattr(thing, '_reg_clsid_'):
klasses.append(nm)
return (path, module, klasses)
def ispkgdir(path):
try:
open(os.path.join(path, '__init__.py'), 'rU')
except IOError:
try:
open(os.path.join(path, '__init__.pyc'), 'rb')
except IOError:
return 0
return 1
epilog = ("The next step is to run Build.py against the generated "
"spec file. See doc/Tutorial.html for details.")
if __name__ == '__main__':
parser = optparse.OptionParser(
usage='python %s [options] <scriptname>.py [<scriptname>.py ...]',
epilog="The next step is to run Build.py against the generated"
"spec file. See doc/Tutorial.html for details."
)
parser.add_option('--debug', default=False, action='store_true',
help='use debug console build and register COM servers with debug')
parser.add_option('--verbose', default=False, action='store_true',
help='use verbose flag in COM server registration')
parser.add_option('--out', default='.',
metavar='DIR',
dest='workdir',
help='generate script and spec file in dir')
parser.add_option('--ascii', default=False, action='store_true')
opts, args = parser.parse_args()
if not args:
parser.error('Requires at least one script filename')
try:
print
print epilog
except KeyboardInterrupt:
raise SystemExit("Aborted by user request.")
| Python |
#!/usr/bin/env python
# Crypt support routines
# Copyright (C) 2005, Giovanni Bajo
try:
import PyInstaller
except ImportError:
# if importing PyInstaller fails, try to load from parent
# directory to support running without installation
import imp, os
if not hasattr(os, "getuid") or os.getuid() != 0:
imp.load_module('PyInstaller', *imp.find_module('PyInstaller',
[os.path.dirname(os.path.dirname(__file__))]))
import sys
class ArgsError(Exception):
pass
def gen_random_key(size=32):
"""
Generate a cryptographically-secure random key. This is done by using
Python 2.4's os.urandom, or PyCrypto.
"""
import os
if hasattr(os, "urandom"): # Python 2.4+
return os.urandom(size)
# Try using PyCrypto if available
try:
from Crypto.Util.randpool import RandomPool
from Crypto.Hash import SHA256
return RandomPool(hash=SHA256).get_bytes(size)
except ImportError:
print >>sys.stderr, "WARNING: The generated key will not be cryptographically-secure key. Consider using Python 2.4+ to generate the key, or install PyCrypto."
# Stupid random generation
import random
L = []
for i in range(size):
L.append(chr(random.randint(0, 255)))
return "".join(L)
def cmd_genkey(args):
import pprint
if len(args) != 1:
raise ArgsError, "invalid number of arguments"
key_file = args[0]
key = gen_random_key()
f = open(key_file, "w")
print >>f, "key = %s" % repr(key)
return 0
def main():
global global_opts
global opts
import optparse
cmds = {}
p = optparse.OptionParser(
usage="%prog [opts] file",
description="Generate a plaintext keyfile containing a "
"random-generated encryption key. ")
cmds["genkey"] = p
for c,p in cmds.items():
p.prog = p.get_prog_name() + " " + c
cmdnames = cmds.keys()
cmdnames.sort()
p = optparse.OptionParser(
usage="%prog cmd [opts]\n\n" +
"Available Commands:\n " +
"\n ".join(cmdnames),
description="This tool is a helper of crypt-related tasks with PyInstaller."
)
p.disable_interspersed_args()
global_opts,args = p.parse_args()
if not args:
p.print_usage()
return -1
c = args.pop(0)
if c not in cmds.keys():
print "invalid command: %s" % c
return -1
p = cmds[c]
opts, args = p.parse_args(args)
try:
return globals()["cmd_" + c](args)
except ArgsError, e:
p.error(e)
try:
raise SystemExit(main())
except KeyboardInterrupt:
raise SystemExit("Aborted by user request.")
| Python |
#! /usr/bin/env 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.
#
# 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
try:
import PyInstaller
except ImportError:
# if importing PyInstaller fails, try to load from parent
# directory to support running without installation
import imp, os
if not hasattr(os, 'getuid') or os.getuid() != 0:
imp.load_module('PyInstaller', *imp.find_module('PyInstaller',
[os.path.dirname(os.path.dirname(__file__))]))
from PyInstaller.utils import versioninfo
if len(sys.argv) < 2:
print 'Usage: >python GrabVersion.py <exe>'
print ' where: <exe> is the fullpathname of a Windows executable.'
print ' The printed output may be saved to a file, editted and '
print ' used as the input for a verion resource on any of the '
print ' executable targets in an Installer config file.'
print ' Note that only NT / Win2K can set version resources.'
else:
try:
vs = versioninfo.decode(sys.argv[1])
print vs
except KeyboardInterrupt:
raise SystemExit("Aborted by user request.")
| Python |
#! /usr/bin/env python
#
# Automatically build spec files containing a description of the project
#
# Copyright (C) 2005-2011, Giovanni Bajo
#
# 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
try:
import PyInstaller
except ImportError:
# if importing PyInstaller fails, try to load from parent
# directory to support running without installation
import imp, os
if not hasattr(os, 'getuid') or os.getuid() != 0:
imp.load_module('PyInstaller', *imp.find_module('PyInstaller',
[os.path.dirname(os.path.dirname(__file__))]))
import PyInstaller.makespec
import PyInstaller.compat
import PyInstaller.log
import optparse
import os
p = optparse.OptionParser(
usage='python %prog [opts] <scriptname> [<scriptname> ...]'
)
PyInstaller.makespec.__add_options(p)
PyInstaller.log.__add_options(p)
PyInstaller.compat.__add_obsolete_options(p)
opts, args = p.parse_args()
PyInstaller.log.__process_options(p, opts)
# Split pathex by using the path separator
temppaths = opts.pathex[:]
opts.pathex = []
for p in temppaths:
opts.pathex.extend(p.split(os.pathsep))
if not args:
p.error('Requires at least one scriptname file')
try:
name = PyInstaller.makespec.main(args, **opts.__dict__)
print 'wrote %s' % name
print 'now run Build.py to build the executable'
except KeyboardInterrupt:
raise SystemExit("Aborted by user request.")
| Python |
#! /usr/bin/env python
#
# Build packages using spec files
#
# Copyright (C) 2005-2011, Giovanni Bajo
#
# 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
try:
import PyInstaller
except ImportError:
# if importing PyInstaller fails, try to load from parent
# directory to support running without installation
import imp, os
if not hasattr(os, 'getuid') or os.getuid() != 0:
imp.load_module('PyInstaller', *imp.find_module('PyInstaller',
[os.path.dirname(os.path.dirname(__file__))]))
import PyInstaller.build
import PyInstaller.compat
import PyInstaller.log
import optparse
parser = optparse.OptionParser(usage='%prog [options] specfile')
PyInstaller.build.__add_options(parser)
PyInstaller.log.__add_options(parser)
PyInstaller.compat.__add_obsolete_options(parser)
opts, args = parser.parse_args()
PyInstaller.log.__process_options(parser, opts)
if len(args) != 1:
parser.error('Requires exactly one .spec-file')
try:
PyInstaller.build.main(args[0], **opts.__dict__)
except KeyboardInterrupt:
raise SystemExit("Aborted by user request.")
| Python |
#!/usr/bin/env python
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 3260 $
# Date: $Date: 2005-04-27 01:03:00 +0200 (Wed, 27 Apr 2005) $
# Copyright: This module has been placed in the public domain.
"""
A minimal front end to the Docutils Publisher, producing LaTeX using
the new LaTeX writer.
"""
try:
import locale
locale.setlocale(locale.LC_ALL, '')
except:
pass
from docutils.core import publish_cmdline, default_description
description = ('Generates LaTeX documents from standalone reStructuredText '
'sources. This writer is EXPERIMENTAL and should not be used '
'in a production environment. ' + default_description)
publish_cmdline(writer_name='newlatex2e', description=description)
| Python |
#!/usr/bin/env python
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 2468 $
# Date: $Date: 2004-07-27 18:25:22 +0200 (Tue, 27 Jul 2004) $
# Copyright: This module has been placed in the public domain.
"""
A minimal front end to the Docutils Publisher, producing Docutils XML.
"""
try:
import locale
locale.setlocale(locale.LC_ALL, '')
except:
pass
from docutils.core import publish_cmdline, default_description
description = ('Generates Docutils-native XML from standalone '
'reStructuredText sources. ' + default_description)
publish_cmdline(writer_name='xml', description=description)
| Python |
#!/usr/bin/python
# Tkinter interface to the McMillan installer / PyInstaller
# (c) 2003 Alan James Salmoni - yes, all this bad code is all mine!!!
# (c) 2011 Hartmut Goebel: adopted to PyInstaller 1.6, use subprocess
# released under the MIT license
import os
import sys
import subprocess
from Tkinter import *
import tkFileDialog
import FileDialog
class PyInstallerGUI:
def make_checkbutton(self, frame, text):
var = IntVar()
widget = Checkbutton(frame, text=text, variable=var)
widget.grid(sticky="NW")
return var
def __init__(self):
root = Tk()
root.title("PyInstaller GUI")
fr1 = Frame(root, width=300, height=100)
fr1.pack(side="top")
fr2 = Frame(root, width=300, height=300,
borderwidth=2, relief="ridge")
fr2.pack(ipadx=10, ipady=10)
fr4 = Frame(root, width=300, height=100)
fr4.pack(side="bottom", pady=10)
getFileButton = Button(fr1, text="Script to bundle ...")
getFileButton.bind("<Button>", self.GetFile)
getFileButton.pack(side="left")
self.filein = Entry(fr1)
self.filein.pack(side="right")
self.filetype = self.make_checkbutton(fr2, "One File Package")
self.ascii = self.make_checkbutton(fr2, "Do NOT include decodings")
self.debug = self.make_checkbutton(fr2, "Use debug versions")
if sys.platform.startswith('win'):
self.noconsole = self.make_checkbutton(fr2, "No console (Windows only)")
else:
self.noconsole = IntVar()
if not sys.platform.startswith('win'):
self.strip = self.make_checkbutton(fr2, "Strip the exe and shared libs")
else:
self.strip = IntVar()
okaybutton = Button(fr4, text="Okay ")
okaybutton.bind("<Button>", self.makePackage)
okaybutton.pack(side="left")
cancelbutton = Button(fr4, text="Cancel")
cancelbutton.bind("<Button>", self.killapp)
cancelbutton.pack(side="right")
self.fin = ''
self.fout = ''
ws = root.winfo_screenwidth()
hs = root.winfo_screenheight()
x = (ws/2) - (400/2)
y = (hs/2) - (250/2)
root.geometry('%dx%d+%d+%d' % (400, 250, x, y))
root.mainloop()
def killapp(self, event):
sys.exit(0)
def makePackage(self, event):
commands = ['python', 'pyinstaller.py']
if self.filetype.get():
commands.append('--onefile')
if self.ascii.get():
commands.append('--ascii')
if self.debug.get():
commands.append('--debug')
if self.noconsole.get():
commands.append('--noconsole')
if self.strip.get():
commands.append('--strip')
commands.append(self.fin)
retcode = subprocess.call(commands)
sys.exit(retcode)
def GetFile(self, event):
self.fin = tkFileDialog.askopenfilename()
self.filein.insert(0, self.fin)
if __name__ == "__main__":
raise SystemExit("Please use just 'pyinstaller.py'. Gui is not maintained.")
try:
app = PyInstallerGUI()
except KeyboardInterrupt:
raise SystemExit("Aborted by user request.")
| 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.
#
# 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 os
import glob
from PyInstaller import depend, hooks
from PyInstaller.compat import is_win, LogDict, set
import PyInstaller.log as logging
import PyInstaller.depend.owner
import PyInstaller.depend.impdirector
logger = logging.getLogger('PyInstaller.build.mf')
#=================Import Tracker============================#
# This one doesn't really import, just analyzes
# If it *were* importing, it would be the one-and-only ImportManager
# ie, the builtin import
UNTRIED = -1
imptyps = ['top-level', 'conditional', 'delayed', 'delayed, conditional']
class ImportTracker:
# really the equivalent of builtin import
def __init__(self, xpath=None, hookspath=None, excludes=None):
self.path = []
self.warnings = {}
if xpath:
self.path = xpath
self.path.extend(sys.path)
self.modules = LogDict()
# RegistryImportDirector is necessary only on Windows.
if is_win:
self.metapath = [
PyInstaller.depend.impdirector.BuiltinImportDirector(),
PyInstaller.depend.impdirector.RegistryImportDirector(),
PyInstaller.depend.impdirector.PathImportDirector(self.path)
]
else:
self.metapath = [
PyInstaller.depend.impdirector.BuiltinImportDirector(),
PyInstaller.depend.impdirector.PathImportDirector(self.path)
]
if hookspath:
hooks.__path__.extend(hookspath)
if excludes is None:
self.excludes = set()
else:
self.excludes = set(excludes)
def analyze_r(self, nm, importernm=None):
importer = importernm
if importer is None:
importer = '__main__'
seen = {}
nms = self.analyze_one(nm, importernm)
nms = map(None, nms, [importer] * len(nms))
i = 0
while i < len(nms):
nm, importer = nms[i]
if seen.get(nm, 0):
del nms[i]
mod = self.modules[nm]
if mod:
mod.xref(importer)
else:
i = i + 1
seen[nm] = 1
j = i
mod = self.modules[nm]
if mod:
mod.xref(importer)
for name, isdelayed, isconditional, level in mod.imports:
imptyp = isdelayed * 2 + isconditional
newnms = self.analyze_one(name, nm, imptyp, level)
newnms = map(None, newnms, [nm] * len(newnms))
nms[j:j] = newnms
j = j + len(newnms)
return map(lambda a: a[0], nms)
def analyze_one(self, nm, importernm=None, imptyp=0, level=-1):
"""
break the name being imported up so we get:
a.b.c -> [a, b, c] ; ..z -> ['', '', z]
"""
#print '## analyze_one', nm, importernm, imptyp, level
if not nm:
nm = importernm
importernm = None
level = 0
nmparts = nm.split('.')
if level < 0:
# behaviour up to Python 2.4 (and default in Python 2.5)
# first see if we could be importing a relative name
contexts = [None]
if importernm:
if self.ispackage(importernm):
contexts.insert(0, importernm)
else:
pkgnm = ".".join(importernm.split(".")[:-1])
if pkgnm:
contexts.insert(0, pkgnm)
elif level == 0:
# absolute import, do not try relative
importernm = None
contexts = [None]
elif level > 0:
# relative import, do not try absolute
if self.ispackage(importernm):
level -= 1
if level > 0:
importernm = ".".join(importernm.split('.')[:-level])
contexts = [importernm, None]
importernm = None
_all = None
assert contexts
# so contexts is [pkgnm, None] or just [None]
if nmparts[-1] == '*':
del nmparts[-1]
_all = []
nms = []
for context in contexts:
ctx = context
for i, nm in enumerate(nmparts):
if ctx:
fqname = ctx + '.' + nm
else:
fqname = nm
mod = self.modules.get(fqname, UNTRIED)
if mod is UNTRIED:
logger.debug('Analyzing %s', fqname)
mod = self.doimport(nm, ctx, fqname)
if mod:
nms.append(mod.__name__)
ctx = fqname
else:
break
else:
# no break, point i beyond end
i = i + 1
if i:
break
# now nms is the list of modules that went into sys.modules
# just as result of the structure of the name being imported
# however, each mod has been scanned and that list is in mod.imports
if i < len(nmparts):
if ctx:
if hasattr(self.modules[ctx], nmparts[i]):
return nms
if not self.ispackage(ctx):
return nms
self.warnings["W: no module named %s (%s import by %s)" % (fqname, imptyps[imptyp], importernm or "__main__")] = 1
if fqname in self.modules:
del self.modules[fqname]
return nms
if _all is None:
return nms
bottommod = self.modules[ctx]
if bottommod.ispackage():
for nm in bottommod._all:
if not hasattr(bottommod, nm):
mod = self.doimport(nm, ctx, ctx + '.' + nm)
if mod:
nms.append(mod.__name__)
else:
bottommod.warnings.append("W: name %s not found" % nm)
return nms
def analyze_script(self, fnm):
try:
stuff = open(fnm, 'rU').read() + '\n'
co = compile(stuff, fnm, 'exec')
except SyntaxError, e:
logger.exception(e)
raise SystemExit(10)
mod = depend.modules.PyScript(fnm, co)
self.modules['__main__'] = mod
return self.analyze_r('__main__')
def ispackage(self, nm):
return self.modules[nm].ispackage()
def doimport(self, nm, ctx, fqname):
"""
nm name
e.g.:
ctx context
e.g.:
fqname fully qualified name
e.g.:
Return dict containing collected information about module (
"""
#print "doimport", nm, ctx, fqname
# NOTE that nm is NEVER a dotted name at this point
assert ("." not in nm), nm
if fqname in self.excludes:
return None
if ctx:
parent = self.modules[ctx]
if parent.ispackage():
mod = parent.doimport(nm)
if mod:
# insert the new module in the parent package
# FIXME why?
setattr(parent, nm, mod)
else:
# if parent is not a package, there is nothing more to do
return None
else:
# now we're dealing with an absolute import
# try to import nm using available directors
for director in self.metapath:
mod = director.getmod(nm)
if mod:
break
# here we have `mod` from:
# mod = parent.doimport(nm)
# or
# mod = director.getmod(nm)
if mod:
mod.__name__ = fqname
# now look for hooks
# this (and scan_code) are instead of doing "exec co in mod.__dict__"
try:
hookmodnm = 'hook-' + fqname
hooks = __import__('PyInstaller.hooks', globals(), locals(), [hookmodnm])
hook = getattr(hooks, hookmodnm)
except AttributeError:
pass
else:
mod = self._handle_hook(mod, hook)
if fqname != mod.__name__:
logger.warn("%s is changing its name to %s",
fqname, mod.__name__)
self.modules[mod.__name__] = mod
# The following line has to be at the end of if statement because
# 'mod' might be replaced by a new object within a hook.
self.modules[fqname] = mod
else:
assert (mod == None), mod
self.modules[fqname] = None
# should be equivalent using only one
# self.modules[fqname] = mod
# here
return mod
def _handle_hook(self, mod, hook):
if hasattr(hook, 'hook'):
mod = hook.hook(mod)
if hasattr(hook, 'hiddenimports'):
for impnm in hook.hiddenimports:
mod.imports.append((impnm, 0, 0, -1))
if hasattr(hook, 'attrs'):
for attr, val in hook.attrs:
setattr(mod, attr, val)
if hasattr(hook, 'datas'):
# hook.datas is a list of globs of files or
# directories to bundle as datafiles. For each
# glob, a destination directory is specified.
def _visit((base, dest_dir, datas), dirname, names):
for fn in names:
fn = os.path.join(dirname, fn)
if os.path.isfile(fn):
datas.append((dest_dir + fn[len(base) + 1:], fn, 'DATA'))
datas = mod.datas # shortcut
for g, dest_dir in hook.datas:
if dest_dir:
dest_dir += os.sep
for fn in glob.glob(g):
if os.path.isfile(fn):
datas.append((dest_dir + os.path.basename(fn), fn, 'DATA'))
else:
os.path.walk(fn, _visit,
(os.path.dirname(fn), dest_dir, datas))
return mod
def getwarnings(self):
warnings = self.warnings.keys()
for nm, mod in self.modules.items():
if mod:
for w in mod.warnings:
warnings.append(w + ' - %s (%s)' % (mod.__name__, mod.__file__))
return warnings
def getxref(self):
mods = self.modules.items() # (nm, mod)
mods.sort()
rslt = []
for nm, mod in mods:
if mod:
importers = mod._xref.keys()
importers.sort()
rslt.append((nm, importers))
return rslt
| 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.
#
# 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
# ImportDirectors live on the metapath.
# There's one for builtins and one for sys.path.
# Windows gets one for modules gotten from the Registry
# There should be one for Frozen modules
# Mac would have them for PY_RESOURCE modules etc.
# A generalization of Owner - their concept of "turf" is broader
import os
import sys
import imp
import marshal
from PyInstaller import depend
from PyInstaller.compat import set
import PyInstaller.depend.owner
import PyInstaller.log as logging
logger = logging.getLogger('PyInstaller.build.mf')
def getDescr(fnm):
ext = os.path.splitext(fnm)[1]
for (suffix, mode, typ) in imp.get_suffixes():
if suffix == ext:
return (suffix, mode, typ)
class ImportDirector(PyInstaller.depend.owner.Owner):
pass
class BuiltinImportDirector(ImportDirector):
def __init__(self):
self.path = 'Builtins'
def getmod(self, nm, isbuiltin=imp.is_builtin):
if isbuiltin(nm):
return depend.modules.BuiltinModule(nm)
return None
class RegistryImportDirector(ImportDirector):
# for Windows only
def __init__(self):
self.path = "WindowsRegistry"
self.map = {}
try:
import win32api
import win32con
except ImportError:
return
subkey = r"Software\Python\PythonCore\%s\Modules" % sys.winver
for root in (win32con.HKEY_CURRENT_USER, win32con.HKEY_LOCAL_MACHINE):
try:
hkey = win32api.RegOpenKeyEx(root, subkey, 0, win32con.KEY_READ)
except Exception, e:
logger.debug('RegistryImportDirector: %s' % e)
continue
numsubkeys, numvalues, lastmodified = win32api.RegQueryInfoKey(hkey)
for i in range(numsubkeys):
subkeyname = win32api.RegEnumKey(hkey, i)
hskey = win32api.RegOpenKeyEx(hkey, subkeyname, 0, win32con.KEY_READ)
val = win32api.RegQueryValueEx(hskey, '')
desc = getDescr(val[0])
#print " RegistryImportDirector got %s %s" % (val[0], desc) #XXX
self.map[subkeyname] = (val[0], desc)
hskey.Close()
hkey.Close()
break
def getmod(self, nm, loadco=marshal.loads):
stuff = self.map.get(nm)
if stuff:
fnm, (suffix, mode, typ) = stuff
if typ == imp.C_EXTENSION:
return depend.modules.ExtensionModule(nm, fnm)
elif typ == imp.PY_SOURCE:
try:
stuff = open(fnm, 'rU').read() + '\n'
co = compile(stuff, fnm, 'exec')
except SyntaxError, e:
logger.exception(e)
raise SystemExit(10)
else:
stuff = open(fnm, 'rb').read()
co = loadco(stuff[8:])
return depend.modules.PyModule(nm, fnm, co)
return None
class PathImportDirector(ImportDirector):
def __init__(self, pathlist=None, importers=None):
if pathlist is None:
self.path = sys.path
else:
self.path = pathlist
self.ownertypes = filter(None, [
PyInstaller.depend.owner.DirOwner,
PyInstaller.depend.owner.ZipOwner,
PyInstaller.depend.owner.PYZOwner,
PyInstaller.depend.owner.Owner,
])
if importers:
self.shadowpath = importers
else:
self.shadowpath = {}
self.building = set()
def __str__(self):
return str(self.path)
def getmod(self, nm):
mod = None
for thing in self.path:
if isinstance(thing, basestring):
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 path in self.building:
return None
self.building.add(path)
owner = None
for klass in self.ownertypes:
try:
# this may cause an import, which may cause recursion
# hence the protection
owner = klass(path)
except PyInstaller.depend.owner.OwnerError:
pass
except Exception, e:
#print "FIXME: Wrong exception", e
pass
else:
break
self.building.remove(path)
return owner
| 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.
#
# 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
# All we're doing here is tracking, not importing
# If we were importing, these would be hooked to the real module objects
import os
from PyInstaller.compat import ctypes, PYCO
from PyInstaller.depend.utils import _resolveCtypesImports, scan_code
import PyInstaller.depend.impdirector
class Module:
_ispkg = 0
typ = 'UNKNOWN'
def __init__(self, nm):
self.__name__ = nm
self.__file__ = None
self._all = []
self.imports = []
self.warnings = []
self.binaries = []
self.datas = []
self._xref = {}
def ispackage(self):
return self._ispkg
def doimport(self, nm):
pass
def xref(self, nm):
self._xref[nm] = 1
def __str__(self):
return ("<%s %r %s imports=%s binaries=%s datas=%s>" %
(self.__class__.__name__, self.__name__, self.__file__,
self.imports, self.binaries, self.datas))
class BuiltinModule(Module):
typ = 'BUILTIN'
def __init__(self, nm):
Module.__init__(self, nm)
class ExtensionModule(Module):
typ = 'EXTENSION'
def __init__(self, nm, pth):
Module.__init__(self, nm)
self.__file__ = pth
class PyModule(Module):
typ = 'PYMODULE'
def __init__(self, nm, pth, co):
Module.__init__(self, nm)
self.co = co
self.__file__ = pth
if os.path.splitext(self.__file__)[1] == '.py':
self.__file__ = self.__file__ + PYCO
self.scancode()
def scancode(self):
self.imports, self.warnings, self.binaries, allnms = scan_code(self.co)
if allnms:
self._all = allnms
if ctypes and self.binaries:
self.binaries = _resolveCtypesImports(self.binaries)
class PyScript(PyModule):
typ = 'PYSOURCE'
def __init__(self, pth, co):
Module.__init__(self, '__main__')
self.co = co
self.__file__ = pth
self.scancode()
class PkgModule(PyModule):
typ = 'PYMODULE'
def __init__(self, nm, pth, co):
PyModule.__init__(self, nm, pth, co)
self._ispkg = 1
pth = os.path.dirname(pth)
self.__path__ = [pth]
self._update_director(force=True)
def _update_director(self, force=False):
if force or self.subimporter.path != self.__path__:
self.subimporter = PyInstaller.depend.impdirector.PathImportDirector(self.__path__)
def doimport(self, nm):
self._update_director()
mod = self.subimporter.getmod(nm)
if mod:
mod.__name__ = self.__name__ + '.' + mod.__name__
return mod
class PkgInPYZModule(PyModule):
def __init__(self, nm, co, pyzowner):
PyModule.__init__(self, nm, co.co_filename, co)
self._ispkg = 1
self.__path__ = [str(pyzowner)]
self.owner = pyzowner
def doimport(self, nm):
mod = self.owner.getmod(self.__name__ + '.' + nm)
return mod
class PyInZipModule(PyModule):
typ = 'ZIPFILE'
def __init__(self, zipowner, nm, pth, co):
PyModule.__init__(self, nm, co.co_filename, co)
self.owner = zipowner
class PkgInZipModule(PyModule):
typ = 'ZIPFILE'
def __init__(self, zipowner, nm, pth, co):
PyModule.__init__(self, nm, co.co_filename, co)
self._ispkg = 1
self.__path__ = [str(zipowner)]
self.owner = zipowner
def doimport(self, nm):
mod = self.owner.getmod(self.__name__ + '.' + nm)
return mod
| 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.
#
# 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
# 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.
# Note that they replace the string in sys.path,
# but str(sys.path[n]) should yield the original string.
import imp
import marshal
import os
from PyInstaller import depend
from PyInstaller.compat import PYCO, caseOk
from PyInstaller.loader import archive
import PyInstaller.log as logging
logger = logging.getLogger('PyInstaller.build.mf')
class OwnerError(Exception):
pass
class Owner:
"""
Base class for loading Python bytecode from different places.
"""
def __init__(self, path):
self.path = path
def __str__(self):
return self.path
def getmod(self, nm):
return None
class BaseDirOwner(Owner):
"""
Base class for loading bytecode of Python modules from file system.
"""
def _getsuffixes(self):
return imp.get_suffixes()
def getmod(self, nm, getsuffixes=None, loadco=marshal.loads):
if getsuffixes is None:
getsuffixes = self._getsuffixes
possibles = [(nm, 0, None)]
if self._isdir(nm) and self._caseok(nm):
possibles.insert(0, (os.path.join(nm, '__init__'), 1, nm))
py = pyc = None
for pth, ispkg, pkgpth in possibles:
for ext, mode, typ in getsuffixes():
attempt = pth + ext
modtime = self._modtime(attempt)
if modtime is not None:
# Check case
if not self._caseok(attempt):
continue
if typ == imp.C_EXTENSION:
#logger.debug("%s.getmod -> ExtensionModule(%s, %s)", self.__class__.__name__, nm, attempt)
return depend.modules.ExtensionModule(nm, os.path.join(self.path, attempt))
elif typ == imp.PY_SOURCE:
py = (attempt, modtime)
else:
pyc = (attempt, modtime)
if py or pyc:
break
if py is None and pyc is None:
#logger.debug("%s.getmod -> (py == pyc == None)", self.__class__.__name__)
return None
co = None
## if nm == 'archive':
## import pdb ; pdb.set_trace()
if pyc:
stuff = self._read(pyc[0])
# If this file was not generated for this version of
# Python, we need to regenerate it.
if stuff[:4] != imp.get_magic():
logger.warn("wrong version .py%s found (%s), will use .py",
PYCO, pyc[0])
else:
try:
co = loadco(stuff[8:])
pth = pyc[0]
except (ValueError, EOFError):
pyc = None
logger.warn("bad .py%s found (%s), will use .py",
PYCO, pyc[0])
if co is None or py and pyc[1] < py[1]:
# If we have no pyc or py is newer
try:
stuff = self._read(py[0]) + '\n'
co = compile(stuff.replace("\r\n", "\n"), py[0], 'exec')
pth = py[0] + PYCO
logger.debug("compiled %s", pth)
except SyntaxError, e:
logger.exception(e)
raise SystemExit(10)
if co is None:
#logger.debug("%s.getmod -> None", self.__class__.__name__)
return None
pth = os.path.join(self.path, pth)
if not os.path.isabs(pth):
pth = os.path.abspath(pth)
if ispkg:
mod = self._pkgclass()(nm, pth, co)
else:
mod = self._modclass()(nm, pth, co)
#logger.debug("%s.getmod -> %s", self.__class__.__name__, mod)
return mod
class DirOwner(BaseDirOwner):
def __init__(self, path):
if path == '':
path = os.getcwd()
if not os.path.isdir(path):
raise OwnerError("%s is not a directory" % repr(path))
Owner.__init__(self, path)
def _isdir(self, fn):
return os.path.isdir(os.path.join(self.path, fn))
def _modtime(self, fn):
try:
return os.stat(os.path.join(self.path, fn))[8]
except OSError:
return None
def _read(self, fn):
return open(os.path.join(self.path, fn), 'rb').read()
def _pkgclass(self):
return depend.modules.PkgModule
def _modclass(self):
return depend.modules.PyModule
def _caseok(self, fn):
return caseOk(os.path.join(self.path, fn))
class ZipOwner(BaseDirOwner):
"""
Load bytecode of Python modules from .egg files.
zipimporter cannot be used here because it has a stupid bug:
>>> z.find_module("setuptools.setuptools.setuptools.setuptools.setuptools") is not None
True
So mf will go into infinite recursion. Instead, we'll reuse
the BaseDirOwner logic, simply changing the template methods.
"""
def __init__(self, path):
import zipfile
try:
self.zf = zipfile.ZipFile(path, "r")
except IOError:
raise OwnerError("%s is not a zipfile" % path)
Owner.__init__(self, path)
def getmod(self, fn):
fn = fn.replace(".", "/")
return BaseDirOwner.getmod(self, fn)
def _modtime(self, fn):
# zipfiles always use forward slashes
fn = fn.replace("\\", "/")
try:
dt = self.zf.getinfo(fn).date_time
return dt
except KeyError:
return None
def _isdir(self, fn):
# No way to find out if "fn" is a directory
# so just always look into it in case it is.
return True
def _caseok(self, fn):
# zipfile is always case-sensitive, so surely
# there is no case mismatch.
return True
def _read(self, fn):
# zipfiles always use forward slashes
fn = fn.replace("\\", "/")
return self.zf.read(fn)
def _pkgclass(self):
return lambda *args: depend.modules.PkgInZipModule(self, *args)
def _modclass(self):
return lambda *args: depend.modules.PyInZipModule(self, *args)
class PYZOwner(Owner):
"""
Class for loading bytecode of Python modules from PYZ files.
PYZ file is internal PyInstaller format embedded into final executable.
It is possible to have a custom .spec file which packs a subset of Python
files into a PYZ file, and then drop it on the disk somewhere. When the PYZ
file is added to sys.path, PYZOwner will parse it and make the modules
within it available at import time.
NOTE: PYZ format cannot be replaced by zipimport module.
The problem is that we have no control over zipimport; for instance,
it doesn't work if the zip file is embedded into a PKG appended
to an executable, like we create in one-file.
"""
def __init__(self, path):
self.pyz = archive.ZlibArchive(path)
Owner.__init__(self, path)
def getmod(self, nm):
rslt = self.pyz.extract(nm)
if not rslt:
return None
ispkg, co = rslt
if ispkg:
return depend.modules.PkgInPYZModule(nm, co, self)
return depend.modules.PyModule(nm, self.path, co)
| Python |
#
# Copyright (C) 2005-2011, 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.
#
# 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 also that you should check the results to make sure that the
# dlls are redistributable. I've listed most of the common MS dlls
# under "excludes" below; add to this list as necessary (or use the
# "excludes" option in the INSTALL section of the config file).
"""
Manipulating with dynamic libraries.
"""
__all__ = ['exclude_list', 'include_list', 'include_library']
import os
import re
from PyInstaller import is_win, is_unix, is_aix, is_darwin
from PyInstaller.compat import set
import PyInstaller.log as logging
logger = logging.getLogger('PyInstaller.build.dylib')
_BOOTLOADER_FNAMES = set(['run', 'run_d', 'runw', 'runw_d'])
# Regex excludes
# Ignoring some system libraries speeds up packaging process
_excludes = {}
# Regex includes - overrides excludes.
# Include list is used only to override specific libraries
# from exclude list.
_includes = {}
_win_excludes = {
# MS assembly excludes
r'^Microsoft\.Windows\.Common-Controls$': 1,
}
_unix_excludes = {
r'/libc\.so\..*': 1,
r'/libdl\.so\..*': 1,
r'/libm\.so\..*': 1,
r'/libpthread\.so\..*': 1,
r'/librt\.so\..*': 1,
r'/libthread_db\.so\..*': 1,
r'/libdb-.*\.so': 1,
# glibc regex excludes.
r'/ld-linux\.so\..*': 1,
r'/libBrokenLocale\.so\..*': 1,
r'/libanl\.so\..*': 1,
r'/libcidn\.so\..*': 1,
r'/libcrypt\.so\..*': 1,
r'/libnsl\.so\..*': 1,
r'/libnss_compat.*\.so\..*': 1,
r'/libnss_dns.*\.so\..*': 1,
r'/libnss_files.*\.so\..*': 1,
r'/libnss_hesiod.*\.so\..*': 1,
r'/libnss_nis.*\.so\..*': 1,
r'/libnss_nisplus.*\.so\..*': 1,
r'/libresolv\.so\..*': 1,
r'/libutil\.so\..*': 1,
# libGL can reference some hw specific libraries (like nvidia libs).
r'/libGL\..*': 1,
}
_aix_excludes = {
r'/libbz2\.a': 1,
r'/libc\.a': 1,
r'/libC\.a': 1,
r'/libcrypt\.a': 1,
r'/libdl\.a': 1,
r'/libintl\.a': 1,
r'/libpthreads\.a': 1,
r'/librt\\.a': 1,
r'/librtl\.a': 1,
r'/libz\.a': 1,
}
if is_win:
_excludes = _win_excludes
from PyInstaller.utils import winutils
sep = '[%s]' % re.escape(os.sep + os.altsep)
# Exclude everything from the Windows directory by default.
windir = re.escape(winutils.get_windows_dir())
_excludes['^%s%s' % (windir, sep)] = 1
# Allow pythonNN.dll, pythoncomNN.dll, pywintypesNN.dll
_includes[r'%spy(?:thon(?:com(?:loader)?)?|wintypes)\d+\.dll$' % sep] = 1
elif is_aix:
# The exclude list for AIX differs from other *nix platforms.
_excludes = _aix_excludes
elif is_unix:
# Common excludes for *nix platforms -- except AIX.
_excludes = _unix_excludes
class ExcludeList(object):
def __init__(self):
self.regex = re.compile('|'.join(_excludes.keys()), re.I)
def search(self, libname):
# Running re.search() on '' regex never returns None.
if _excludes:
return self.regex.search(libname)
else:
return False
class IncludeList(object):
def __init__(self):
self.regex = re.compile('|'.join(_includes.keys()), re.I)
def search(self, libname):
# Running re.search() on '' regex never returns None.
if _includes:
return self.regex.search(libname)
else:
return False
exclude_list = ExcludeList()
include_list = IncludeList()
if is_darwin:
# On Mac use macholib to decide if a binary is a system one.
from PyInstaller.lib.macholib import util
class MacExcludeList(object):
def search(self, libname):
return util.in_system_path(libname)
exclude_list = MacExcludeList()
def include_library(libname):
"""
Check if a dynamic library should be included with application or not.
"""
# For configuration phase we need to have exclude / include lists None
# so these checking is skipped and library gets included.
if exclude_list:
if exclude_list.search(libname) and not include_list.search(libname):
# Library is excluded and is not overriden by include list.
# It should be then excluded.
return False
else:
# Include library
return True
else:
# By default include library.
return True
def mac_set_relative_dylib_deps(libname, distname):
"""
On Mac OS X set relative paths to dynamic library dependencies
of `libname`.
Relative paths allow to avoid using environment variable DYLD_LIBRARY_PATH.
There are known some issues with DYLD_LIBRARY_PATH. Relative paths is
more flexible mechanism.
Current location of dependend libraries is derived from the location
of the library path (paths start with '@loader_path').
'distname' path of the library relative to dist directory of frozen
executable. We need this to determine the level of directory
level for @loader_path of binaries not found in dist directory.
E.g. qt4 plugins are not in the same directory as Qt*.dylib
files. Without using '@loader_path/../..' for qt plugins
Mac OS X would not be able to resolve shared library
dependencies and qt plugins will not be loaded.
"""
from PyInstaller.lib.macholib import util
from PyInstaller.lib.macholib.MachO import MachO
# Ignore bootloader otherwise PyInstaller fails with exception like
# 'ValueError: total_size > low_offset (288 > 0)'
if os.path.basename(libname) in _BOOTLOADER_FNAMES:
return
# Determine how many directories up is the directory with shared
# dynamic libraries. '../'
# E.g. ./qt4_plugins/images/ -> ./../../
parent_dir = ''
# Check if distname is not only base filename.
if os.path.dirname(distname):
parent_level = len(os.path.dirname(distname).split(os.sep))
parent_dir = parent_level * (os.pardir + os.sep)
def match_func(pth):
"""
For system libraries is still used absolute path. It is unchanged.
"""
# Match non system dynamic libraries.
if not util.in_system_path(pth):
# Use relative path to dependend dynamic libraries bases on
# location of the executable.
return os.path.join('@loader_path', parent_dir,
os.path.basename(pth))
# Rewrite mach headers with @loader_path.
dll = MachO(libname)
dll.rewriteLoadCommands(match_func)
# Write changes into file.
# Write code is based on macholib example.
try:
f = open(dll.filename, 'rb+')
for header in dll.headers:
f.seek(0)
dll.write(f)
f.seek(0, 2)
f.flush()
f.close()
except Exception:
pass
| 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.
#
# 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
# Scan the code object for imports, __all__ and wierd stuff
import dis
import os
from PyInstaller import compat
from PyInstaller.compat import set, ctypes
from PyInstaller import is_unix, is_darwin, is_py25, is_py27
import PyInstaller.depend.utils
import PyInstaller.log as logging
logger = logging.getLogger(__name__)
IMPORT_NAME = dis.opname.index('IMPORT_NAME')
IMPORT_FROM = dis.opname.index('IMPORT_FROM')
try:
IMPORT_STAR = dis.opname.index('IMPORT_STAR')
except:
IMPORT_STAR = None
STORE_NAME = dis.opname.index('STORE_NAME')
STORE_FAST = dis.opname.index('STORE_FAST')
STORE_GLOBAL = dis.opname.index('STORE_GLOBAL')
try:
STORE_MAP = dis.opname.index('STORE_MAP')
except:
STORE_MAP = None
LOAD_GLOBAL = dis.opname.index('LOAD_GLOBAL')
LOAD_ATTR = dis.opname.index('LOAD_ATTR')
LOAD_NAME = dis.opname.index('LOAD_NAME')
EXEC_STMT = dis.opname.index('EXEC_STMT')
try:
SET_LINENO = dis.opname.index('SET_LINENO')
except ValueError:
SET_LINENO = None
BUILD_LIST = dis.opname.index('BUILD_LIST')
LOAD_CONST = dis.opname.index('LOAD_CONST')
if is_py25:
LOAD_CONST_level = LOAD_CONST
else:
LOAD_CONST_level = None
if is_py27:
COND_OPS = set([dis.opname.index('POP_JUMP_IF_TRUE'),
dis.opname.index('POP_JUMP_IF_FALSE'),
dis.opname.index('JUMP_IF_TRUE_OR_POP'),
dis.opname.index('JUMP_IF_FALSE_OR_POP'),
])
else:
COND_OPS = set([dis.opname.index('JUMP_IF_FALSE'),
dis.opname.index('JUMP_IF_TRUE'),
])
JUMP_FORWARD = dis.opname.index('JUMP_FORWARD')
try:
STORE_DEREF = dis.opname.index('STORE_DEREF')
except ValueError:
STORE_DEREF = None
STORE_OPS = set([STORE_NAME, STORE_FAST, STORE_GLOBAL, STORE_DEREF, STORE_MAP])
#IMPORT_STAR -> IMPORT_NAME mod ; IMPORT_STAR
#JUMP_IF_FALSE / JUMP_IF_TRUE / JUMP_FORWARD
HASJREL = set(dis.hasjrel)
def pass1(code):
instrs = []
i = 0
n = len(code)
curline = 0
incondition = 0
out = 0
while i < n:
if i >= out:
incondition = 0
c = code[i]
i = i + 1
op = ord(c)
if op >= dis.HAVE_ARGUMENT:
oparg = ord(code[i]) + ord(code[i + 1]) * 256
i = i + 2
else:
oparg = None
if not incondition and op in COND_OPS:
incondition = 1
out = oparg
if op in HASJREL:
out += i
elif incondition and op == JUMP_FORWARD:
out = max(out, i + oparg)
if op == SET_LINENO:
curline = oparg
else:
instrs.append((op, oparg, incondition, curline))
return instrs
def scan_code(co, m=None, w=None, b=None, nested=0):
instrs = pass1(co.co_code)
if m is None:
m = []
if w is None:
w = []
if b is None:
b = []
all = []
lastname = None
level = -1 # import-level, same behaviour as up to Python 2.4
for i, (op, oparg, conditional, curline) in enumerate(instrs):
if op == IMPORT_NAME:
if level <= 0:
name = lastname = co.co_names[oparg]
else:
name = lastname = co.co_names[oparg]
#print 'import_name', name, `lastname`, level
m.append((name, nested, conditional, level))
elif op == IMPORT_FROM:
name = co.co_names[oparg]
#print 'import_from', name, `lastname`, level,
if level > 0 and (not lastname or lastname[-1:] == '.'):
name = lastname + name
else:
name = lastname + '.' + name
#print name
m.append((name, nested, conditional, level))
assert lastname is not None
elif op == IMPORT_STAR:
assert lastname is not None
m.append((lastname + '.*', nested, conditional, level))
elif op == STORE_NAME:
if co.co_names[oparg] == "__all__":
j = i - 1
pop, poparg, pcondtl, pline = instrs[j]
if pop != BUILD_LIST:
w.append("W: __all__ is built strangely at line %s" % pline)
else:
all = []
while j > 0:
j = j - 1
pop, poparg, pcondtl, pline = instrs[j]
if pop == LOAD_CONST:
all.append(co.co_consts[poparg])
else:
break
elif op in STORE_OPS:
pass
elif op == LOAD_CONST_level:
# starting with Python 2.5, _each_ import is preceeded with a
# LOAD_CONST to indicate the relative level.
if isinstance(co.co_consts[oparg], (int, long)):
level = co.co_consts[oparg]
elif op == LOAD_GLOBAL:
name = co.co_names[oparg]
cndtl = ['', 'conditional'][conditional]
lvl = ['top-level', 'delayed'][nested]
if name == "__import__":
w.append("W: %s %s __import__ hack detected at line %s" % (lvl, cndtl, curline))
elif name == "eval":
w.append("W: %s %s eval hack detected at line %s" % (lvl, cndtl, curline))
elif op == EXEC_STMT:
cndtl = ['', 'conditional'][conditional]
lvl = ['top-level', 'delayed'][nested]
w.append("W: %s %s exec statement detected at line %s" % (lvl, cndtl, curline))
else:
lastname = None
if ctypes:
# ctypes scanning requires a scope wider than one bytecode instruction,
# so the code resides in a separate function for clarity.
ctypesb, ctypesw = scan_code_for_ctypes(co, instrs, i)
b.extend(ctypesb)
w.extend(ctypesw)
for c in co.co_consts:
if isinstance(c, type(co)):
# FIXME: "all" was not updated here nor returned. Was it the desired
# behaviour?
_, _, _, all_nested = scan_code(c, m, w, b, 1)
all.extend(all_nested)
return m, w, b, all
def scan_code_for_ctypes(co, instrs, i):
"""
Detects ctypes dependencies, using reasonable heuristics that should
cover most common ctypes usages; returns a tuple of two lists, one
containing names of binaries detected as dependencies, the other containing
warnings.
"""
def _libFromConst(i):
"""Extracts library name from an expected LOAD_CONST instruction and
appends it to local binaries list.
"""
op, oparg, conditional, curline = instrs[i]
if op == LOAD_CONST:
soname = co.co_consts[oparg]
b.append(soname)
b = []
op, oparg, conditional, curline = instrs[i]
if op in (LOAD_GLOBAL, LOAD_NAME):
name = co.co_names[oparg]
if name in ("CDLL", "WinDLL"):
# Guesses ctypes imports of this type: CDLL("library.so")
# LOAD_GLOBAL 0 (CDLL) <--- we "are" here right now
# LOAD_CONST 1 ('library.so')
_libFromConst(i + 1)
elif name == "ctypes":
# Guesses ctypes imports of this type: ctypes.DLL("library.so")
# LOAD_GLOBAL 0 (ctypes) <--- we "are" here right now
# LOAD_ATTR 1 (CDLL)
# LOAD_CONST 1 ('library.so')
op2, oparg2, conditional2, curline2 = instrs[i + 1]
if op2 == LOAD_ATTR:
if co.co_names[oparg2] in ("CDLL", "WinDLL"):
# Fetch next, and finally get the library name
_libFromConst(i + 2)
elif name in ("cdll", "windll"):
# Guesses ctypes imports of these types:
# * cdll.library (only valid on Windows)
# LOAD_GLOBAL 0 (cdll) <--- we "are" here right now
# LOAD_ATTR 1 (library)
# * cdll.LoadLibrary("library.so")
# LOAD_GLOBAL 0 (cdll) <--- we "are" here right now
# LOAD_ATTR 1 (LoadLibrary)
# LOAD_CONST 1 ('library.so')
op2, oparg2, conditional2, curline2 = instrs[i + 1]
if op2 == LOAD_ATTR:
if co.co_names[oparg2] != "LoadLibrary":
# First type
soname = co.co_names[oparg2] + ".dll"
b.append(soname)
else:
# Second type, needs to fetch one more instruction
_libFromConst(i + 2)
# If any of the libraries has been requested with anything different from
# the bare filename, drop that entry and warn the user - pyinstaller would
# need to patch the compiled pyc file to make it work correctly!
w = []
for bin in list(b):
if bin != os.path.basename(bin):
b.remove(bin)
w.append("W: ignoring %s - ctypes imports only supported using bare filenames" % (bin,))
return b, w
def _resolveCtypesImports(cbinaries):
"""Completes ctypes BINARY entries for modules with their full path.
"""
from ctypes.util import find_library
if is_unix:
envvar = "LD_LIBRARY_PATH"
elif is_darwin:
envvar = "DYLD_LIBRARY_PATH"
else:
envvar = "PATH"
def _setPaths():
path = os.pathsep.join(PyInstaller.__pathex__)
old = compat.getenv(envvar)
if old is not None:
path = os.pathsep.join((path, old))
compat.setenv(envvar, path)
return old
def _restorePaths(old):
if old is None:
compat.unsetenv(envvar)
else:
compat.setenv(envvar, old)
ret = []
# Try to locate the shared library on disk. This is done by
# executing ctypes.utile.find_library prepending ImportTracker's
# local paths to library search paths, then replaces original values.
old = _setPaths()
for cbin in cbinaries:
# Ignore annoying warnings like:
# 'W: library kernel32.dll required via ctypes not found'
# 'W: library coredll.dll required via ctypes not found'
if cbin in ['coredll.dll', 'kernel32.dll']:
continue
ext = os.path.splitext(cbin)[1]
# On Windows, only .dll files can be loaded.
if os.name == "nt" and ext.lower() in [".so", ".dylib"]:
continue
cpath = find_library(os.path.splitext(cbin)[0])
if is_unix:
# CAVEAT: find_library() is not the correct function. Ctype's
# documentation says that it is meant to resolve only the filename
# (as a *compiler* does) not the full path. Anyway, it works well
# enough on Windows and Mac. On Linux, we need to implement
# more code to find out the full path.
if cpath is None:
cpath = cbin
# "man ld.so" says that we should first search LD_LIBRARY_PATH
# and then the ldcache
for d in compat.getenv(envvar, '').split(os.pathsep):
if os.path.isfile(os.path.join(d, cpath)):
cpath = os.path.join(d, cpath)
break
else:
text = compat.exec_command("/sbin/ldconfig", "-p")
for L in text.strip().splitlines():
if cpath in L:
cpath = L.split("=>", 1)[1].strip()
assert os.path.isfile(cpath)
break
else:
cpath = None
if cpath is None:
logger.warn("library %s required via ctypes not found", cbin)
else:
ret.append((cbin, cpath, "BINARY"))
_restorePaths(old)
return ret
| Python |
#
# Various classes and functions to provide some backwards-compatibility
# with previous versions of Python from 2.3 onward.
#
# Copyright (C) 2011, 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 dircache # Module removed in Python 3
import os
import sys
try:
import subprocess
except ImportError:
# :todo: remove when dropping Python 2.3 compatibility
# fall back to out version of `subprocess`
import PyInstaller.lib.__subprocess as subprocess
is_py23 = sys.version_info >= (2, 3)
is_py24 = sys.version_info >= (2, 4)
is_py25 = sys.version_info >= (2, 5)
is_py26 = sys.version_info >= (2, 6)
is_py27 = sys.version_info >= (2, 7)
is_win = sys.platform.startswith('win')
is_cygwin = sys.platform == 'cygwin'
is_darwin = sys.platform == 'darwin' # Mac OS X
# Unix platforms
is_linux = sys.platform.startswith('linux')
is_solar = sys.platform.startswith('sun') # Solaris
is_aix = sys.platform.startswith('aix')
# Some code parts are similar to several unix platforms
# (e.g. Linux, Solaris, AIX)
# Mac OS X is not considered as unix since there are many
# platform specific details for Mac in PyInstaller.
is_unix = is_linux or is_solar or is_aix
# In debug mode a .log file is written.
if __debug__:
import UserDict
class LogDict(UserDict.UserDict):
count = 0
def __init__(self, *args):
UserDict.UserDict.__init__(self, *args)
LogDict.count += 1
logfile = "logdict%s-%d.log" % (".".join(map(str, sys.version_info)),
LogDict.count)
if os.path.isdir("build"):
logfile = os.path.join("build", logfile)
self.logfile = open(logfile, "w")
def __setitem__(self, key, value):
self.logfile.write("%s: %s -> %s\n" % (key, self.data.get(key), value))
UserDict.UserDict.__setitem__(self, key, value)
def __delitem__(self, key):
self.logfile.write(" DEL %s\n" % key)
UserDict.UserDict.__delitem__(self, key)
else:
LogDict = dict
# Correct extension ending: 'c' or 'o'
if __debug__:
PYCO = 'c'
else:
PYCO = 'o'
# os.devnull is available since Python 2.4+.
if hasattr(os, 'devnull'):
devnull = os.devnull
else:
if is_win:
devnull = 'nul'
else:
devnull = '/dev/null'
# If ctypes is present, specific dependency discovery can be enabled.
try:
import ctypes
except ImportError:
ctypes = None
if 'PYTHONCASEOK' not in os.environ:
def caseOk(filename):
files = dircache.listdir(os.path.dirname(filename))
return os.path.basename(filename) in files
else:
def caseOk(filename):
return True
# Obsolete command line options (do not exist anymore).
_OLD_OPTIONS = [
'--upx', '-X',
'-K', '--tk',
'-C', '--configfile',
'--skip-configure',
]
# Options for python interpreter when invoked in a subprocess.
_PYOPTS = __debug__ and '-O' or ''
try:
# Python 2.5+
import hashlib
except ImportError:
class hashlib(object):
from md5 import new as md5
from sha import new as sha
# In Python 2.4+ there is a builtin type set(). In Python 2.3
# it is class Set in module sets.
try:
from __builtin__ import set
except ImportError:
from sets import Set as set
# Function os.path.relpath() available in Python 2.6+.
if hasattr(os.path, 'relpath'):
from os.path import relpath
# Own implementation of relpath function.
else:
def relpath(path, start=os.curdir):
"""
Return a relative version of a path.
"""
if not path:
raise ValueError("no path specified")
# Normalize paths.
path = os.path.normpath(path)
start = os.path.abspath(start) + os.sep # os.sep has to be here.
# Get substring.
relative = path[len(start):len(path)]
return relative
# Some code parts needs to behave different when running in virtualenv.
is_virtualenv = hasattr(sys, 'real_prefix')
def architecture():
"""
Returns the bit depth of the python interpreter's architecture as
a string ('32bit' or '64bit'). Similar to platform.architecture(),
but with fixes for universal binaries on MacOS.
"""
import platform
if is_darwin:
# Darwin's platform.architecture() is buggy and always
# returns "64bit" event for the 32bit version of Python's
# universal binary. So we roll out our own (that works
# on Darwin).
if sys.maxint > 2L ** 32:
return '64bit'
else:
return '32bit'
else:
return platform.architecture()[0]
def system():
import platform
# On some Windows installation (Python 2.4) platform.system() is
# broken and incorrectly returns 'Microsoft' instead of 'Windows'.
# http://mail.python.org/pipermail/patches/2007-June/022947.html
syst = platform.system()
if syst == 'Microsoft':
return 'Windows'
return syst
# Set and get environment variables does not handle unicode strings correctly
# on Windows.
# Acting on os.environ instead of using getenv()/setenv()/unsetenv(),
# as suggested in <http://docs.python.org/library/os.html#os.environ>:
# "Calling putenv() directly does not change os.environ, so it's
# better to modify os.environ." (Same for unsetenv.)
def getenv(name, default=None):
"""
Returns unicode string containing value of environment variable 'name'.
"""
return os.environ.get(name, default)
def setenv(name, value):
"""
Accepts unicode string and set it as environment variable 'name' containing
value 'value'.
"""
os.environ[name] = value
def unsetenv(name):
"""
Delete the environment variable 'name'.
"""
# Some platforms (e.g. AIX) do not support `os.unsetenv()` and
# thus `del os.environ[name]` has no effect onto the real
# environment. For this case we set the value to the empty string.
os.environ[name] = ""
del os.environ[name]
# Exec commands in subprocesses.
def exec_command(*cmdargs):
"""
Wrap creating subprocesses
Return stdout of the invoked command.
Todo: Use module `subprocess` if available, else `os.system()`
"""
return subprocess.Popen(cmdargs, stdout=subprocess.PIPE).communicate()[0]
def exec_command_rc(*cmdargs, **kwargs):
"""
Wrap creating subprocesses.
Return exit code of the invoked command.
Todo: Use module `subprocess` if available, else `os.system()`
"""
return subprocess.call(cmdargs, **kwargs)
def exec_command_all(*cmdargs, **kwargs):
"""
Wrap creating subprocesses
Return tuple (exit_code, stdout, stderr) of the invoked command.
"""
proc = subprocess.Popen(cmdargs, bufsize=-1, # Default OS buffer size.
stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs)
# Waits for subprocess to complete.
out, err = proc.communicate()
return proc.returncode, out, err
def __wrap_python(args, kwargs):
cmdargs = [sys.executable]
# Mac OS X supports universal binaries (binary for multiple architectures.
# We need to ensure that subprocess binaries are running for the same
# architecture as python executable.
# It is necessary to run binaries with 'arch' command.
if is_darwin:
mapping = {'32bit': '-i386', '64bit': '-x86_64'}
py_prefix = ['arch', mapping[architecture()]]
cmdargs = py_prefix + cmdargs
if _PYOPTS:
cmdargs.append(_PYOPTS)
cmdargs.extend(args)
return cmdargs, kwargs
def exec_python(*args, **kwargs):
"""
Wrap running python script in a subprocess.
Return stdout of the invoked command.
"""
cmdargs, kwargs = __wrap_python(args, kwargs)
return exec_command(*cmdargs, **kwargs)
def exec_python_rc(*args, **kwargs):
"""
Wrap running python script in a subprocess.
Return exit code of the invoked command.
"""
cmdargs, kwargs = __wrap_python(args, kwargs)
return exec_command_rc(*cmdargs, **kwargs)
def exec_python_all(*args, **kwargs):
"""
Wrap running python script in a subprocess.
Return tuple (exit_code, stdout, stderr) of the invoked command.
"""
cmdargs, kwargs = __wrap_python(args, kwargs)
return exec_command_all(*cmdargs, **kwargs)
# Obsolete command line options.
def __obsolete_option(option, opt, value, parser):
parser.error('%s option does not exist anymore (obsolete).' % opt)
def __add_obsolete_options(parser):
"""
Add the obsolete options to a option-parser instance and
print error message when they are present.
"""
g = parser.add_option_group('Obsolete options (not used anymore)')
g.add_option(*_OLD_OPTIONS,
**{'action': 'callback',
'callback': __obsolete_option,
'help': 'These options do not exist anymore.'})
| 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 PyInstaller.hooks.hookutils import qt4_plugins_binaries
def hook(mod):
mod.binaries.extend(qt4_plugins_binaries('script'))
return mod
| 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 PyInstaller.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 |
#
# Copyright (C) 2012, Daniel Hyams
#
# 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 PyInstaller.hooks.hookutils
from PyInstaller.hooks.hookutils import logger
def hook(mod):
pth = str(mod.__path__[0])
if os.path.isdir(pth):
# If the user imported setuparg1, this is detected
# by the hook-wx.lib.pubsub.setuparg1.py hook. That
# hook sets PyInstaller.hooks.hookutils.wxpubsub
# to "arg1", and we set the appropriate path here.
protocol = getattr(PyInstaller.hooks.hookutils, 'wxpubsub', 'kwargs')
logger.info('wx.lib.pubsub: Adding %s protocol path' % protocol)
mod.__path__.append(os.path.normpath(os.path.join(pth, protocol)))
return mod
| Python |
from PyInstaller.hooks.hookutils import exec_statement
mpl_data_dir = exec_statement(
"import matplotlib; print matplotlib._get_data_path()")
datas = [
(mpl_data_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
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 mod.__file__.find('_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(os.path.join(modpath, 'backends', '*.py')):
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 PyInstaller.hooks.hookutils import qt4_plugins_binaries
def hook(mod):
mod.binaries.extend(qt4_plugins_binaries('codecs'))
return mod
| Python |
#
# Copyright (C) 2012, Martin Zibricky
# 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
from PyInstaller.hooks.hookutils import get_pyextension_imports
# It's hard to detect imports of binary Python module without importing it.
# Let's try importing that module in a subprocess.
# TODO function get_pyextension_imports() is experimental and we need
# to evaluate its usage here and its suitability for other hooks.
hiddenimports = get_pyextension_imports('pyodbc')
| 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
import glob
import os
import PyInstaller
import PyInstaller.compat as compat
from hookutils import django_dottedstring_imports, find_django_root
python_path = compat.getenv("PYTHONPATH")
if python_path:
python_path = os.pathsep.join([python_path] + PyInstaller.__pathex__)
else:
python_path = os.pathsep.join(PyInstaller.__pathex__)
django_root_dirs = [find_django_root(path)
for path in python_path.split(os.pathsep)]
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 PyInstaller.__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.")
compat.setenv("PYTHONPATH", python_path)
hiddenimports = [django_dottedstring_imports(root_dir)
for root_dir in django_root_dirs]
| Python |
import sys
from PyInstaller.hooks.hookutils import qt4_menu_nib_dir
# In the new consolidated mode any PyQt depends on _qt
hiddenimports = ['sip', 'PyQt4._qt']
# For Qt to work on Mac OS X it is necessary include
# directory qt_menu.nib. This directory contains some
# resource files necessary to run PyQt app.
if sys.platform.startswith('darwin'):
datas = [
(qt4_menu_nib_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 sys
hiddenimports = []
def hook(mod):
global hiddenimports
# `PIL.Image` may be imported as `PIL.Image` or as `Image`
# (without the prefix). We need to use the same module name to
# avoid the same module under two different names.
__import__(mod.__name__)
image_mod = sys.modules[mod.__name__]
# PIL uses lazy initialization.
# first import the default stuff ...
image_mod.preinit()
# ... then every available plugin
image_mod.init()
for name in sys.modules:
if name.endswith("ImagePlugin"):
hiddenimports.append(name)
return mod
| 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 |
#
# Copyright (C) 2012, 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
from PyInstaller.hooks.hookutils import matplotlib_backends
# Include only available matplotlib backends.
hiddenimports = matplotlib_backends()
| Python |
#
# Copyright (C) 2012, 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
# Replace the code of real 'site' module by fake code doing nothing.
#
# The real 'site' does some magic to find paths to other possible
# Python modules. We do not want this behaviour for frozen applications.
#
# Fake 'site' makes PyInstaller to work with distutils and to work inside
# virtualenv environment.
import os
import PyInstaller
def hook(mod):
# Replace mod by fake 'site' module.
pyi_dir = os.path.abspath(os.path.dirname(PyInstaller.__file__))
fake_file = os.path.join(pyi_dir, 'fake', 'fake-site.py')
new_code_object = PyInstaller.utils.misc.get_code_object(fake_file)
mod = PyInstaller.depend.modules.PyModule('site', fake_file, new_code_object)
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
# cElementTree has a hidden import
hiddenimports = ['elementtree.ElementTree']
| Python |
#
# Copyright (C) 2012, Martin Zibricky
# 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
hiddenimports = [
# win32com client and server util
# modules could be hidden imports
# of some modules using win32com.
# Included for completeness.
'win32com.client.util',
'win32com.server.util',
]
def hook(mod):
# win32com module changes sys.path and wrapps win32comext modules.
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) 2009, 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 PyInstaller.hooks.hookutils import exec_statement
# include most common database bindings
# some database bindings are detected and include some
# are not. We should explicitly include database backends.
hiddenimports = ['pysqlite2', 'MySQLdb', 'psycopg2']
# sqlalchemy.databases package from pre 0.6 sqlachemy versions
databases = exec_statement("import sqlalchemy.databases;print sqlalchemy.databases.__all__")
databases = eval(databases.strip())
for n in databases:
hiddenimports.append("sqlalchemy.databases." + n)
# sqlalchemy.dialects package from 0.6 and newer sqlachemy versions
version = exec_statement('import sqlalchemy; print sqlalchemy.__version__')
is_alch06 = version >= '0.6'
if is_alch06:
dialects = exec_statement("import sqlalchemy.dialects;print sqlalchemy.dialects.__all__")
dialects = eval(dialects.strip())
for n in databases:
hiddenimports.append("sqlalchemy.dialects." + n)
| Python |
#
# Copyright (C) 2012, Martin Zibricky
# Copyright (C) 2011, Hartmut Goebel
# Copyright (C) 2005, Giovanni Bajo
#
# 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 PyInstaller.bindepend
from PyInstaller.compat import is_py24, is_win, is_darwin, is_unix, is_virtualenv
from PyInstaller.build import Tree
from PyInstaller.hooks.hookutils import exec_statement, logger
def _handle_broken_tk():
"""
Workaround for broken Tcl/Tk detection in virtualenv on Windows.
There is a bug in older versions of virtualenv in setting paths
to Tcl/Tk properly. PyInstaller running in virtualenv is then
not able to find Tcl/Tk.
This issue has been experienced in virtualenv with Python 2.4 on Win7.
https://github.com/pypa/virtualenv/issues/93
"""
if is_win and is_virtualenv and is_py24:
basedir = os.path.join(sys.real_prefix, 'tcl')
files = os.listdir(basedir)
v = os.environ
# Detect Tcl/Tk paths.
for f in files:
abs_path = os.path.join(basedir, f)
if f.startswith('tcl') and os.path.isdir(abs_path):
v['TCL_LIBRARY'] = abs_path
if f.startswith('tk') and os.path.isdir(abs_path):
v['TK_LIBRARY'] = abs_path
if f.startswith('tix') and os.path.isdir(abs_path):
v['TIX_LIBRARY'] = abs_path
def _find_tk_darwin_frameworks(binaries):
"""
Tcl and Tk are installed as Mac OS X Frameworks.
"""
tcl_root = tk_root = None
for nm, fnm in binaries:
if nm == 'Tcl':
tcl_root = os.path.join(os.path.dirname(fnm), 'Resources/Scripts')
if nm == 'Tk':
tk_root = os.path.join(os.path.dirname(fnm), 'Resources/Scripts')
return tcl_root, tk_root
def _find_tk_tclshell():
"""
Get paths to Tcl/Tk from the Tcl shell command 'info library'.
This command will return path to TCL_LIBRARY.
On most systems are Tcl and Tk libraries installed
in the same prefix.
"""
tcl_root = tk_root = None
# Python code to get path to TCL_LIBRARY.
code = 'from Tkinter import Tcl; t = Tcl(); print t.eval("info library")'
tcl_root = exec_statement(code)
tk_version = exec_statement('from _tkinter import TK_VERSION as v; print v')
# TK_LIBRARY is in the same prefix as Tcl.
tk_root = os.path.join(os.path.dirname(tcl_root), 'tk%s' % tk_version)
return tcl_root, tk_root
def _find_tk(mod):
"""
Find paths with Tcl and Tk data files to be bundled by PyInstaller.
Return:
tcl_root path to Tcl data files.
tk_root path to Tk data files.
"""
bins = PyInstaller.bindepend.selectImports(mod.__file__)
if is_darwin:
# _tkinter depends on system Tcl/Tk frameworks.
if not bins:
# 'mod.binaries' can't be used because on Mac OS X _tkinter.so
# might depend on system Tcl/Tk frameworks and these are not
# included in 'mod.binaries'.
bins = PyInstaller.bindepend.getImports(mod.__file__)
# Reformat data structure from
# set(['lib1', 'lib2', 'lib3'])
# to
# [('Tcl', '/path/to/Tcl'), ('Tk', '/path/to/Tk')]
mapping = {}
for l in bins:
mapping[os.path.basename(l)] = l
bins = [
('Tcl', mapping['Tcl']),
('Tk', mapping['Tk']),
]
# _tkinter depends on Tcl/Tk compiled as frameworks.
path_to_tcl = bins[0][1]
if 'Library/Frameworks' in path_to_tcl:
tcl_tk = _find_tk_darwin_frameworks(bins)
# Tcl/Tk compiled as on Linux other Unices.
# For example this is the case of Tcl/Tk from macports.
else:
tcl_tk = _find_tk_tclshell()
else:
tcl_tk = _find_tk_tclshell()
return tcl_tk
def _collect_tkfiles(mod):
# Workaround for broken Tcl/Tk detection in virtualenv on Windows.
_handle_broken_tk()
tcl_root, tk_root = _find_tk(mod)
tcldir = "tcl"
tkdir = "tk"
tcltree = Tree(tcl_root, os.path.join('_MEI', tcldir),
excludes=['demos', 'encoding', '*.lib', 'tclConfig.sh'])
tktree = Tree(tk_root, os.path.join('_MEI', tkdir),
excludes=['demos', 'encoding', '*.lib', 'tkConfig.sh'])
return (tcltree + tktree)
def hook(mod):
# If not supported platform, skip TCL/TK detection.
if not (is_win or is_darwin or is_unix):
logger.info("... skipping TCL/TK detection on this platform (%s)",
sys.platform)
return mod
# Get the Tcl/Tk data files for bundling with executable.
#try:
tk_files = _collect_tkfiles(mod)
mod.datas.extend(tk_files)
#except:
#logger.error("could not find TCL/TK")
return mod
| Python |
#
# Copyright (C) 2012, 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
# pyttsx imports drivers module based on specific platform.
# Found at http://mrmekon.tumblr.com/post/5272210442/pyinstaller-and-pyttsx
hiddenimports = [
'drivers',
'drivers.dummy',
'drivers.espeak',
'drivers.nsss',
'drivers.sapi5',
]
| Python |
#
# Copyright (C) 2012, 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
hiddenimports = [
'sip',
'PyQt4.QtCore',
'PyQt4.QtGui',
'PyQt4.QtSql',
'PyQt4.QtNetwork',
'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
# 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 PyInstaller.hooks.shared_PIL_SpiderImagePlugin import *
| Python |
hiddenimports = ['sip', 'PyQt4.QtCore', 'PyQt4._qt']
from PyInstaller.hooks.hookutils import qt4_plugins_binaries
def hook(mod):
mod.binaries.extend(qt4_plugins_binaries('accessible'))
mod.binaries.extend(qt4_plugins_binaries('iconengines'))
mod.binaries.extend(qt4_plugins_binaries('imageformats'))
mod.binaries.extend(qt4_plugins_binaries('inputmethods'))
mod.binaries.extend(qt4_plugins_binaries('graphicssystems'))
return mod
| 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 |
#
# Copyright (C) 2011, Vinay Sajip
#
# 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
# Hook for PyZMQ. Cython based Python bindings for messaging library ZeroMQ.
# http://www.zeromq.org/
hiddenimports = [
'zmq.core.pysocket',
'zmq.utils.jsonapi',
'zmq.utils.strtypes',
]
| 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
import PyInstaller.compat as compat
from hookutils import logger
if not compat.getenv("DJANGO_SETTINGS_MODULE"):
compat.setenv("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(compat.getenv("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)
logger.debug('%r', sorted(set(hiddenimports)))
| Python |
hiddenimports = ['sip', 'PyQt4.QtCore', 'PyQt4.QtGui', '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
import sys
def hook(mod):
for i, m in enumerate(mod.imports):
if m[0] == 'strop':
del mod.imports[i]
break
return mod
| Python |
hiddenimports = ["sql_mar"]
| Python |
hiddenimports = ['sip', 'PyQt4.QtGui', 'PyQt4._qt']
from PyInstaller.hooks.hookutils import qt4_plugins_binaries
def hook(mod):
mod.binaries.extend(qt4_plugins_binaries('phonon_backend'))
return mod
| Python |
#
# Copyright (C) 2011, 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
from PyInstaller import is_unix, is_darwin
hiddenimports = [
# Test case import/test_zipimport2 fails during importing
# pkg_resources or setuptools when module not present.
'distutils.command.build_ext',
]
# Necessary for setuptools on Mac/Unix
if is_unix or is_darwin:
hiddenimports.append('syslog')
| 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
def hook(mod):
if 'posix' in sys.builtin_module_names:
removes = ['nt', 'ntpath', 'dos', 'dospath', 'os2', 'mac', 'macpath',
'ce', 'riscos', 'riscospath', 'win32api', 'riscosenviron']
elif 'nt' in sys.builtin_module_names:
removes = ['dos', 'dospath', 'os2', 'mac', 'macpath', 'ce', 'riscos',
'riscospath', 'riscosenviron',]
mod.imports = [m
for m in mod.imports
# if first part of module-name not in removes
if m[0].split('.', 1)[0] not in removes
]
return mod
| 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
# Submited by Seth Remington (ticket#15)
# Refined by Marco Bonifazi (via e-mail)
hiddenimports = ['gtkglext', 'gdkgl', 'gdkglext', 'gdk', 'gtk.gdk', 'gtk.gtkgl',
'gtk.gtkgl._gtkgl', 'gtkgl', 'pangocairo', 'pango', 'atk',
'gobject', 'gtk.glade', 'cairo', 'gio',
'gtk.keysyms']
| 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(os.path.join(modpath, 'commands', '*.py')):
fn = os.path.basename(fn)
fn = os.path.splitext(fn)[0]
hiddenimports.append('django.core.management.commands.' + fn)
return mod
| Python |
hiddenimports = ['sip', 'PyQt4.QtCore', 'PyQt4._qt']
| Python |
# Copyright (C) 2009, 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
def hook(mod):
# forbid imports in the port_v2 directory under Python 3
# The code wouldn't import and would crash the build process.
if sys.hexversion >= 0x03000000:
mod.__path__ = []
return mod
| Python |
#
# Copyright (C) 2012, Chien-An "Zero" Cho
#
# 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 ctypes.util
import os
from PyInstaller.depend.utils import _resolveCtypesImports
from PyInstaller.compat import is_cygwin
# Include glob for library lookup in run-time hook.
hiddenimports = ['glob']
# This method will try to resolve your libusb libraries in the
# following orders:
#
# libusb-1.0, libusb-0.1, openusb
#
# NOTE: Mind updating run-time hook when adding further libs.
libusb_candidates = (
# libusb10
'usb-1.0', 'usb', 'libusb-1.0',
# libusb01
'usb-0.1', 'libusb0',
# openusb
'openusb',
)
def hook(mod):
for candidate in libusb_candidates:
libname = ctypes.util.find_library(candidate)
if libname is not None:
break
if libname is not None:
# Use basename here because Python returns full library path
# on Mac OSX when using ctypes.util.find_library.
bins = [os.path.basename(libname)]
mod.binaries.extend(_resolveCtypesImports(bins))
elif is_cygwin:
bins = ['cygusb-1.0-0.dll', 'cygusb0.dll']
mod.binaries.extend(_resolveCtypesImports(bins)[0:1])
return mod
| Python |
hiddenimports = ['sip', 'PyQt4.QtCore', 'PyQt4.QtGui', 'PyQt4._qt']
| Python |
# Copyirght (C) 2005, Eugene Prigorodov
#
# 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
# Courtesy of Eugene Prigorodov <eprigorodov at naumen dot ru>
#kinterbasdb
hiddenimports = ['k_exceptions', 'services', 'typeconv_naked',
'typeconv_backcompat', 'typeconv_23plus',
'typeconv_datetime_stdlib', 'typeconv_datetime_mx',
'typeconv_datetime_naked', 'typeconv_fixed_fixedpoint',
'typeconv_fixed_stdlib', 'typeconv_text_unicode',
'typeconv_util_isinstance', '_kinterbasdb', '_kiservices']
| 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 PyInstaller.depend.modules
def hook(mod):
import sys
newname = 'pywintypes%d%d' % sys.version_info[:2]
if mod.typ == 'EXTENSION':
mod.__name__ = newname
else:
import win32api
h = win32api.LoadLibrary(newname + '.dll')
pth = win32api.GetModuleFileName(h)
#win32api.FreeLibrary(h)
mod = PyInstaller.depend.modules.ExtensionModule(newname, pth)
return mod
| 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.dom.html.HTMLDocument
hiddenimports = ['xml.dom.html.HTMLAnchorElement',
'xml.dom.html.HTMLAppletElement',
'xml.dom.html.HTMLAreaElement',
'xml.dom.html.HTMLBaseElement',
'xml.dom.html.HTMLBaseFontElement',
'xml.dom.html.HTMLBodyElement',
'xml.dom.html.HTMLBRElement',
'xml.dom.html.HTMLButtonElement',
'xml.dom.html.HTMLDirectoryElement',
'xml.dom.html.HTMLDivElement',
'xml.dom.html.HTMLDListElement',
'xml.dom.html.HTMLElement',
'xml.dom.html.HTMLFieldSetElement',
'xml.dom.html.HTMLFontElement',
'xml.dom.html.HTMLFormElement',
'xml.dom.html.HTMLFrameElement',
'xml.dom.html.HTMLFrameSetElement',
'xml.dom.html.HTMLHeadElement',
'xml.dom.html.HTMLHeadingElement',
'xml.dom.html.HTMLHRElement',
'xml.dom.html.HTMLHtmlElement',
'xml.dom.html.HTMLIFrameElement',
'xml.dom.html.HTMLImageElement',
'xml.dom.html.HTMLInputElement',
'xml.dom.html.HTMLIsIndexElement',
'xml.dom.html.HTMLLabelElement',
'xml.dom.html.HTMLLegendElement',
'xml.dom.html.HTMLLIElement',
'xml.dom.html.HTMLLinkElement',
'xml.dom.html.HTMLMapElement',
'xml.dom.html.HTMLMenuElement',
'xml.dom.html.HTMLMetaElement',
'xml.dom.html.HTMLModElement',
'xml.dom.html.HTMLObjectElement',
'xml.dom.html.HTMLOListElement',
'xml.dom.html.HTMLOptGroupElement',
'xml.dom.html.HTMLOptionElement',
'xml.dom.html.HTMLParagraphElement',
'xml.dom.html.HTMLParamElement',
'xml.dom.html.HTMLPreElement',
'xml.dom.html.HTMLQuoteElement',
'xml.dom.html.HTMLScriptElement',
'xml.dom.html.HTMLSelectElement',
'xml.dom.html.HTMLStyleElement',
'xml.dom.html.HTMLTableCaptionElement',
'xml.dom.html.HTMLTableCellElement',
'xml.dom.html.HTMLTableColElement',
'xml.dom.html.HTMLTableElement',
'xml.dom.html.HTMLTableRowElement',
'xml.dom.html.HTMLTableSectionElement',
'xml.dom.html.HTMLTextAreaElement',
'xml.dom.html.HTMLTitleElement',
'xml.dom.html.HTMLUListElement',
]
| Python |
from PyInstaller.hooks.hookutils import eval_statement
hiddenimports = ["PyQt4.QtCore", "PyQt4.QtGui", "PyQt4.QtSvg"]
if eval_statement("from PyQt4 import Qwt5; print hasattr(Qwt5, 'toNumpy')"):
hiddenimports.append("numpy")
if eval_statement("from PyQt4 import Qwt5; print hasattr(Qwt5, 'toNumeric')"):
hiddenimports.append("Numeric")
if eval_statement("from PyQt4 import Qwt5; print hasattr(Qwt5, 'toNumarray')"):
hiddenimports.append("numarray")
| 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(os.path.join(modpath, 'backends', '*.py')):
fn = os.path.basename(fn)
fn = os.path.splitext(fn)[0]
hiddenimports.append('django.core.cache.backends.' + fn)
return mod
| Python |
#
# Copyright (C) 2012, 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 distutils
import distutils.sysconfig
import marshal
import os
import sys
from PyInstaller import compat
from PyInstaller.compat import is_win
# distutils module requires Makefile and pyconfig.h files from Python
# installation. 'distutils.sysconfig' parses these files to get some
# information from them.
_CONFIG_H = distutils.sysconfig.get_config_h_filename()
_MAKEFILE = distutils.sysconfig.get_makefile_filename()
# In virtualenv sys.prefix is overridden.
if hasattr(sys, 'real_prefix'):
sys_prefix = sys.real_prefix
else:
sys_prefix = sys.prefix
# Relative path to config_h in the dist directory.
_frozen_config_h = compat.relpath(os.path.dirname(_CONFIG_H), sys_prefix)
# Data files in PyInstaller hook format.
datas = [
(_CONFIG_H, _frozen_config_h),
]
# On Windows Makefile does not exist.
if not is_win:
_frozen_makefile = compat.relpath(os.path.dirname(_MAKEFILE), sys_prefix)
datas.append((_MAKEFILE, _frozen_makefile))
def hook(mod):
"""
Contributed by jkp@kirkconsulting.co.uk
This hook checks for the distutils hacks present when using the
virtualenv package.
"""
# Non-empty means PyInstaller is running inside virtualenv.
# Virtualenv overrides real distutils modules.
if hasattr(distutils, 'distutils_path'):
mod_path = os.path.join(distutils.distutils_path, '__init__.pyc')
try:
parsed_code = marshal.loads(open(mod_path, 'rb').read()[8:])
except IOError:
parsed_code = compile(open(mod_path[:-1], 'rU').read(), mod_path, 'exec')
mod.__init__('distutils', mod_path, parsed_code)
return mod
| Python |
hiddenimports = ['default']
| 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 = [('HTML_4_STRICT_INLINE',0),
('HTML_4_TRANSITIONAL_INLINE',0),
('HTML_FORBIDDEN_END',0),
('HTML_OPT_END',0),
('HTML_BOOLEAN_ATTRS',0),
('HTML_CHARACTER_ENTITIES',0),
('HTML_NAME_ALLOWED',0),
('HTML_DTD',0),
('HTMLDOMImplementation',0),
('htmlImplementation',0),
('utf8_to_code',0),
('ConvertChar',0),
('UseHtmlCharEntities',0),
('TranslateHtmlCdata',0),
('SECURE_HTML_ELEMS',0),
]
| Python |
hiddenimports = ['sip',
'PyQt4._qt',
'PyQt4.QtAssistant',
'PyQt4.QtCore',
'PyQt4.QtGui',
'PyQt4.QtNetwork',
'PyQt4.Qt3Support',
'PyQt4.QtSql',
'PyQt4.QtSvg',
'PyQt4.QtTest',
'PyQt4.QtSql',
'PyQt4.QtXml',
'PyQt4.QtWebKit',
'PyQt4.QtOpenGL',
]
| Python |
hiddenimports = ['sip', 'PyQt4.QtCore', 'PyQt4.QtGui', 'PyQt4._qt']
from PyInstaller.hooks.hookutils import qt4_plugins_binaries
def hook(mod):
mod.binaries.extend(qt4_plugins_binaries('sqldrivers'))
return mod
| Python |
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 = ['warnings']
| Python |
from PyInstaller.hooks.hookutils import exec_statement
exec_statement("import wx.lib.activex") #this needed because comtypes wx.lib.activex generates some stuff
| Python |
# Hook for pygame._view, required for develop releases between
# 2011-02-08 and 2011-08-31, including prebuilt-pygame1.9.2a0
# Author: htgoebel
# Date: 2011-11-18
# Ticket: #406
hiddenimports = ['pygame._view']
| Python |
# Copyright (C) 2009, 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
def hook(mod):
# forbid imports in the port_v3 directory under Python 2
# The code wouldn't import and would crash the build process.
if sys.hexversion < 0x03000000:
mod.__path__ = []
return mod
| Python |
Subsets and Splits
SQL Console for ajibawa-2023/Python-Code-Large
Provides a useful breakdown of language distribution in the training data, showing which languages have the most samples and helping identify potential imbalances across different language groups.