code stringlengths 1 1.72M | language stringclasses 1 value |
|---|---|
"""
PyInstaller is a program that converts (packages) Python programs into
stand-alone executables, under Windows, Linux, and Mac OS X. Its main
advantages over similar tools are that PyInstaller works with any
version of Python since 2.2, it builds smaller executables thanks to
transparent compression, it is fully multi-platform, and use the OS
support to load the dynamic libraries, thus ensuring full
compatibility.
The main goal of PyInstaller is to be compatible with 3rd-party
packages out-of-the-box. This means that, with PyInstaller, all the
required tricks to make external packages work are already integrated
within PyInstaller itself so that there is no user intervention
required. You'll never be required to look for tricks in wikis and
apply custom modification to your files or your setup scripts. As an
example, libraries like PyQt, Django or matplotlib are fully
supported, without having to handle plugins or external data files
manually.
"""
raise SystemExit("\nsetup.py is not yet supposed to work. "
"Please Use PyInstaller without installation.\n")
from setuptools import setup, find_packages
import platform
import itertools
import glob
import os
scripts = [
'pyinstaller.py',
'pyinstaller-gui.py',
'utils/ArchiveViewer.py',
#'utils/BinDepend.py',
'utils/Build.py',
'utils/Configure.py',
#'utils/Crypt.py',
#'utils/GrabVersion.py',
'utils/Makespec.py',
]
if platform.system() == "Windows":
scripts.append('MakeComServer.py')
def find_data_files(*patterns):
data_files = {}
for fn in itertools.chain(*(glob.iglob(p) for p in patterns)):
if os.path.isfile(fn):
data_files.setdefault(os.path.dirname(fn), []).append(fn)
return data_files.items()
setup(
name = 'pyinstaller',
version = '1.6.0dev',
scripts = scripts,
packages = find_packages(),
data_files = find_data_files('doc/*',
'doc/images/*', 'doc/stylesheets/*.css',
'support/*.py', 'support/rthooks/*.py',
'support/loader/*', 'support/loader/*/*'),
author = "Gordon McMillan, William Caban, Giovanni Bajo and the PyInstaller team",
author_email = "pyinstaller@googlegroups.com",
maintainer = "Giovanni Bajo and the PyInstaller team",
maintainer_email = "pyinstaller@googlegroups.com",
description = "Converts (packages) Python programs into stand-alone executables, under Windows, Linux, and Mac OS X.",
long_description = __doc__,
license = ("GPL license with a special exception which allows to use "
"PyInstaller to build and distribute non-free programs "
"(including commercial ones)."),
keywords = "packaging, standalone executable, freeze",
url = "http://www.pyinstaller.org/",
download_url = "http://www.pyinstaller.org/wiki#Downloads",
zip_safe = False,
classifiers = [
'Development Status :: 6 - Mature',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Natural Language :: English',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.3',
'Programming Language :: Python :: 2.4',
'Programming Language :: Python :: 2.5',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: C',
'Topic :: Software Development :: Build Tools',
'Topic :: System :: Software Distribution',
]
)
| 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.
#
# In addition to the permissions in the GNU General Public License, the
# authors give you unlimited permission to link or embed the compiled
# version of this file into combinations with other programs, and to
# distribute those combinations without any restriction coming from the
# use of this file. (The General Public License restrictions do apply in
# other respects; for example, they cover modification of the file, and
# distribution when not linked into a combine executable.)
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
### Start bootstrap process
# Only python built-in modules can be used.
import archive
import iu
import sys
# Force Python to look first for modules bundled in the executable created
# PyInstaller.
iu._globalownertypes.insert(0, archive.PYZOwner)
# Override default import manager in Python
sys.importManager = iu.ImportManager()
sys.importManager.install()
### Bootstrap process is complete.
# We can use other python modules (e.g. os)
import os
# Let other python modules know that the code is running in frozen mode.
if not hasattr(sys, 'frozen'):
sys.frozen = True
# Now that the startup is complete, we can reset the _MEIPASS2 env
# so that if the program invokes another PyInstaller one-file program
# as subprocess, this subprocess will not fooled into thinking that it
# is already unpacked.
#
# But we need to preserve _MEIPASS2 value for cases where reseting it
# causes some issues (e.g. multiprocess module on Windows).
# set sys._MEIPASS
MEIPASS2 = '_MEIPASS2'
if MEIPASS2 in os.environ:
meipass2_value = os.environ[MEIPASS2]
# Ensure sys._MEIPASS is absolute path.
meipass2_value = os.path.abspath(meipass2_value)
sys._MEIPASS = meipass2_value
# Delete _MEIPASS2 from environment.
# On some platforms (e.g. AIX) 'os.unsetenv()' is not available and then
# deleting the var from os.environ does not delete it from the environment.
# In those cases we cannot delete the variable but only set it to the
# empty string.
os.environ[MEIPASS2] = ''
del os.environ[MEIPASS2]
# Ensure PYTHONHOME environment variable is unset. PYTHONHOME
# makes sure that no python modules from host OS are used. Startup is
# By deleting it we ensure that invoked standard Python interpreter
# is not affected by PYTHONHOME from bootloader.
if 'PYTHONHOME' in os.environ:
# On some platforms (e.g. AIX) 'os.unsetenv()' is not available and then
# deleting the var from os.environ does not delete it from the environment.
# In those cases we cannot delete the variable but only set it to the
# empty string.
os.environ['PYTHONHOME'] = ''
del os.environ['PYTHONHOME']
# FIXME On Windows setting environment variable PYTHONHOME does not work.
# This is a workaround for that. PYTHONHOME should be fixed for Windows
# in bootloader.
# http://www.pyinstaller.org/ticket/549
else:
sys.prefix = sys._MEIPASS
sys.exec_prefix = sys._MEIPASS
# Forces PyInstaller to include fake 'site' module. Fake 'site' module
# is dummy and does not do any search for additional Python modules.
import site
# Ensure PYTHONPATH contains absolute paths. Otherwise import of other python
# modules will fail when current working directory is changed by frozen
# application.
python_path = []
for pth in sys.path:
python_path.append(os.path.abspath(pth))
sys.path = python_path
# Implement workaround for prints in non-console mode. In non-console mode
# (with "pythonw"), print randomly fails with "[errno 9] Bad file descriptor"
# when the printed text is flushed (eg: buffer full); this is because the
# sys.stdout object is bound to an invalid file descriptor.
# Python 3000 has a fix for it (http://bugs.python.org/issue1415), but we
# feel that a workaround in PyInstaller is a good thing since most people
# found this problem for the first time with PyInstaller as they don't
# usually run their code with "pythonw" (and it's hard to debug anyway).
class NullWriter:
def write(*args):
pass
def flush(*args):
pass
if sys.stdout.fileno() < 0:
sys.stdout = NullWriter()
if sys.stderr.fileno() < 0:
sys.stderr = NullWriter()
| Python |
#
# Copyright (C) 2012, Martin Zibricky
# Copyright (C) 2005, Giovanni Bajo
# Based on previous work under copyright (c) 2002 McMillan Enterprises, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# In addition to the permissions in the GNU General Public License, the
# authors give you unlimited permission to link or embed the compiled
# version of this file into combinations with other programs, and to
# distribute those combinations without any restriction coming from the
# use of this file. (The General Public License restrictions do apply in
# other respects; for example, they cover modification of the file, and
# distribution when not linked into a combine executable.)
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
# The win32.client.gencache code must be allowed to create the cache in %temp%
# (user's temp). It is necessary to get the gencache code to use a suitable
# directory other than the default in lib\site-packages\win32com\client\gen_py.
# PyInstaller does not provide this directory structure and the frozen
# executable could be placed in a non-writable directory like 'C:\Program Files.
# That's the reason for %temp% directory.
#
# http://www.py2exe.org/index.cgi/UsingEnsureDispatch
import atexit
import os
import shutil
import tempfile
# Put gen_py cache in temp directory.
supportdir = tempfile.mkdtemp()
# gen_py has to be put into directory 'gen_py'.
genpydir = os.path.join(supportdir, 'gen_py')
# Create 'gen_py' directory. This directory does not need
# to contain '__init__.py' file.
try:
# win32com gencache cannot be put directly to 'supportdir' with any
# random name. It has to be put in a directory called 'gen_py'.
# This is the reason why to create this directory in supportdir'.
os.makedirs(genpydir)
# Remove temp directory at application exit and ignore any errors.
atexit.register(shutil.rmtree, supportdir, ignore_errors=True)
except OSError:
pass
# Override the default path to gen_py cache.
import win32com
win32com.__gen_path__ = genpydir
# Ensure genpydir is in 'gen_py' module paths.
import win32com.gen_py
win32com.gen_py.__path__.insert(0, genpydir)
| Python |
import os
import sys
os.environ["MATPLOTLIBDATA"] = os.path.join(sys._MEIPASS, "mpl-data")
| Python |
# Copyright (C) 2005, Giovanni Bajo
# Based on previous work under copyright (c) 2002 McMillan Enterprises, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# In addition to the permissions in the GNU General Public License, the
# authors give you unlimited permission to link or embed the compiled
# version of this file into combinations with other programs, and to
# distribute those combinations without any restriction coming from the
# use of this file. (The General Public License restrictions do apply in
# other respects; for example, they cover modification of the file, and
# distribution when not linked into a combine executable.)
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import os
import sys
import imp
import iu
class Win32ImportDirector(iu.ImportDirector):
def __init__(self):
self.path = sys.path[0] # since I run as a hook, sys.path probably hasn't been mucked with
if hasattr(sys, 'version_info'):
self.suffix = '%d%d' % (sys.version_info[0], sys.version_info[1])
else:
self.suffix = '%s%s' % (sys.version[0], sys.version[2])
def getmod(self, nm):
fnm = os.path.join(self.path, nm + self.suffix + '.dll')
try:
fp = open(fnm, 'rb')
except:
return None
else:
mod = imp.load_module(nm, fp, fnm, ('.dll', 'rb', imp.C_EXTENSION))
mod.__file__ = fnm
return mod
sys.importManager.metapath.insert(1, Win32ImportDirector())
| Python |
import os
import sys
basedir = sys._MEIPASS
tcldir = os.path.join(basedir, '_MEI', 'tcl')
tkdir = os.path.join(basedir, '_MEI', 'tk')
# Directories with .tcl files.
os.environ["TCL_LIBRARY"] = tcldir
os.environ["TK_LIBRARY"] = tkdir
| 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 sys
d = sys._MEIPASS
import django.core.management
import django.utils.autoreload
def _setup_environ(settings_mod, original_settings_path=None):
project_name = settings_mod.__name__.split(".")[0]
settings_name = "settings"
if original_settings_path:
os.environ['DJANGO_SETTINGS_MODULE'] = original_settings_path
else:
os.environ['DJANGO_SETTINGS_MODULE'] = '%s.%s' % (project_name, settings_name)
project_module = __import__(project_name, {}, {}, [''])
return d
def _find_commands(_):
return """cleanup compilemessages createcachetable dbshell shell runfcgi runserver startproject""".split()
old_restart_with_reloader = django.utils.autoreload.restart_with_reloader
def _restart_with_reloader(*args):
import sys
a0 = sys.argv.pop(0)
try:
return old_restart_with_reloader(*args)
finally:
sys.argv.insert(0, a0)
django.core.management.setup_environ = _setup_environ
django.core.management.find_commands = _find_commands
django.utils.autoreload.restart_with_reloader = _restart_with_reloader
| Python |
import sys
import iu
# Search all import directors for a PYZOwner one
for im in sys.importManager.metapath:
if isinstance(im, iu.PathImportDirector):
for arch in im.shadowpath.values():
if isinstance(arch, archive.PYZOwner):
# import all modules `*ImagePlugin`
for name in arch.pyz.contents():
if name.endswith('ImagePlugin') and not '.' in name:
__import__(name)
| Python |
# 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.
#
# In addition to the permissions in the GNU General Public License, the
# authors give you unlimited permission to link or embed the compiled
# version of this file into combinations with other programs, and to
# distribute those combinations without any restriction coming from the
# use of this file. (The General Public License restrictions do apply in
# other respects; for example, they cover modification of the file, and
# distribution when not linked into a combine executable.)
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
# PyOpenGL (specifically, OpenGL.__init__) reads a "version" text file
# containing the version number to export it as OpenGL.__version__. When
# packaging with PyInstaller, the 'version' file does not exist, and importing
# PyOpenGL results in an IOError.
# The (convoluted) solution is to override Python's builtin "open" with our
# own function which detects when "version" is opened and returns some fake
# content stream (through cStringIO).
__realopen__ = open
def myopen(fn, *args):
if isinstance(fn, basestring):
if fn.endswith("version") and ".pyz" in fn:
# Restore original open, since we're almost done
__builtins__.__dict__["open"] = __realopen__
# Report a fake revision number. Anything would do since it's not
# used by the library, but it needs to be made of four numbers
# separated by dots.
import cStringIO
return cStringIO.StringIO("0.0.0.0")
return __realopen__(fn, *args)
__builtins__.__dict__["open"] = myopen
| Python |
# Qt4 plugins are bundled as data files (see hooks/hook-PyQt4*),
# within a "qt4_plugins" directory.
# We add a runtime hook to tell Qt4 where to find them.
import os
import sys
d = "qt4_plugins"
d = os.path.join(sys._MEIPASS, d)
# We remove QT_PLUGIN_PATH variable, beasuse we want Qt4 to load
# plugins only from one path.
if 'QT_PLUGIN_PATH' in os.environ:
del os.environ['QT_PLUGIN_PATH']
# We cannot use QT_PLUGIN_PATH here, because it would not work when
# PyQt4 is compiled with a different CRT from Python (eg: it happens
# with Riverbank's GPL package).
from PyQt4.QtCore import QCoreApplication
# We set "qt4_plugins" as only one path for Qt4 plugins
QCoreApplication.setLibraryPaths([os.path.abspath(d)])
| 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
import glob
import os
import sys
import usb.backend.libusb10 as libusb10
import usb.backend.libusb01 as libusb01
import usb.backend.openusb as openusb
def get_load_func(type, candidates):
def _load_library():
exec_path = sys._MEIPASS
l = None
for candidate in candidates:
# Do linker's path lookup work to force load bundled copy.
if os.name == 'posix' and sys.platform == 'darwin':
libs = glob.glob("%s/%s*.dylib*" % (exec_path, candidate))
elif sys.platform == 'win32' or sys.platform == 'cygwin':
libs = glob.glob("%s\\%s*.dll" % (exec_path, candidate))
else:
libs = glob.glob("%s/%s*.so*" % (exec_path, candidate))
for libname in libs:
try:
# NOTE: libusb01 is using CDLL under win32.
# (see usb.backends.libusb01)
if sys.platform == 'win32' and type != 'libusb01':
l = ctypes.WinDLL(libname)
else:
l = ctypes.CDLL(libname)
if l is not None:
break
except:
l = None
if l is not None:
break
else:
raise OSError('USB library could not be found')
if type == 'libusb10':
if not hasattr(l, 'libusb_init'):
raise OSError('USB library could not be found')
return l
return _load_library
# NOTE: Need to keep in sync with future PyUSB updates.
if sys.platform == 'cygwin':
libusb10._load_library = get_load_func('libusb10', ('cygusb-1.0', ))
libusb01._load_library = get_load_func('libusb01', ('cygusb0', ))
openusb._load_library = get_load_func('openusb', ('openusb', ))
else:
libusb10._load_library = get_load_func('libusb10', ('usb-1.0', 'libusb-1.0', 'usb'))
libusb01._load_library = get_load_func('libusb01', ('usb-0.1', 'usb', 'libusb0'))
openusb._load_library = get_load_func('openusb', ('openusb', ))
| Python |
import os
import sys
d = "localedata"
d = os.path.join(sys._MEIPASS, d)
import babel.localedata
babel.localedata._dirname = d
| Python |
import sys
import iu
# Search all import directors for a PYZOwner one
for im in sys.importManager.metapath:
if isinstance(im, iu.PathImportDirector):
for arch in im.shadowpath.values():
if isinstance(arch, archive.PYZOwner):
# import all modules `*ImagePlugin`
for name in arch.pyz.contents():
if name.startswith('PIL.') and name.endswith('ImagePlugin'):
__import__(name)
| Python |
# At least on Windows, Python seems to hook up the codecs on this
# import, so it's not enough to just package up all the encodings.
import encodings
| Python |
#!/usr/bin/env python
#
# Make .eggs and zipfiles available at runtime
#
# Copyright (C) 2010 Giovanni Bajo <rasky@develer.com>
#
# This file is part of PyInstaller <http://www.pyinstaller.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# In addition to the permissions in the GNU General Public License, the
# authors give you unlimited permission to link or embed the compiled
# version of this file into combinations with other programs, and to
# distribute those combinations without any restriction coming from the
# use of this file. (The General Public License restrictions do apply in
# other respects; for example, they cover modification of the file, and
# distribution when not linked into a combine executable.)
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import os
import sys
d = "eggs"
d = os.path.join(sys._MEIPASS, d)
for fn in os.listdir(d):
sys.path.append(os.path.join(d, fn))
| Python |
# -*- mode: python -*-
__testname__ = 'test_encoders'
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=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_5'
a = Analysis([__testname__ + '.py'],
pathex=[])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
[('W ignore', '', 'OPTION')],
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,
name=os.path.join('dist', __testname__),)
| Python |
# -*- mode: python -*-
__testname__ = 'test_chdir_meipass'
a = Analysis([__testname__ + '.py'], pathex=['.'])
pyz = PYZ(a.pure)
exe = EXE( pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name=os.path.join('dist', __testname__, __testname__ + '.exe'),
debug=False,
strip=False,
upx=True,
console=1 )
| Python |
# -*- mode: python -*-
__testname__ = 'test_celementtree'
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=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_12'
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=0,
console=1)
coll = COLLECT( exe,
a.binaries,
name=os.path.join('dist', __testname__),)
| Python |
# -*- mode: python -*-
__testname__ = 'test_13'
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=1 )
coll = COLLECT( exe,
a.binaries,
strip=False,
upx=False,
name=os.path.join('dist', __testname__),)
| Python |
attrs = [('notamodule','')]
def hook(mod):
import os, sys, marshal
other = os.path.join(mod.__path__[0], '../pkg2/__init__.pyc')
if os.path.exists(other):
co = marshal.loads(open(other,'rb').read()[8:])
else:
co = compile(open(other[:-1],'rU').read()+'\n', other, 'exec')
mod.__init__(mod.__name__, other, co)
mod.__path__.append(os.path.join(mod.__path__[0], 'extra'))
return mod
| Python |
# -*- mode: python -*-
__testname__ = 'test_nestedlaunch1'
a = Analysis([__testname__ + '.py'],
pathex=[''])
pyz = PYZ(a.pure)
exe = EXE( pyz,
a.scripts,
a.binaries,
a.zipfiles,
name=os.path.join('dist', __testname__, __testname__ + '.exe'),
debug=False,
strip=False,
upx=False,
console=1 )
| Python |
# Copyright (C) 2005, Giovanni Bajo
# Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#nasty
import time
time.sleep(5)
x = 5
| Python |
# -*- mode: python -*-
__testname__ = 'test_helloworld'
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_python_makefile_onefile'
a = Analysis([__testname__ + '.py'],
pathex=['.'],
hiddenimports=[],
hookspath=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name=os.path.join('dist', __testname__),
debug=True,
strip=None,
upx=True,
console=True )
| Python |
""" pkg1.a.py is never imported """
print " %s" % __doc__
print " %s %s" % (__name__, __file__)
| Python |
""" pkg1 replaces itself with pkg2"""
__all__ = ["a", "b"]
import pkg2
import sys
sys.modules[__name__] = pkg2
from pkg2 import *
| Python |
# -*- mode: python -*-
__testname__ = 'test_time'
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_threading2'
a = Analysis([__testname__+'.py'],
pathex=[],
hiddenimports=[],
hookspath=None)
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=None,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=None,
upx=True,
name=os.path.join('dist', __testname__))
| Python |
# -*- mode: python -*-
a = Analysis(['test_site.py'],
pathex=['/home/martin/Work/pyinstaller/gitrepo/buildtests/import'],
hiddenimports=['encodings'],
hookspath=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build/pyi.linux2/test_site', 'test_site'),
debug=True,
strip=None,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=None,
upx=True,
name=os.path.join('dist', 'test_site'))
| Python |
# -*- mode: python -*-
import sys
import os
is_win = sys.platform.startswith('win')
is_darwin = sys.platform == 'darwin' # Mac OS X
def mac_gcc_architecture():
"""
Returns the -arch parameter for gcc on Mac OS X.
"""
# 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:
# 64bit
return 'x86_64'
else:
# 32bit
return 'i386'
CTYPES_DIR = 'ctypes'
TEST_LIB = os.path.join(CTYPES_DIR, 'testctypes')
if is_win:
TEST_LIB += '.dll'
elif is_darwin:
TEST_LIB += '.dylib'
else:
TEST_LIB += '.so'
# If the required dylib does not reside in the current directory, the Analysis
# class machinery, based on ctypes.util.find_library, will not find it. This
# was done on purpose for this test, to show how to give Analysis class
# a clue.
if is_win:
os.environ['PATH'] = os.path.abspath(CTYPES_DIR) + ';' + os.environ['PATH']
else:
os.environ['LD_LIBRARY_PATH'] = CTYPES_DIR
os.environ['DYLD_LIBRARY_PATH'] = CTYPES_DIR
os.environ['LIBPATH'] = CTYPES_DIR
os.chdir(CTYPES_DIR)
if is_win:
ret = os.system('cl /LD testctypes-win.c')
if ret != 0:
os.system('gcc -shared testctypes-win.c -o testctypes.dll')
elif is_darwin:
# On Mac OS X we need to detect architecture - 32 bit or 64 bit.
cmd = ('gcc -arch ' + mac_gcc_architecture() + ' -Wall -dynamiclib '
'testctypes.c -o testctypes.dylib -headerpad_max_install_names')
os.system(cmd)
id_dylib = os.path.abspath('testctypes.dylib')
os.system('install_name_tool -id %s testctypes.dylib' % (id_dylib,))
else:
os.system('gcc -fPIC -shared testctypes.c -o testctypes.so')
os.chdir("..")
__testname__ = 'test_ctypes'
a = Analysis([__testname__ + '.py'],
pathex=[])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
a.binaries,
name=os.path.join('dist', __testname__, __testname__ + '.exe'),
debug=False,
strip=False,
upx=False,
console=1)
| Python |
# -*- mode: python -*-
__testname__ = 'test_threading'
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=0,
console=1)
coll = COLLECT( exe,
a.binaries,
name=os.path.join('dist', __testname__),)
| Python |
x = 2
| Python |
# -*- mode: python -*-
__testname__ = 'test_f_option'
a = Analysis([__testname__ + '.py'],
pathex=[])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
[('f','','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 |
# -*- mode: python -*-
__testname__ = 'test_8'
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=0,
strip=0,
upx=0,
console=1 )
coll = COLLECT( exe,
a.binaries,
strip=0,
upx=0,
name=os.path.join('dist', __testname__),)
| Python |
""" pkg2.a defines overridden and a_func """
def a_func():
return "a_func from pkg2.a"
print "pkg2.a imported"
| Python |
""" pkg2 does various namespace tricks, __path__ append """
def notamodule():
return "notamodule from pkg2.__init__"
import os
__path__.append(os.path.join(
os.path.dirname(__file__), 'extra'))
__all__ = ["a", "b", "notamodule"]
| Python |
""" b.py lives in extra, but shows as pkg2.b (and pkg1.b)"""
def b_func():
return "b_func from pkg2.b (pkg2/extra/b.py)"
| Python |
# -*- mode: python -*-
__testname__ = 'test_filename'
a = Analysis([__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=1 )
coll = COLLECT( exe,
a.binaries,
strip=False,
upx=False,
name=os.path.join('dist', __testname__),)
| Python |
# -*- mode: python -*-
__testname__ = 'test_getfilesystemencoding'
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=1 )
coll = COLLECT(exe,
a.binaries,
strip=False,
upx=False,
name=os.path.join('dist', __testname__),)
| Python |
# -*- mode: python -*-
__testname__ = 'test_6'
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=0,
console=1)
coll = COLLECT( exe,
a.binaries,
name=os.path.join('dist', __testname__),)
| Python |
# -*- mode: python -*-
__testname__ = 'test_pkg_structures'
a = Analysis([__testname__ + '.py'],
hookspath=['hooks1'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.platform, __testname__ + '.exe'),
icon=__testname__+'.ico',
version=__testname__+'-version.txt',
debug=0,
console=1)
coll = COLLECT( exe,
a.binaries,
name=os.path.join('dist', __testname__),)
| Python |
# -*- mode: python -*-
__testname__ = 'test_nestedlaunch0'
a = Analysis([__testname__ + '.py'],
pathex=[''])
pyz = PYZ(a.pure)
exe = EXE( pyz,
a.scripts,
a.binaries,
a.zipfiles,
name=os.path.join('dist', __testname__, __testname__ + '.exe'),
debug=False,
strip=False,
upx=False,
console=1 )
| Python |
# -*- mode: python -*-
__testname__ = 'test_module_attributes'
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=1 )
coll = COLLECT( exe,
a.binaries,
strip=False,
upx=False,
name=os.path.join('dist', __testname__),)
| Python |
# -*- mode: python -*-
__testname__ = 'test_python_makefile'
a = Analysis([__testname__ + '.py'],
pathex=['.'],
hiddenimports=[],
hookspath=None)
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=None,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=None,
upx=True,
name=os.path.join('dist', __testname__),)
| Python |
# -*- mode: python -*-
__testname__ = 'test_get_meipass2_value'
a = Analysis([__testname__ + '.py'],
pathex=[])
a = Analysis([__testname__ + '.py'],
pathex=[],
hookspath=None)
pyz = PYZ(a.pure)
exe = EXE( pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name=os.path.join('dist', __testname__ + '.exe'),
debug=True,
strip=None,
upx=True,
console=True )
| Python |
#!/usr/bin/env python
import sys
from ctypes import *
# Current working directory is set to dist directory for tests.
def dummy(arg):
if sys.platform == "win32":
tct = CDLL("..\\..\\ctypes\\testctypes-win.dll")
elif sys.platform.startswith("darwin"):
tct = CDLL("../../ctypes/testctypes.dylib")
else:
tct = CDLL("../../ctypes/testctypes.so")
return tct.dummy(arg)
| Python |
#!/usr/bin/env python
#
# Copyright (C) 2011-2012 Martin Zibricky
# Copyright (C) 2011-2012 Hartmut Goebel
# Copyright (C) 2005-2011 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
# This program will execute any file with name test*<digit>.py. If your test
# need an aditional dependency name it test*<digit><letter>.py to be ignored
# by this program but be recognizable by any one as a dependency of that
# particular test.
import glob
import optparse
import os
import re
import shutil
import sys
try:
import PyInstaller
except ImportError:
# if importing PyInstaller fails, try to load from parent
# directory to support running without installation
import imp
if not hasattr(os, "getuid") or os.getuid() != 0:
imp.load_module('PyInstaller', *imp.find_module('PyInstaller',
[os.path.dirname(os.path.dirname(os.path.abspath(__file__)))]))
from PyInstaller import HOMEPATH
from PyInstaller import is_py23, is_py24, is_py25, is_py26, is_win, is_darwin
from PyInstaller import compat
from PyInstaller.lib import unittest2 as unittest
from PyInstaller.lib import junitxml
from PyInstaller.utils import misc
VERBOSE = False
REPORT = False
# Directory with this script (runtests.py).
BASEDIR = os.path.dirname(os.path.abspath(__file__))
class MiscDependencies(object):
"""
Place holder for special requirements of some tests.
e.g. basic/test_ctypes needs C compiler.
Every method returns None when successful or a string containing
error message to be displayed on console.
"""
def c_compiler(self):
"""
Check availability of C compiler.
"""
compiler = None
msg = 'Cannot find GCC, MinGW or Visual Studio in PATH.'
if is_win:
# Try MSVC.
compiler = misc.find_executable('cl')
if compiler is None:
# Try GCC.
compiler = misc.find_executable('gcc')
if compiler is None:
return msg
return None # C compiler was found.
class SkipChecker(object):
"""
Check conditions if a test case should be skipped.
"""
def __init__(self):
depend = MiscDependencies()
# Required Python or OS version for some tests.
self.MIN_VERSION_OR_OS = {
'basic/test_time': is_py23,
'basic/test_celementtree': is_py25,
'basic/test_email': is_py25,
# On Mac DYLD_LIBRARY_PATH is not used.
'basic/test_absolute_ld_library_path': not is_win and not is_darwin,
'import/test_c_extension': is_py25,
'import/test_onefile_c_extension': is_py25,
'import/test_relative_import': is_py25,
'import/test_relative_import2': is_py26,
'import/test_relative_import3': is_py25,
'libraries/test_enchant': is_win,
}
# Required Python modules for some tests.
self.MODULES = {
'basic/test_ctypes': ['ctypes'],
'basic/test_module_attributes': ['xml.etree.cElementTree'],
'basic/test_nestedlaunch1': ['ctypes'],
'basic/test_onefile_multiprocess': ['multiprocessing'],
'libraries/test_enchant': ['enchant'],
'libraries/test_Image': ['PIL'],
'libraries/test_Image2': ['PIL'],
'libraries/test_numpy': ['numpy'],
'libraries/test_onefile_tkinter': ['Tkinter'],
'libraries/test_PIL': ['PIL'],
'libraries/test_PIL2': ['PIL'],
'libraries/test_pycrypto': ['Crypto'],
'libraries/test_pyodbc': ['pyodbc'],
'libraries/test_pyttsx': ['pyttsx'],
'libraries/test_sqlalchemy': ['sqlalchemy', 'MySQLdb', 'psycopg2'],
'libraries/test_usb': ['ctypes', 'usb'],
'libraries/test_wx': ['wx'],
'libraries/test_wx_pubsub': ['wx'],
'libraries/test_wx_pubsub_arg1': ['wx'],
'libraries/test_wx_pubsub_kwargs': ['wx'],
'import/test_c_extension': ['simplejson'],
'import/test_ctypes_cdll_c': ['ctypes'],
'import/test_ctypes_cdll_c2': ['ctypes'],
'import/test_eggs2': ['pkg_resources'],
'import/test_onefile_c_extension': ['simplejson'],
'import/test_onefile_zipimport': ['pkg_resources'],
'import/test_onefile_zipimport2': ['pkg_resources', 'setuptools'],
'interactive/test_pygame': ['pygame'],
}
# Other dependecies of some tests.
self.DEPENDENCIES = {
'basic/test_ctypes': [depend.c_compiler()],
# Support for unzipped eggs is not yet implemented.
# http://www.pyinstaller.org/ticket/541
'import/test_eggs1': ['Unzipped eggs not yet implemented.'],
}
def _check_python_and_os(self, test_name):
"""
Return True if test name is not in the list or Python or OS
version is not met.
"""
if (test_name in self.MIN_VERSION_OR_OS and
not self.MIN_VERSION_OR_OS[test_name]):
return False
return True
def _check_modules(self, test_name):
"""
Return name of missing required module, if any. None means
no module is missing.
"""
if test_name in self.MODULES:
for mod_name in self.MODULES[test_name]:
# STDOUT and STDERR are discarded (devnull) to hide
# import exceptions.
trash = open(compat.devnull)
retcode = compat.exec_python_rc('-c', "import %s" % mod_name,
stdout=trash, stderr=trash)
trash.close()
if retcode != 0:
return mod_name
return None
def _check_dependencies(self, test_name):
"""
Return error message when a requirement is not met, None otherwise.
"""
if test_name in self.DEPENDENCIES:
for dep in self.DEPENDENCIES[test_name]:
if dep is not None:
return dep
return None
def check(self, test_name):
"""
Check test requirements if they are any specified.
Return tupple (True/False, 'Reason for skipping.').
True if all requirements are met. Then test case may
be executed.
"""
if not self._check_python_and_os(test_name):
return (False, 'Required another Python version or OS.')
required_module = self._check_modules(test_name)
if required_module is not None:
return (False, "Module %s is missing." % required_module)
dependency = self._check_dependencies(test_name)
if dependency is not None:
return (False, dependency)
return (True, 'Requirements met.')
NO_SPEC_FILE = [
'basic/test_absolute_ld_library_path',
'basic/test_absolute_python_path',
'basic/test_email',
'basic/test_email_oldstyle',
'basic/test_onefile_multiprocess',
'basic/test_python_home',
'import/test_c_extension',
'import/test_onefile_c_extension',
'import/test_onefile_zipimport',
'import/test_onefile_zipimport2',
'libraries/test_enchant',
'libraries/test_onefile_tkinter',
'libraries/test_sqlalchemy',
'libraries/test_pyodbc',
'libraries/test_pyttsx',
'libraries/test_usb',
'libraries/test_wx_pubsub',
'libraries/test_wx_pubsub_kwargs',
'libraries/test_wx_pubsub_arg1'
]
class BuildTestRunner(object):
def __init__(self, test_name, verbose=False, report=False):
# Use path separator '/' even on windows for test_name name.
self.test_name = test_name.replace('\\', '/')
self.verbose = verbose
self.test_dir, self.test_file = os.path.split(self.test_name)
# For junit xml report some behavior is changed.
# Especially redirecting sys.stdout.
self.report = report
def _msg(self, text):
"""
Important text. Print it to console only in verbose mode.
"""
if self.verbose:
# This allows to redirect stdout to junit xml report.
sys.stdout.write('\n' + 10 * '#' + ' ' + text + ' ' + 10 * '#' + '\n\n')
sys.stdout.flush()
def _plain_msg(self, text):
"""
Print text to console only in verbose mode.
"""
if self.verbose:
sys.stdout.write(text + '\n')
sys.stdout.flush()
def _find_exepath(self, test, parent_dir='dist'):
of_prog = os.path.join(parent_dir, test) # one-file deploy filename
od_prog = os.path.join(parent_dir, test, test) # one-dir deploy filename
prog = None
if os.path.isfile(of_prog):
prog = of_prog
elif os.path.isfile(of_prog + ".exe"):
prog = of_prog + ".exe"
elif os.path.isdir(of_prog):
if os.path.isfile(od_prog):
prog = od_prog
elif os.path.isfile(od_prog + ".exe"):
prog = od_prog + ".exe"
return prog
def _run_created_exe(self, test, testdir=None):
"""
Run executable created by PyInstaller.
"""
self._msg('EXECUTING TEST ' + self.test_name)
# Run the test in a clean environment to make sure they're
# really self-contained
path = compat.getenv('PATH')
compat.unsetenv('PATH')
prog = self._find_exepath(test, 'dist')
if prog is None:
self._plain_msg('ERROR: no file generated by PyInstaller found!')
compat.setenv("PATH", path)
return 1
else:
self._plain_msg("RUNNING: " + prog)
old_wd = os.getcwd()
os.chdir(os.path.dirname(prog))
prog = os.path.join(os.curdir, os.path.basename(prog))
retcode, out, err = compat.exec_command_all(prog)
os.chdir(old_wd)
self._msg('STDOUT %s' % self.test_name)
self._plain_msg(out)
self._msg('STDERR %s' % self.test_name)
self._plain_msg(err)
compat.setenv("PATH", path)
return retcode
def test_exists(self):
"""
Return True if test file exists.
"""
return os.path.exists(os.path.join(BASEDIR, self.test_name + '.py'))
def test_building(self):
"""
Run building of test script.
Return True if build succeded False otherwise.
"""
OPTS = ['--debug']
if self.verbose:
OPTS.extend(['--debug', '--log-level=INFO'])
else:
OPTS.append('--log-level=ERROR')
# Build executable in onefile mode.
if self.test_file.startswith('test_onefile'):
OPTS.append('--onefile')
else:
OPTS.append('--onedir')
self._msg("BUILDING TEST " + self.test_name)
# Use pyinstaller.py for building test_name.
testfile_spec = self.test_file + '.spec'
if not os.path.exists(self.test_file + '.spec'):
# .spec file does not exist and it has to be generated
# for main script.
testfile_spec = self.test_file + '.py'
pyinst_script = os.path.join(HOMEPATH, 'pyinstaller.py')
# In report mode is stdout and sys.stderr redirected.
if self.report:
# Write output from subprocess to stdout/err.
retcode, out, err = compat.exec_python_all(pyinst_script,
testfile_spec, *OPTS)
sys.stdout.write(out)
sys.stdout.write(err)
else:
retcode = compat.exec_python_rc(pyinst_script,
testfile_spec, *OPTS)
return retcode == 0
def test_exe(self):
"""
Test running of all created executables.
"""
files = glob.glob(os.path.join('dist', self.test_file + '*'))
retcode = 0
for exe in files:
exe = os.path.splitext(exe)[0]
retcode_tmp = self._run_created_exe(exe[5:], self.test_dir)
retcode = retcode or retcode_tmp
return retcode == 0
def test_logs(self):
"""
Compare log files (now used only by multipackage test_name).
Return True if .toc files match or when .toc patters
are not defined.
"""
logsfn = glob.glob(self.test_file + '.toc')
# Other main scritps do not start with 'test_'.
logsfn += glob.glob(self.test_file.split('_', 1)[1] + '_?.toc')
for logfn in logsfn:
self._msg("EXECUTING MATCHING " + logfn)
tmpname = os.path.splitext(logfn)[0]
prog = self._find_exepath(tmpname)
if prog is None:
prog = self._find_exepath(tmpname,
os.path.join('dist', self.test_file))
fname_list = compat.exec_python(
os.path.join(HOMEPATH, 'utils', 'ArchiveViewer.py'),
'-b', '-r', prog)
# Fix line-endings so eval() does not fail.
fname_list = fname_list.replace('\r\n', '\n').replace('\n\r', '\n')
fname_list = eval(fname_list)
pattern_list = eval(open(logfn, 'rU').read())
# Alphabetical order of patterns.
pattern_list.sort()
count = 0
for pattern in pattern_list:
found = False
for fname in fname_list:
if re.match(pattern, fname):
count += 1
found = True
self._plain_msg('MATCH: %s --> %s' % (pattern, fname))
break
if not found:
self._plain_msg('MISSING: %s' % pattern)
# Not all modules matched.
# Stop comparing other .toc files and fail the test.
if count < len(pattern_list):
return False
return True
class GenericTestCase(unittest.TestCase):
def __init__(self, test_dir, func_name):
"""
test_dir Directory containing testing python scripts.
func_name Name of test function to create.
"""
self.test_name = test_dir + '/' + func_name
# Create new test fuction. This has to be done before super().
setattr(self, func_name, self._generic_test_function)
super(GenericTestCase, self).__init__(func_name)
# For tests current working directory has to be changed temporaly.
self.curr_workdir = os.getcwdu()
def setUp(self):
testdir = os.path.dirname(self.test_name)
os.chdir(os.path.join(BASEDIR, testdir)) # go to testdir
# For some 'basic' tests we need create file with path to python
# executable and if it is running in debug mode.
build_python = open(os.path.join(BASEDIR, 'basic', 'python_exe.build'),
'w')
build_python.write(sys.executable + "\n")
build_python.write('debug=%s' % __debug__ + '\n')
# On Windows we need to preserve systme PATH for subprocesses in tests.
build_python.write(os.environ.get('PATH') + '\n')
build_python.close()
def tearDown(self):
os.chdir(self.curr_workdir) # go back from testdir
def _generic_test_function(self):
# Skip test case if test requirement are not met.
s = SkipChecker()
req_met, msg = s.check(self.test_name)
if not req_met:
raise unittest.SkipTest(msg)
# Create a build and test it.
b = BuildTestRunner(self.test_name, verbose=VERBOSE, report=REPORT)
self.assertTrue(b.test_exists(),
msg='Test %s not found.' % self.test_name)
self.assertTrue(b.test_building(),
msg='Build of %s failed.' % self.test_name)
self.assertTrue(b.test_exe(),
msg='Running exe of %s failed.' % self.test_name)
self.assertTrue(b.test_logs(),
msg='Matching .toc of %s failed.' % self.test_name)
class BasicTestCase(GenericTestCase):
test_dir = 'basic'
def __init__(self, func_name):
super(BasicTestCase, self).__init__(self.test_dir, func_name)
class ImportTestCase(GenericTestCase):
test_dir = 'import'
def __init__(self, func_name):
super(ImportTestCase, self).__init__(self.test_dir, func_name)
class LibrariesTestCase(GenericTestCase):
test_dir = 'libraries'
def __init__(self, func_name):
super(LibrariesTestCase, self).__init__(self.test_dir, func_name)
class MultipackageTestCase(GenericTestCase):
test_dir = 'multipackage'
def __init__(self, func_name):
super(MultipackageTestCase, self).__init__(self.test_dir, func_name)
class InteractiveTestCase(GenericTestCase):
"""
Interactive tests require user interaction mostly GUI.
Interactive tests have to be run directly by user.
They can't be run by any continuous integration system.
"""
test_dir = 'interactive'
def __init__(self, func_name):
super(InteractiveTestCase, self).__init__(self.test_dir, func_name)
class TestCaseGenerator(object):
"""
Generate test cases.
"""
def _detect_tests(self, directory):
files = glob.glob(os.path.join(directory, 'test_*.py'))
# Test name is a file name without extension.
tests = [os.path.splitext(os.path.basename(x))[0] for x in files]
tests.sort()
return tests
def create_suite(self, test_types):
"""
Create test suite and add test cases to it.
test_types Test classes to create test cases from.
Return test suite with tests.
"""
suite = unittest.TestSuite()
for _type in test_types:
tests = self._detect_tests(_type.test_dir)
# Create test cases for a specific type.
for test_name in tests:
suite.addTest(_type(test_name))
return suite
def clean():
"""
Remove temporary files created while running tests.
"""
# Files/globs to clean up.
patterns = """python_exe.build
logdict*.log
disttest*
buildtest*
warn*.txt
*.py[co]
*/*.py[co]
*/*/*.py[co]
build/
dist/
*/*.dll
*/*.lib
*/*.obj
*/*.exp
*/*.so
*/*.dylib
""".split()
# Remove temporary files in all subdirectories.
for directory in os.listdir(BASEDIR):
if not os.path.isdir(directory):
continue
for pattern in patterns:
file_list = glob.glob(os.path.join(directory, pattern))
for pth in file_list:
try:
if os.path.isdir(pth):
shutil.rmtree(pth)
else:
os.remove(pth)
except OSError, e:
print e
# Delete *.spec files for tests without spec file.
for pth in NO_SPEC_FILE:
pth = os.path.join(BASEDIR, pth + '.spec')
if os.path.exists(pth):
os.remove(pth)
def run_tests(test_suite, xml_file):
"""
Run test suite and save output to junit xml file if requested.
"""
if xml_file:
print 'Writting test results to: %s' % xml_file
fp = open('report.xml', 'w')
result = junitxml.JUnitXmlResult(fp)
# Text from stdout/stderr should be added to failed test cases.
result.buffer = True
result.startTestRun()
test_suite.run(result)
result.stopTestRun()
fp.close()
else:
unittest.TextTestRunner(verbosity=2).run(test_suite)
def main():
try:
parser = optparse.OptionParser(usage='%prog [options] [TEST-NAME ...]',
epilog='TEST-NAME can be the name of the .py-file, '
'the .spec-file or only the basename.')
except TypeError:
parser = optparse.OptionParser(usage='%prog [options] [TEST-NAME ...]')
parser.add_option('-c', '--clean', action='store_true',
help='Clean up generated files')
parser.add_option('-i', '--interactive-tests', action='store_true',
help='Run interactive tests (default: run normal tests)')
parser.add_option('-v', '--verbose',
action='store_true',
default=False,
help='Verbose mode (default: %default)')
parser.add_option('--junitxml', action='store', default=None,
metavar='FILE', help='Create junit-xml style test report file')
opts, args = parser.parse_args()
global VERBOSE, REPORT
VERBOSE = opts.verbose
REPORT = opts.junitxml is not None
# Do only cleanup.
if opts.clean:
clean()
raise SystemExit() # Exit code is 0 in this case.
# Run only specified tests.
if args:
if opts.interactive_tests:
parser.error('Must not specify -i/--interactive-tests when passing test names.')
suite = unittest.TestSuite()
for arg in args:
test_list = glob.glob(arg)
if not test_list:
test_list = [arg]
else:
test_list = [x for x in test_list if os.path.splitext(x)[1] == ".py"]
for t in test_list:
test_dir = os.path.dirname(t)
test_script = os.path.basename(os.path.splitext(t)[0])
suite.addTest(GenericTestCase(test_dir, test_script))
print 'Running test: %s' % (test_dir + '/' + test_script)
# Run all tests or all interactive tests.
else:
if opts.interactive_tests:
print 'Running interactive tests...'
test_classes = [InteractiveTestCase]
else:
print 'Running normal tests (-i for interactive tests)...'
test_classes = [BasicTestCase, ImportTestCase,
LibrariesTestCase, MultipackageTestCase]
# Create test suite.
generator = TestCaseGenerator()
suite = generator.create_suite(test_classes)
# Run created test suite.
clean()
run_tests(suite, opts.junitxml)
if __name__ == '__main__':
main()
| Python |
#!/usr/bin/env python
#
# This file is part of the package for testing eggs in `PyInstaller`.
#
# Author: Hartmut Goebel <h.goebel@goebel-consult.de>
# Copyright: 2012 by Hartmut Goebel
# Licence: GNU Public Licence v3 (GPLv3)
#
from setuptools import setup
setup(name='zipped_egg',
version='0.1',
description='A zipped egg for testing PyInstaller',
packages=['zipped_egg'],
package_data={'zipped_egg': ['data/datafile.txt']},
)
| Python |
#!/usr/bin/env python
#
# This file is part of the package for testing eggs in `PyInstaller`.
#
# Author: Hartmut Goebel <h.goebel@goebel-consult.de>
# Copyright: 2012 by Hartmut Goebel
# Licence: GNU Public Licence v3 (GPLv3)
#
import pkg_resources
data = pkg_resources.resource_string(__name__, 'data/datafile.txt').rstrip()
| Python |
#!/usr/bin/env python
#
# This file is part of the package for testing eggs in `PyInstaller`.
#
# Author: Hartmut Goebel <h.goebel@goebel-consult.de>
# Copyright: 2012 by Hartmut Goebel
# Licence: GNU Public Licence v3 (GPLv3)
#
import pkg_resources
data = pkg_resources.resource_string(__name__, 'data/datafile.txt').rstrip()
| Python |
#!/usr/bin/env python
#
# This file is part of the package for testing eggs in `PyInstaller`.
#
# Author: Hartmut Goebel <h.goebel@goebel-consult.de>
# Copyright: 2012 by Hartmut Goebel
# Licence: GNU Public Licence v3 (GPLv3)
#
from setuptools import setup
setup(name='unzipped_egg',
version='0.1',
description='A unzipped egg for testing PyInstaller',
packages=['unzipped_egg'],
package_data={'unzipped_egg': ['data/datafile.txt']},
zip_safe = False,
)
| 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
# Install necessary 3rd party Python modules to run all tests.
# This script is supposed to be used in a continuous integration system:
# https://jenkins.shiningpanda.com/pyinstaller/
# Python there is mostly 64bit. Only Python 2.4 is 32bit on Windows 7.
import glob
import optparse
import os
import platform
import sys
# easy_install command used in a Python script.
from setuptools.command import easy_install
try:
import PyInstaller
except ImportError:
# if importing PyInstaller fails, try to load from parent
# directory to support running without installation
import imp
if not hasattr(os, "getuid") or os.getuid() != 0:
imp.load_module('PyInstaller', *imp.find_module('PyInstaller',
[os.path.dirname(os.path.dirname(os.path.abspath(__file__)))]))
from PyInstaller.compat import is_py24, is_py25, is_py26
PYVER = '.'.join([str(x) for x in sys.version_info[0:2]])
def py_arch():
"""
.exe installers of Python modules contain architecture name in filename.
"""
mapping = {'32bit': 'win32', '64bit': 'win-amd64'}
arch = platform.architecture()[0]
return mapping[arch]
_PACKAGES = {
# 'modulename': 'pypi_name_or_url_or_path'
'MySQLdb': ['MySQL-python-*%s-py%s.exe' % (py_arch(), PYVER)],
'numpy': ['numpy-unoptimized-*%s-py%s.exe' % (py_arch(), PYVER)],
'PIL': ['PIL-*%s-py%s.exe' % (py_arch(), PYVER)],
'psycopg2': ['psycopg2-*%s-py%s.exe' % (py_arch(), PYVER)],
'pycrypto': ['pycrypto'],
'pyodbc': ['pyodbc'],
'simplejson': ['simplejson'],
'sqlalchemy': ['SQLAlchemy-*%s-py%s.exe' % (py_arch(), PYVER)],
'wx': ['wxPython-common-*%s-py%s.exe' % (py_arch(), PYVER),
'wxPython-2*%s-py%s.exe' % (py_arch(), PYVER)],
'win32api': ['http://downloads.sourceforge.net/project/pywin32/pywin32/Build%%20217/pywin32-217.%s-py%s.exe' %
(py_arch(), PYVER)],
}
_PY_VERSION = {
'MySQLdb': is_py26,
'numpy': is_py26,
'PIL': is_py26,
'psycopg2': is_py26,
'simplejson': is_py25,
'sqlalchemy': is_py24,
# Installers are available only for Python 2.6/2.7.
'wx': is_py26,
}
def main():
parser = optparse.OptionParser()
parser.add_option('-d', '--download-dir',
help='Directory with maually downloaded python modules.'
)
opts, _ = parser.parse_args()
# Install packages.
for k, v in _PACKAGES.items():
# Test python version for module.
if k in _PY_VERSION:
# Python version too old, skip module.
if PYVER < _PY_VERSION[k]:
continue
try:
__import__(k)
print 'Already installed... %s' % k
# Module is not available - install it.
except ImportError:
# If not url or module name then look for installers in download area.
if not v[0].startswith('http') and v[0].endswith('exe'):
files = []
# Try all file patterns.
for pattern in v:
pattern = os.path.join(opts.download_dir, pattern)
files += glob.glob(pattern)
# No file with that pattern was not found - skip it.
if not files:
print 'Skipping module... %s' % k
continue
# Full path to installers in download directory.
v = files
print 'Installing module... %s' % k
# Some modules might require several .exe files to install.
for f in v:
print ' %s' % f
# Use --no-deps ... installing module dependencies might fail
# because easy_install tries to install the same module from
# PYPI from source code and if fails because of C code that
# that needs to be compiled.
easy_install.main(['--no-deps', '--always-unzip', f])
if __name__ == '__main__':
main()
| Python |
# -*- mode: python -*-
__testname__ = 'test_eggs1'
a = Analysis([__testname__ + '.py'],
pathex=['unzipped.egg', 'zipped.egg'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.platform, __testname__ + '.exe'),
debug=0,
console=1)
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=None,
name=os.path.join('dist', __testname__),)
| Python |
# -*- mode: python -*-
__testname__ = 'test_relative_import2'
a = Analysis([__testname__ + '.py'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
name = os.path.join('dist', __testname__, __testname__ +'.exe'),
debug=False,
strip=False,
upx=False,
console=1 )
| Python |
name = 'relimp.relimp.relimp3'
| Python |
from __future__ import absolute_import
name = 'relimp.relimp.relimp2'
from . import relimp3
assert relimp3.name == 'relimp.relimp.relimp3'
from .. import relimp
assert relimp.name == 'relimp.relimp'
import relimp
assert relimp.name == 'relimp'
import relimp.relimp2
assert relimp.relimp2.name == 'relimp.relimp2'
# While this seams to work when running Python, it is wrong:
# .relimp should be a sibling of this package
#from .relimp import relimp2
#assert relimp2.name == 'relimp.relimp2'
| Python |
name = 'relimp.relimp'
| Python |
from __future__ import absolute_import
name = 'relimp.relimp1'
from . import relimp2 as upper
from . relimp import relimp2 as lower
assert upper.name == 'relimp.relimp2'
assert lower.name == 'relimp.relimp.relimp2'
if upper.__name__ == lower.__name__:
raise SystemExit("Imported the same module")
if upper.__file__ == lower.__file__:
raise SystemExit("Imported the same file")
| Python |
name = 'relimp.E'
| Python |
name = 'relimp.relimp2'
| Python |
name = 'relimp.F.G'
| Python |
name = 'relimp.F'
class H:
name = 'relimp.F.H'
| Python |
name = 'relimp'
| Python |
name = 'relimp.B.D'
class X:
name = 'relimp.B.D.X'
| Python |
name = 'relimp.B'
| Python |
name = 'relimp.B.C'
from . import D # Imports relimp.B.D
from .D import X # Imports relimp.B.D.X
from .. import E # Imports relimp.E
from ..F import G # Imports relimp.F.G
from ..F import H # Imports relimp.F.H
assert D.name == 'relimp.B.D'
assert E.name == 'relimp.E'
assert G.name == 'relimp.F.G'
assert H.name == 'relimp.F.H'
| Python |
# -*- mode: python -*-
__testname__ = 'test_ctypes_cdll_c'
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=True,
strip=False,
upx=False,
console=1 )
coll = COLLECT( exe,
a.binaries,
a.zipfiles,
strip=False,
upx=False,
name=os.path.join('dist', __testname__))
| Python |
# -*- mode: python -*-
__testname__ = 'test_eggs2'
a = Analysis([__testname__ + '.py'],
pathex=['unzipped.egg', 'zipped.egg'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.platform, __testname__ + '.exe'),
debug=0,
console=1)
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=None,
name=os.path.join('dist', __testname__),)
| Python |
string = "I hope you see this!"
| Python |
#
| Python |
# -*- mode: python -*-
__testname__ = 'test_ctypes_cdll_c2'
a = Analysis([__testname__ + '.py'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.binaries,
a.zipfiles,
a.scripts,
name=os.path.join('dist', __testname__ + '.exe'),
debug=True,
strip=False,
upx=False,
console=1 )
| Python |
import os
os.environ["qwiejioqwjeioqwjeioqwje"]
| 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
# This is a static plugin module that goes
# with the test_app_with_plugins sample.
print('Static plugin imported.')
| Python |
# -*- mode: python -*-
__testname__ = 'test_hiddenimport'
a = Analysis([__testname__ + '.py'],
hiddenimports=['anydbm'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.platform, __testname__ + '.exe'),
debug=0,
console=1)
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=None,
name=os.path.join('dist', __testname__),)
| Python |
raise RuntimeError
| Python |
# -*- mode: python -*-
__testname__ = 'test_relative_import'
a = Analysis([__testname__ + '.py'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
name = os.path.join('dist', __testname__, __testname__ +'.exe'),
debug=False,
strip=False,
upx=False,
console=1 )
| Python |
# -*- mode: python -*-
__testname__ = 'test_app_with_plugins'
a = Analysis([__testname__+'.py'], pathex=[])
TOC_custom = [('static_plugin.py','static_plugin.py','DATA')]
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build', 'pyi.'+sys.platform, __testname__ + '.exe'),
debug=1,
console=1)
coll = COLLECT( exe,
a.binaries,
TOC_custom,
name=os.path.join('dist', __testname__),)
| Python |
from .relimp3b import b1
from .relimp3c import c1
def getString():
return b1.string + c1.string
| Python |
#
| Python |
class c1:
string = "... and this"
| Python |
#
| Python |
raise ValueError
| Python |
raise ValueError
| Python |
# -*- mode: python -*-
__testname__ = 'test_error_during_import'
a = Analysis([__testname__ + '.py'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
name = os.path.join('dist', __testname__, __testname__ +'.exe'),
debug=False,
strip=False,
upx=False,
console=1 )
| Python |
from ..baz import *
| Python |
def say_hello_please():
print "Hello World!"
| Python |
from .baz import *
| Python |
#
| Python |
#!/usr/bin/env python
#
# This file is part of the package for testing eggs in `PyInstaller`.
#
# Author: Hartmut Goebel <h.goebel@goebel-consult.de>
# Copyright: 2012 by Hartmut Goebel
# Licence: GNU Public Licence v3 (GPLv3)
#
import pkg_resources
data = pkg_resources.resource_string(__name__, 'data/datafile.txt').rstrip()
| Python |
# -*- mode: python -*-
__testname__ = 'test_relative_import3'
a = Analysis([__testname__ + '.py'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
name = os.path.join('dist', __testname__, __testname__ +'.exe'),
debug=False,
strip=False,
upx=False,
console=1 )
| Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import httplib
import gzip
def main():
print "Hello World!"
if __name__ == "__main__":
main()
| Python |
#!/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 |
#!/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 -*-
'''
MULTIPROCESS FEATURE: file A (onefile pack) depends on file B (onefile pack).
'''
__testname__ = 'test_multipackage1'
__testdep__ = 'multipackage1_B'
a = Analysis([__testname__ + '.py'],
pathex=['.'])
b = Analysis([__testdep__ + '.py'],
pathex=['.'])
MERGE((b, __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.binaries,
b.zipfiles,
b.datas,
b.dependencies,
name=os.path.join('dist', __testdep__ + '.exe'),
debug=False,
strip=False,
upx=True,
console=1 )
| Python |
#!/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 (onedir pack).
'''
__testname__ = 'test_multipackage4'
__testdep__ = 'multipackage4_B'
a = Analysis([__testname__ + '.py'],
pathex=['.'])
b = Analysis([__testdep__ + '.py'],
pathex=['.'])
MERGE((b, __testdep__, os.path.join(__testdep__, __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.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 |
#!/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 (onedir pack) and file C (onefile pack)
'''
__testname__ = 'test_multipackage5'
__testdep__ = 'multipackage5_B'
__testdep2__ = 'multipackage5_C'
a = Analysis([__testname__ + '.py'],
pathex=['.'])
b = Analysis([__testdep__ + '.py'],
pathex=['.'])
c = Analysis([__testdep2__ + '.py'],
pathex=['.'])
MERGE((b, __testdep__, os.path.join(__testdep__, __testdep__ + '.exe')),
(c, __testdep2__, os.path.join(__testdep2__ + '.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.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__))
pyzC = PYZ(c.pure)
exeC = EXE(pyzC,
c.scripts,
c.binaries,
c.zipfiles,
c.datas,
c.dependencies,
name=os.path.join('dist', __testdep2__ + '.exe'),
debug=False,
strip=False,
upx=True,
console=1 )
| 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.