Esempio n. 1
0
#-----------------------------------------------------------------------------


RT_ICON = 3
RT_GROUP_ICON = 14
LOAD_LIBRARY_AS_DATAFILE = 2

import struct
import types
try:
    StringTypes = types.StringTypes
except AttributeError:
    StringTypes = [ type("") ]

import PyInstaller.log as logging
logger = logging.getLogger('PyInstaller.icon')

class Structure:
    def __init__(self):
        size = self._sizeInBytes = struct.calcsize(self._format_)
        self._fields_ = list(struct.unpack(self._format_, '\000' * size))
        indexes = self._indexes_ = {}
        for i, nm in enumerate(self._names_):
            indexes[nm] = i

    def dump(self):
        logger.info("DUMP of %s", self)
        for name in self._names_:
            if not name.startswith('_'):
                logger.info("%20s = %s", name, getattr(self, name))
        logger.info("")
Esempio n. 2
0
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 = {
Esempio n. 3
0
#-----------------------------------------------------------------------------
# Copyright (c) 2015-2016, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------

from PyInstaller.utils.hooks import is_module_satisfies
from PyInstaller import log as logging

if is_module_satisfies('kivy >= 1.9.1'):
    from kivy.tools.packaging.pyinstaller_hooks import (
        add_dep_paths, excludedimports, datas, get_deps_all,
        get_factory_modules, kivy_modules)

    add_dep_paths()

    hiddenimports = get_deps_all()['hiddenimports']
    hiddenimports = list(set(get_factory_modules() + kivy_modules +
                             hiddenimports))
else:
    logger = logging.getLogger(__name__)
    logger.warn('Hook disabled because of Kivy version < 1.9.1')
Esempio n. 4
0
# 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

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):
Esempio n. 5
0
Manipulating with dynamic libraries.
"""


__all__ = ['exclude_list', 'include_list', 'include_library']


import os
import re


from PyInstaller.compat import is_win, is_unix, is_aix, is_darwin


import PyInstaller.log as logging
logger = logging.getLogger(__name__)


_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_includes = {
    # DLLs are from 'Microsoft Visual C++ 2010 Redistributable Package'.
Esempio n. 6
0
"""
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 = {
Esempio n. 7
0
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('-a', '--all-with-crypto', action='store_true',
                      help='Run the whole test suite with bytecode encryption enabled.')
    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('--known-fails', action='store_true',
                      dest='run_known_fails',
                      help='Run tests known to fail, too.')

    opts, args = parser.parse_args()

    # 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] in (".py", ".spec")]
            # Sort tests aplhabetically. For example test
            # basic/test_nested_launch1 depends on the executable from
            # basic/test_nested_launch0, which it runs.
            test_list.sort()
            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_script, test_dir=test_dir,
                        run_known_fails=opts.run_known_fails))
                print('Running test: ', (test_dir + '/' + test_script))

    # Run all tests or all interactive tests.
    else:
        if opts.interactive_tests:
            print('Running interactive tests...')
            test_classes = [InteractiveTestCase]
        elif opts.all_with_crypto:
            print('Running normal tests with bytecode encryption...')
            # Make sure to exclude CryptoTestCase here since we are building
            # everything else with crypto enabled.
            test_classes = [BasicTestCase, ImportTestCase,
                    LibrariesTestCase, MultipackageTestCase]
        else:
            print('Running normal tests (-i for interactive tests)...')
            test_classes = [BasicTestCase, CryptoTestCase, ImportTestCase,
                    LibrariesTestCase, MultipackageTestCase]

        # Create test suite.
        generator = TestCaseGenerator()
        suite = generator.create_suite(test_classes, opts.all_with_crypto,
                                       opts.run_known_fails)

    # Set global options
    global VERBOSE, REPORT, PYI_CONFIG
    VERBOSE = opts.verbose
    # The function called by configure.get_config uses logging. So, we need to
    # set a logging level now, in addition to passing it as a "log-level=XXXX"
    # option in test_building (see the OPTS dict), in order for the logging
    # level to be consistent. Otherwise, the default logging level of INFO will
    # produce messages, then be overriden by runtest's default (when the -v /
    # --verbose option isn't specificed on runtest's command line) of ERROR
    # (again, see the OPTS dict in test_building).
    if VERBOSE:
        # logging's default of INFO is fine.
        pass
    else:
        # Set the logging level to ERROR.
        logger = logging.getLogger('PyInstaller')
        logger.setLevel(logging.ERROR)
    PYI_CONFIG = configure.get_config(upx_dir=None)  # Run configure phase only once.


    # Run created test suite.
    clean()

    result = run_tests(suite)

    sys.exit(int(bool(result.failures or result.errors)))
Esempio n. 8
0
import shutil
import re
import time
import inspect

from PyInstaller import HOMEPATH, PLATFORM
from PyInstaller import is_win, is_unix, is_darwin, is_py24, get_version

import PyInstaller.build as build
import PyInstaller.compat as compat

import PyInstaller.log as logging
import PyInstaller.depend.modules
import PyInstaller.depend.imptracker

logger = logging.getLogger("PyInstaller.configure")


def test_Crypt(config):
    # TODO: disabled for now
    config["useCrypt"] = 0
    return

    # Crypt support. We need to build the AES module and we'll use distutils
    # for that. FIXME: the day we'll use distutils for everything this will be
    # a solved problem.
    logger.info("trying to build crypt support...")
    from distutils.core import run_setup

    cwd = os.getcwd()
    args = sys.argv[:]
Esempio n. 9
0
# 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('PyInstaller.build.mf')

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')
Esempio n. 10
0
import shutil
import re
import time
import inspect

from PyInstaller import HOMEPATH, PLATFORM
from PyInstaller import is_win, is_unix, is_darwin, is_py24, get_version

import PyInstaller.build as build
import PyInstaller.compat as compat

import PyInstaller.log as logging
import PyInstaller.depend.modules
import PyInstaller.depend.imptracker

logger = logging.getLogger('PyInstaller.configure')


def test_Crypt(config):
    # TODO: disabled for now
    config["useCrypt"] = 0
    return

    #Crypt support. We need to build the AES module and we'll use distutils
    # for that. FIXME: the day we'll use distutils for everything this will be
    # a solved problem.
    logger.info("trying to build crypt support...")
    from distutils.core import run_setup
    cwd = os.getcwd()
    args = sys.argv[:]
    try:
Esempio n. 11
0
# 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,
}
Esempio n. 12
0
# 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):
Esempio n. 13
0
Commandline usage:
winresource.py <dstpath> <srcpath>
Updates or adds resources from file <srcpath> in file <dstpath>.

2009-03 Florian Hoech

"""

import os.path
import pywintypes
import win32api

import PyInstaller.log as logging

logger = logging.getLogger('PyInstaller.build.winresource')

from PyInstaller.compat import set

LOAD_LIBRARY_AS_DATAFILE = 2
ERROR_BAD_EXE_FORMAT = 193
ERROR_RESOURCE_DATA_NOT_FOUND = 1812
ERROR_RESOURCE_TYPE_NOT_FOUND = 1813
ERROR_RESOURCE_NAME_NOT_FOUND = 1814
ERROR_RESOURCE_LANG_NOT_FOUND = 1815


class File(object):
    """ Win32 PE file class. """
    def __init__(self, filename):
        self.filename = filename
Esempio n. 14
0
#!/usr/bin/env python

import os
import sys
import PyInstaller
import PyInstaller.compat as compat
from PyInstaller.compat import set
from PyInstaller.utils import misc

import PyInstaller.log as logging
logger = logging.getLogger('PyInstaller.build.hooks')


def __exec_python_cmd(cmd):
    """
    Executes an externally spawned Python interpreter and returns
    anything that was emitted in the standard output as a single
    string.
    """
    # Prepend PYTHONPATH with pathex
    pp = os.pathsep.join(PyInstaller.__pathex__)
    old_pp = compat.getenv('PYTHONPATH')
    if old_pp:
        pp = os.pathsep.join([pp, old_pp])
    compat.setenv("PYTHONPATH", pp)
    try:
        try:
            txt = compat.exec_python(*cmd)
        except OSError, e:
            raise SystemExit("Execution failed: %s" % e)
    finally:
Esempio n. 15
0
#!/usr/bin/env python

import os
import sys
import PyInstaller
import PyInstaller.compat as compat
from PyInstaller.compat import set
from PyInstaller.utils import misc

import PyInstaller.log as logging
logger = logging.getLogger('PyInstaller.build.hooks')


def __exec_python_cmd(cmd):
    """
    Executes an externally spawned Python interpreter and returns
    anything that was emitted in the standard output as a single
    string.
    """
    # Prepend PYTHONPATH with pathex
    pp = os.pathsep.join(PyInstaller.__pathex__)
    old_pp = compat.getenv('PYTHONPATH')
    if old_pp:
        pp = os.pathsep.join([pp, old_pp])
    compat.setenv("PYTHONPATH", pp)
    try:
        try:
            txt = compat.exec_python(*cmd)
        except OSError, e:
            raise SystemExit("Execution failed: %s" % e)
    finally:
Esempio n. 16
0
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(
        '-a',
        '--all-with-crypto',
        action='store_true',
        help='Run the whole test suite with bytecode encryption enabled.')
    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('--known-fails',
                      action='store_true',
                      dest='run_known_fails',
                      help='Run tests known to fail, too.')

    opts, args = parser.parse_args()

    # 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] in (".py", ".spec")
                ]
            # Sort tests aplhabetically. For example test
            # basic/test_nested_launch1 depends on the executable from
            # basic/test_nested_launch0, which it runs.
            test_list.sort()
            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_script,
                                    test_dir=test_dir,
                                    run_known_fails=opts.run_known_fails))
                print('Running test: ', (test_dir + '/' + test_script))

    # Run all tests or all interactive tests.
    else:
        if opts.interactive_tests:
            print('Running interactive tests...')
            test_classes = [InteractiveTestCase]
        elif opts.all_with_crypto:
            print('Running normal tests with bytecode encryption...')
            # Make sure to exclude CryptoTestCase here since we are building
            # everything else with crypto enabled.
            test_classes = [
                BasicTestCase, ImportTestCase, LibrariesTestCase,
                MultipackageTestCase
            ]
        else:
            print('Running normal tests (-i for interactive tests)...')
            test_classes = [
                BasicTestCase, CryptoTestCase, ImportTestCase,
                LibrariesTestCase, MultipackageTestCase
            ]

        # Create test suite.
        generator = TestCaseGenerator()
        suite = generator.create_suite(test_classes, opts.all_with_crypto,
                                       opts.run_known_fails)

    # Set global options
    global VERBOSE, REPORT, PYI_CONFIG
    VERBOSE = opts.verbose
    # The function called by configure.get_config uses logging. So, we need to
    # set a logging level now, in addition to passing it as a "log-level=XXXX"
    # option in test_building (see the OPTS dict), in order for the logging
    # level to be consistent. Otherwise, the default logging level of INFO will
    # produce messages, then be overriden by runtest's default (when the -v /
    # --verbose option isn't specificed on runtest's command line) of ERROR
    # (again, see the OPTS dict in test_building).
    if VERBOSE:
        # logging's default of INFO is fine.
        pass
    else:
        # Set the logging level to ERROR.
        logger = logging.getLogger('PyInstaller')
        logger.setLevel(logging.ERROR)
    PYI_CONFIG = configure.get_config(
        upx_dir=None)  # Run configure phase only once.

    # Run created test suite.
    clean()

    result = run_tests(suite)

    sys.exit(int(bool(result.failures or result.errors)))
Esempio n. 17
0
import re
import time
import inspect

from PyInstaller import HOMEPATH, CONFIGDIR, DEFAULT_CONFIGFILE, PLATFORM
from PyInstaller import is_win, is_unix, is_darwin, is_py24, get_version

import PyInstaller.mf as mf
import PyInstaller.bindepend as bindepend
import PyInstaller.build as build
import PyInstaller.compat as compat

from PyInstaller.depend import dylib

import PyInstaller.log as logging
logger = logging.getLogger('PyInstaller.configure')


def _write_textfile(filename, text):
    """
    Write `text` into file `filename`. If the target directory does
    not exist, create it.
    """
    dirname = os.path.dirname(filename)
    if not os.path.exists(dirname):
        os.makedirs(dirname)
    outf = open(filename, 'w')
    outf.write(text)
    outf.close()

Esempio n. 18
0
def add_qt5_dependencies(hook_file):

    logger = logging.getLogger(__name__)

    # Accumulate all dependencies in a set to avoid duplicates.
    hiddenimports = set()
    translations_base = set()
    plugins = set()

    # Find the module underlying this Qt hook: change
    # ``/path/to/hook-PyQt5.blah.py`` to ``PyQt5.blah``.
    hook_name, hook_ext = os.path.splitext(os.path.basename(hook_file))
    assert hook_ext.startswith('.py')
    assert hook_name.startswith('hook-')
    module_name = hook_name[5:]
    namespace = module_name.split('.')[0]
    if namespace != 'PyQt5':
        raise Exception('Invalid namespace: {0}'.format(namespace))

    # Look up the module returned by this import.
    module = get_module_file_attribute(module_name)
    logger.debug('add_qt5_dependencies: Examining %s, based on hook of %s.',
                 module, hook_file)

    # Walk through all the static dependencies of a dynamically-linked library
    # (``.so``/``.dll``/``.dylib``).
    imports = set(getImports(module))
    while imports:
        imp = imports.pop()

        # On Windows, find this library; other platforms already provide the
        # full path.
        if is_win:
            imp = getfullnameof(imp)

        # Strip off the extension and ``lib`` prefix (Linux/Mac) to give the raw
        # name. Lowercase (since Windows always normalized names to lowercase).
        lib_name = os.path.splitext(os.path.basename(imp))[0].lower()
        # Linux libraries sometimes have a dotted version number --
        # ``libfoo.so.3``. It's now ''libfoo.so``, but the ``.so`` must also be
        # removed.
        if is_linux and os.path.splitext(lib_name)[1] == '.so':
            lib_name = os.path.splitext(lib_name)[0]
        if lib_name.startswith('lib'):
            lib_name = lib_name[3:]
        # Mac: rename from ``qt`` to ``qt5`` to match names in Windows/Linux.
        if is_darwin and lib_name.startswith(
                'qt') and not lib_name.startswith('qt5'):
            lib_name = 'qt5' + lib_name[2:]
        elif is_darwin and lib_name.startswith('qt5'):
            lib_name = 'qt5' + lib_name[3:]
        if is_darwin and len(os.path.splitext(lib_name)) > 1:
            lib_name = os.path.splitext(lib_name)[0]

        logger.debug('add_qt5_dependencies: raw lib %s -> parsed lib %s', imp,
                     lib_name)

        # Follow only Qt dependencies.
        if lib_name in _qt_dynamic_dependencies_dict:
            # Follow these to find additional dependencies.
            logger.debug('add_qt5_dependencies: Import of %s.', imp)
            imports.update(getImports(imp))
            # Look up which plugins and translations are needed. Avoid Python
            # 3-only syntax, since the Python 2.7 parser will raise an
            # exception. The original statment was:
            ## (lib_name_hiddenimports, lib_name_translations_base,
            ## *lib_name_plugins) = _qt_dynamic_dependencies_dict[lib_name]
            dd = _qt_dynamic_dependencies_dict[lib_name]
            lib_name_hiddenimports, lib_name_translations_base = dd[:2]
            lib_name_plugins = dd[2:]
            # Add them in.
            if lib_name_hiddenimports:
                hiddenimports.update([lib_name_hiddenimports])
            plugins.update(lib_name_plugins)
            if lib_name_translations_base:
                translations_base.update([lib_name_translations_base])

    # Change plugins into binaries.
    binaries = []
    for plugin in plugins:
        more_binaries = qt_plugins_binaries(plugin, namespace=namespace)
        binaries.extend(more_binaries)
    # Change translation_base to datas.
    tp = pyqt5_library_info.location['TranslationsPath']
    datas = []
    for tb in translations_base:
        src = os.path.join(tp, tb + '_*.qm')
        # Not all PyQt5 installations include translations. See
        # https://github.com/pyinstaller/pyinstaller/pull/3229#issuecomment-359479893
        # and
        # https://github.com/pyinstaller/pyinstaller/issues/2857#issuecomment-368744341.
        if glob.glob(src):
            datas.append((src, os.path.join(namespace, 'Qt', 'translations')))
        else:
            logger.warning(
                'Unable to find Qt5 translations %s. These '
                'translations were not packaged.', src)
    # Change hiddenimports to a list.
    hiddenimports = list(hiddenimports)

    logger.debug(
        'add_qt5_dependencies: imports from %s:\n'
        '  hiddenimports = %s\n'
        '  binaries = %s\n'
        '  datas = %s', hook_name, hiddenimports, binaries, datas)
    return hiddenimports, binaries, datas
Esempio n. 19
0
import sys
import re
from glob import glob

# Required for extracting eggs.
import zipfile


from PyInstaller.compat import is_win, is_unix, is_aix, is_cygwin, is_darwin, is_py26
from PyInstaller.depend import dylib
from PyInstaller.utils import winutils
import PyInstaller.compat as compat


import PyInstaller.log as logging
logger = logging.getLogger(__file__)

seen = {}

if is_win:
    if is_py26:
        try:
            # For Portable Python it is required to import pywintypes before
            # win32api module. See for details:
            # http://www.voidspace.org.uk/python/movpy/reference/win32ext.html#problems-with-win32api
            import pywintypes
            import win32api
        except ImportError:
            raise SystemExit("Error: PyInstaller for Python 2.6+ on Windows "
                 "needs pywin32.\r\nPlease install from "
                 "http://sourceforge.net/projects/pywin32/")
Esempio n. 20
0
#
# 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
"""
Utils for Windows platform.
"""

__all__ = ['get_windows_dir']

import os

from PyInstaller import is_win

import PyInstaller.log as logging
logger = logging.getLogger('PyInstaller.build.bindepend')


def get_windows_dir():
    """Return the Windows directory e.g. C:\\Windows"""
    try:
        import win32api
    except ImportError:
        windir = os.getenv('SystemRoot', os.getenv('WINDIR'))
    else:
        windir = win32api.GetWindowsDirectory()
    if not windir:
        raise SystemExit("Error: Can not determine your Windows directory")
    return windir

Esempio n. 21
0
Commandline usage:
winresource.py <dstpath> <srcpath>
Updates or adds resources from file <srcpath> in file <dstpath>.

2009-03 Florian Hoech

"""

import os.path
import pywintypes
import win32api

import PyInstaller.log as logging

logger = logging.getLogger("PyInstaller.build.winresource")

from PyInstaller.compat import set

LOAD_LIBRARY_AS_DATAFILE = 2
ERROR_BAD_EXE_FORMAT = 193
ERROR_RESOURCE_DATA_NOT_FOUND = 1812
ERROR_RESOURCE_TYPE_NOT_FOUND = 1813
ERROR_RESOURCE_NAME_NOT_FOUND = 1814
ERROR_RESOURCE_LANG_NOT_FOUND = 1815


class File(object):

    """ Win32 PE file class. """
Esempio n. 22
0
import os
import sys
import re
from glob import glob

# Required for extracting eggs.
import zipfile

from PyInstaller.compat import is_win, is_unix, is_aix, is_cygwin, is_darwin, is_py26
from PyInstaller.depend import dylib
from PyInstaller.utils import winutils
import PyInstaller.compat as compat

import PyInstaller.log as logging
logger = logging.getLogger(__file__)

seen = {}

if is_win:
    if is_py26:
        try:
            # For Portable Python it is required to import pywintypes before
            # win32api module. See for details:
            # http://www.voidspace.org.uk/python/movpy/reference/win32ext.html#problems-with-win32api
            import pywintypes
            import win32api
        except ImportError:
            raise SystemExit("Error: PyInstaller for Python 2.6+ on Windows "
                             "needs pywin32.\r\nPlease install from "
                             "http://sourceforge.net/projects/pywin32/")
Esempio n. 23
0
"""

import os
from glob import glob
import re
import sys
import xml
from xml.dom import Node, minidom
from xml.dom.minidom import Document, Element

from PyInstaller import compat
from PyInstaller.compat import hashlib, architecture
from PyInstaller import log as logging

logger = logging.getLogger("PyInstaller.build.winmanifest")

try:
    from PyInstaller.utils import winresource
except ImportError, detail:
    winresource = None
    logger.warn(detail)
    logger.warn("Cannot check for assembly dependencies - resource access ")
    logger.warn("unavailable. To enable resource access, please install ")
    logger.warn("http://sourceforge.net/projects/pywin32/")


LANGUAGE_NEUTRAL_NT5 = "x-ww"
LANGUAGE_NEUTRAL_NT6 = "none"
RT_MANIFEST = 24
Esempio n. 24
0
winmanifest.py <dstpath> <xmlpath>
Updates or adds manifest <xmlpath> as resource in Win32 PE file <dstpath>.
"""

import os
from glob import glob
import re
import sys
import xml
from xml.dom import Node, minidom
from xml.dom.minidom import Document, Element

from PyInstaller import compat
from PyInstaller.compat import hashlib, architecture
from PyInstaller import log as logging
logger = logging.getLogger('PyInstaller.build.winmanifest')

try:
    from PyInstaller.utils import winresource
except ImportError, detail:
    winresource = None
    logger.warn(detail)
    logger.warn("Cannot check for assembly dependencies - resource access ")
    logger.warn("unavailable. To enable resource access, please install ")
    logger.warn("http://sourceforge.net/projects/pywin32/")

LANGUAGE_NEUTRAL_NT5 = "x-ww"
LANGUAGE_NEUTRAL_NT6 = "none"
RT_MANIFEST = 24

Document.aChild = Document.appendChild
Esempio n. 25
0
import os
import sys
import re
from glob import glob
# Required for extracting eggs.
import zipfile

from PyInstaller import is_win, is_unix, is_aix, is_cygwin, is_darwin, is_py26
from PyInstaller.depend import dylib
from PyInstaller.utils import winutils
import PyInstaller.compat as compat
from PyInstaller.compat import set


import PyInstaller.log as logging
logger = logging.getLogger('PyInstaller.build.bindepend')

seen = {}

if is_win:
    if is_py26:
        try:
            import win32api
            import pywintypes
        except ImportError:
            raise SystemExit("Error: PyInstaller for Python 2.6+ on Windows "
                 "needs pywin32.\r\nPlease install from "
                 "http://sourceforge.net/projects/pywin32/")

    from PyInstaller.utils.winmanifest import RT_MANIFEST
    from PyInstaller.utils.winmanifest import GetManifestResources
Esempio n. 26
0
# This code is courtesy of Thomas Heller, who
# has kindly donated it to this project.

RT_ICON = 3
RT_GROUP_ICON = 14
LOAD_LIBRARY_AS_DATAFILE = 2

import struct
import types
try:
    StringTypes = types.StringTypes
except AttributeError:
    StringTypes = [ type("") ]

import PyInstaller.log as logging
logger = logging.getLogger('PyInstaller.icon')

class Structure:
    def __init__(self):
        size = self._sizeInBytes = struct.calcsize(self._format_)
        self._fields_ = list(struct.unpack(self._format_, '\000' * size))
        indexes = self._indexes_ = {}
        for i in range(len(self._names_)):
            indexes[self._names_[i]] = i

    def dump(self):
        logger.info("DUMP of %s", self)
        for name in self._names_:
            if not name.startswith('_'):
                logger.info("%20s = %s", name, getattr(self, name))
        logger.info("")