コード例 #1
0
 def _scan(self, path, relativeModule):
     if relativeModule and str(relativeModule) in self._visited:
         return
     self._visited.add(str(relativeModule))
     if path == "":
         path = "."
     for root, dirs, files in os.walk(path):
         for directory in list(dirs):
             fullPath = os.path.join(root, directory)
             initFile = os.path.join(fullPath, "__init__.py")
             if not os.path.isfile(initFile):
                 dirs.remove(directory)
         for filename in files:
             fullPath = os.path.join(root, filename)
             if not fileIsUpsetoPythonNamespaceJoinInit(fullPath):
                 continue
             submodule = root[len(path) + len(os.path.sep):].split(
                 os.path.sep)
             absoluteModuleNameSplit = relativeModule
             if submodule != ['']:
                 absoluteModuleNameSplit = submodule
             absoluteModuleName = ".".join(absoluteModuleNameSplit)
             joinPaths = pythonnamespacejoin.Joiner(
                 fullPath, absoluteModuleName).found()
             for joinPath in joinPaths:
                 modulefinder.AddPackagePath(absoluteModuleName, joinPath)
                 self._todo.append((joinPath, absoluteModuleNameSplit))
コード例 #2
0
def InstallPy2exePatch():
    """
    Tricks py2exe to include the win32com module.

    ModuleFinder can't handle runtime changes to __path__, but win32com
    uses them, particularly for people who build from sources.
    """
    try:
        import modulefinder
        import win32com
        for path in win32com.__path__[1:]:
            modulefinder.AddPackagePath("win32com", path)
        for extra in ["win32com.shell"]:
            __import__(extra)
            module = sys.modules[extra]
            for path in module.__path__[1:]:
                modulefinder.AddPackagePath(extra, path)
    except ImportError:  # IGNORE:W0704
        # no build path setup, no worries.
        pass
コード例 #3
0
ファイル: build.py プロジェクト: swstack/stephenstack.com.v2
def main():
    """Parse command-line arguments and initiate the build process"""
    if __debug__:  # run ourself in subprocess
        print "Executing in subprocess"
        args = [sys.executable, '-OO'] + sys.argv
        sys.exit(subprocess.call(args))

    # HACK: work around deficiencies with modulefinder not examining
    # __path__ along the way (known limitation of modulefinder).
    try:
        import spectrum
        import spectrum.lib
        for path in spectrum.__path__:
            modulefinder.AddPackagePath('spectrum', path)
        for path in spectrum.lib.__path__:
            modulefinder.AddPackagePath('spectrum.lib', path)
    except ImportError:
        pass

    parser = _get_parser()
    options, args = parser.parse_args()
    if options.verbose:
        logger.setLevel(logging.DEBUG)

    build_config = BuildConfiguration()
    if options.config is not None:
        build_config.update_from_config(options.config)

    _setup_env(build_config, options.clean)

    files_to_copy = []
    if options.test_package is not None:
        # first, find the tests
        test_modules = TestFinder('my_application.test').find_test_modules()
        testfile_contents = fill_test_template(test_modules=test_modules)
        _write_to_out('runtests.py', testfile_contents)

    # perform the build
    files_to_copy.extend(_perform_build(build_config))
    files_to_copy.extend(_find_addl_files())
    _copy_to_out(build_config.output_directory_path, files_to_copy)
コード例 #4
0
def setupPackages():
    # First, get the list of packages, then reverse the list to
    # put it in ctattach order.  (The reversal may not matter too
    # much these days, but let's be as correct as we can be.)
    global packages
    packages = []
    for proj in ctprojs.split():
        projName = proj.split(':')[0]
        moduleName = projName.lower()
        if moduleName in sourceTrees:
            packages.append(moduleName)
    packages.reverse()

    for moduleName in packages:
        str = 'import %s' % (moduleName)
        exec(str)

        module = sys.modules[moduleName]
        modulefinder.AddPackagePath(moduleName, module.__path__[0])
コード例 #5
0
ファイル: setup.py プロジェクト: tcaddy/couchapp
    if os.name == "nt":
        scripts.append(os.path.join("resources", "scripts",
            "couchapp.bat"))
    return scripts

if os.name == "nt" or sys.platform == "win32":
    # py2exe needs to be installed to work
    try:
        import py2exe

        # Help py2exe to find win32com.shell
        try:
            import modulefinder
            import win32com
            for p in win32com.__path__[1:]: # Take the path to win32comext
                modulefinder.AddPackagePath("win32com", p)
            pn = "win32com.shell"
            __import__(pn)
            m = sys.modules[pn]
            for p in m.__path__[1:]:
                modulefinder.AddPackagePath(pn, p)
        except ImportError:
            raise SystemExit('You need pywin32 installed ' +
                    'http://sourceforge.net/projects/pywin32')

        # If run without args, build executables, in quiet mode.
        if len(sys.argv) == 1:
            sys.argv.append("py2exe")
            sys.argv.append("-q")

        extra['console'] = [{
コード例 #6
0
def main():
    # overridable context
    prefix = None                       # settable with -p option
    exec_prefix = None                  # settable with -P option
    extensions = []
    exclude = []                        # settable with -x option
    addn_link = []      # settable with -l, but only honored under Windows.
    path = sys.path[:]
    modargs = 0
    debug = 1
    odir = ''
    win = sys.platform[:3] == 'win'
    replace_paths = []                  # settable with -r option
    error_if_any_missing = 0

    # default the exclude list for each platform
    if win: exclude = exclude + [
        'dos', 'dospath', 'mac', 'macfs', 'MACFS', 'posix', ]

    fail_import = exclude[:]

    # output files
    frozen_c = 'frozen.c'
    config_c = 'config.c'
    target = 'a.out'                    # normally derived from script name
    makefile = 'Makefile'
    subsystem = 'console'

    # parse command line by first replacing any "-i" options with the
    # file contents.
    pos = 1
    while pos < len(sys.argv)-1:
        # last option can not be "-i", so this ensures "pos+1" is in range!
        if sys.argv[pos] == '-i':
            try:
                with open(sys.argv[pos+1]) as infp:
                    options = infp.read().split()
            except IOError as why:
                usage("File name '%s' specified with the -i option "
                      "can not be read - %s" % (sys.argv[pos+1], why) )
            # Replace the '-i' and the filename with the read params.
            sys.argv[pos:pos+2] = options
            pos = pos + len(options) - 1 # Skip the name and the included args.
        pos = pos + 1

    # Now parse the command line with the extras inserted.
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'r:a:dEe:hmo:p:P:qs:wX:x:l:')
    except getopt.error as msg:
        usage('getopt error: ' + str(msg))

    # process option arguments
    for o, a in opts:
        if o == '-h':
            print(__doc__)
            return
        if o == '-d':
            debug = debug + 1
        if o == '-e':
            extensions.append(a)
        if o == '-m':
            modargs = 1
        if o == '-o':
            odir = a
        if o == '-p':
            prefix = a
        if o == '-P':
            exec_prefix = a
        if o == '-q':
            debug = 0
        if o == '-w':
            win = not win
        if o == '-s':
            if not win:
                usage("-s subsystem option only on Windows")
            subsystem = a
        if o == '-x':
            exclude.append(a)
        if o == '-X':
            exclude.append(a)
            fail_import.append(a)
        if o == '-E':
            error_if_any_missing = 1
        if o == '-l':
            addn_link.append(a)
        if o == '-a':
            modulefinder.AddPackagePath(*a.split("=", 2))
        if o == '-r':
            f,r = a.split("=", 2)
            replace_paths.append( (f,r) )

    # modules that are imported by the Python runtime
    implicits = []
    for module in ('site', 'warnings', 'encodings.utf_8', 'encodings.latin_1'):
        if module not in exclude:
            implicits.append(module)

    # default prefix and exec_prefix
    if not exec_prefix:
        if prefix:
            exec_prefix = prefix
        else:
            exec_prefix = sys.exec_prefix
    if not prefix:
        prefix = sys.prefix

    # determine whether -p points to the Python source tree
    ishome = os.path.exists(os.path.join(prefix, 'Python', 'ceval.c'))

    # locations derived from options
    version = '%d.%d' % sys.version_info[:2]
    if hasattr(sys, 'abiflags'):
        flagged_version = version + sys.abiflags
    else:
        flagged_version = version
    if win:
        extensions_c = 'frozen_extensions.c'
    if ishome:
        print("(Using Python source directory)")
        binlib = exec_prefix
        incldir = os.path.join(prefix, 'Include')
        config_h_dir = exec_prefix
        config_c_in = os.path.join(prefix, 'Modules', 'config.c.in')
        frozenmain_c = os.path.join(prefix, 'Python', 'frozenmain.c')
        makefile_in = os.path.join(exec_prefix, 'Makefile')
        if win:
            frozendllmain_c = os.path.join(exec_prefix, 'Pc\\frozen_dllmain.c')
    else:
        binlib = os.path.join(exec_prefix,
                              'lib', 'python%s' % version,
                              'config-%s' % flagged_version)
        incldir = os.path.join(prefix, 'include', 'python%s' % flagged_version)
        config_h_dir = os.path.join(exec_prefix, 'include',
                                    'python%s' % flagged_version)
        config_c_in = os.path.join(binlib, 'config.c.in')
        frozenmain_c = os.path.join(binlib, 'frozenmain.c')
        makefile_in = os.path.join(binlib, 'Makefile')
        frozendllmain_c = os.path.join(binlib, 'frozen_dllmain.c')
    supp_sources = []
    defines = []
    includes = ['-I' + incldir, '-I' + config_h_dir]

    # sanity check of directories and files
    check_dirs = [prefix, exec_prefix, binlib, incldir]
    if not win:
        # These are not directories on Windows.
        check_dirs = check_dirs + extensions
    for dir in check_dirs:
        if not os.path.exists(dir):
            usage('needed directory %s not found' % dir)
        if not os.path.isdir(dir):
            usage('%s: not a directory' % dir)
    if win:
        files = supp_sources + extensions # extensions are files on Windows.
    else:
        files = [config_c_in, makefile_in] + supp_sources
    for file in supp_sources:
        if not os.path.exists(file):
            usage('needed file %s not found' % file)
        if not os.path.isfile(file):
            usage('%s: not a plain file' % file)
    if not win:
        for dir in extensions:
            setup = os.path.join(dir, 'Setup')
            if not os.path.exists(setup):
                usage('needed file %s not found' % setup)
            if not os.path.isfile(setup):
                usage('%s: not a plain file' % setup)

    # check that enough arguments are passed
    if not args:
        usage('at least one filename argument required')

    # check that file arguments exist
    for arg in args:
        if arg == '-m':
            break
        # if user specified -m on the command line before _any_
        # file names, then nothing should be checked (as the
        # very first file should be a module name)
        if modargs:
            break
        if not os.path.exists(arg):
            usage('argument %s not found' % arg)
        if not os.path.isfile(arg):
            usage('%s: not a plain file' % arg)

    # process non-option arguments
    scriptfile = args[0]
    modules = args[1:]

    # derive target name from script name
    base = os.path.basename(scriptfile)
    base, ext = os.path.splitext(base)
    if base:
        if base != scriptfile:
            target = base
        else:
            target = base + '.bin'

    # handle -o option
    base_frozen_c = frozen_c
    base_config_c = config_c
    base_target = target
    if odir and not os.path.isdir(odir):
        try:
            os.mkdir(odir)
            print("Created output directory", odir)
        except OSError as msg:
            usage('%s: mkdir failed (%s)' % (odir, str(msg)))
    base = ''
    if odir:
        base = os.path.join(odir, '')
        frozen_c = os.path.join(odir, frozen_c)
        config_c = os.path.join(odir, config_c)
        target = os.path.join(odir, target)
        makefile = os.path.join(odir, makefile)
        if win: extensions_c = os.path.join(odir, extensions_c)

    # Handle special entry point requirements
    # (on Windows, some frozen programs do not use __main__, but
    # import the module directly.  Eg, DLLs, Services, etc
    custom_entry_point = None  # Currently only used on Windows
    python_entry_is_main = 1   # Is the entry point called __main__?
    # handle -s option on Windows
    if win:
        import winmakemakefile
        try:
            custom_entry_point, python_entry_is_main = \
                winmakemakefile.get_custom_entry_point(subsystem)
        except ValueError as why:
            usage(why)


    # Actual work starts here...

    # collect all modules of the program
    dir = os.path.dirname(scriptfile)
    path[0] = dir
    mf = modulefinder.ModuleFinder(path, debug, exclude, replace_paths)

    if win and subsystem=='service':
        # If a Windows service, then add the "built-in" module.
        mod = mf.add_module("servicemanager")
        mod.__file__="dummy.pyd" # really built-in to the resulting EXE

    for mod in implicits:
        mf.import_hook(mod)
    for mod in modules:
        if mod == '-m':
            modargs = 1
            continue
        if modargs:
            if mod[-2:] == '.*':
                mf.import_hook(mod[:-2], None, ["*"])
            else:
                mf.import_hook(mod)
        else:
            mf.load_file(mod)

    # Alias "importlib._bootstrap" to "_frozen_importlib" so that the
    # import machinery can bootstrap.  Do the same for
    # importlib._bootstrap_external.
    mf.modules["_frozen_importlib"] = mf.modules["importlib._bootstrap"]
    mf.modules["_frozen_importlib_external"] = mf.modules["importlib._bootstrap_external"]

    # Add the main script as either __main__, or the actual module name.
    if python_entry_is_main:
        mf.run_script(scriptfile)
    else:
        mf.load_file(scriptfile)

    if debug > 0:
        mf.report()
        print()
    dict = mf.modules

    if error_if_any_missing:
        missing = mf.any_missing()
        if missing:
            sys.exit("There are some missing modules: %r" % missing)

    # generate output for frozen modules
    files = makefreeze.makefreeze(base, dict, debug, custom_entry_point,
                                  fail_import)

    # look for unfrozen modules (builtin and of unknown origin)
    builtins = []
    unknown = []
    mods = sorted(dict.keys())
    for mod in mods:
        if dict[mod].__code__:
            continue
        if not dict[mod].__file__:
            builtins.append(mod)
        else:
            unknown.append(mod)

    # search for unknown modules in extensions directories (not on Windows)
    addfiles = []
    frozen_extensions = [] # Windows list of modules.
    if unknown or (not win and builtins):
        if not win:
            addfiles, addmods = \
                      checkextensions.checkextensions(unknown+builtins,
                                                      extensions)
            for mod in addmods:
                if mod in unknown:
                    unknown.remove(mod)
                    builtins.append(mod)
        else:
            # Do the windows thang...
            import checkextensions_win32
            # Get a list of CExtension instances, each describing a module
            # (including its source files)
            frozen_extensions = checkextensions_win32.checkextensions(
                unknown, extensions, prefix)
            for mod in frozen_extensions:
                unknown.remove(mod.name)

    # report unknown modules
    if unknown:
        sys.stderr.write('Warning: unknown modules remain: %s\n' %
                         ' '.join(unknown))

    # windows gets different treatment
    if win:
        # Taking a shortcut here...
        import winmakemakefile, checkextensions_win32
        checkextensions_win32.write_extension_table(extensions_c,
                                                    frozen_extensions)
        # Create a module definition for the bootstrap C code.
        xtras = [frozenmain_c, os.path.basename(frozen_c),
                 frozendllmain_c, os.path.basename(extensions_c)] + files
        maindefn = checkextensions_win32.CExtension( '__main__', xtras )
        frozen_extensions.append( maindefn )
        with open(makefile, 'w') as outfp:
            winmakemakefile.makemakefile(outfp,
                                         locals(),
                                         frozen_extensions,
                                         os.path.basename(target))
        return

    # generate config.c and Makefile
    builtins.sort()
    with open(config_c_in) as infp, bkfile.open(config_c, 'w') as outfp:
        makeconfig.makeconfig(infp, outfp, builtins)

    cflags = ['$(OPT)']
    cppflags = defines + includes
    libs = [os.path.join(binlib, '$(LDLIBRARY)')]

    somevars = {}
    if os.path.exists(makefile_in):
        makevars = parsesetup.getmakevars(makefile_in)
        for key in makevars:
            somevars[key] = makevars[key]

    somevars['CFLAGS'] = ' '.join(cflags) # override
    somevars['CPPFLAGS'] = ' '.join(cppflags) # override
    files = [base_config_c, base_frozen_c] + \
            files + supp_sources +  addfiles + libs + \
            ['$(MODLIBS)', '$(LIBS)', '$(SYSLIBS)']

    with bkfile.open(makefile, 'w') as outfp:
        makemakefile.makemakefile(outfp, somevars, files, base_target)

    # Done!

    if odir:
        print('Now run "make" in', odir, end=' ')
        print('to build the target:', base_target)
    else:
        print('Now run "make" to build the target:', base_target)
コード例 #7
0
    ],
    'scripts': [
        'shotfactory.py',
        'browsershot.py',
        'ppmoffset.py',
    ],
}

if 'py2exe' in sys.argv:
    import py2exe
    # modulefinder can't handle runtime changes to __path__,
    # but win32com uses them
    import modulefinder
    import win32com
    for path in win32com.__path__[1:]:
        modulefinder.AddPackagePath("win32com", path)
    __import__("win32com.shell")
    m = sys.modules["win32com.shell"]
    for path in m.__path__[1:]:
        modulefinder.AddPackagePath("win32com.shell", path)
    # py2exe configuration
    kwargs['console'] = [{
        'script': 'shotfactory.py',
        'icon_resources': [(1, 'favicon.ico')],
    }]
    kwargs['options'] = {
        'py2exe': {
            'includes':
            ','.join([
                'shotfactory04.gui.windows.msie',
                'shotfactory04.gui.windows.firefox',
コード例 #8
0
ファイル: nodes.py プロジェクト: xxoolm/Ryven
 def update_event(self, inp=-1):
     self.set_output_val(
         0, modulefinder.AddPackagePath(self.input(0), self.input(1)))
コード例 #9
0
def setup_windows(version):
    # Specific definitios for Windows NT-alike installations
    _scripts = []
    _data_files = []
    _packages = [
        'tortoisehg.hgqt', 'tortoisehg.util', 'tortoisehg', 'hgext3rd'
    ]
    extra = {}
    hgextmods = []

    # py2exe needs to be installed to work
    try:
        import py2exe

        # Help py2exe to find win32com.shell
        try:
            import modulefinder
            import win32com
            for p in win32com.__path__[1:]:  # Take the path to win32comext
                modulefinder.AddPackagePath("win32com", p)
            pn = "win32com.shell"
            __import__(pn)
            m = sys.modules[pn]
            for p in m.__path__[1:]:
                modulefinder.AddPackagePath(pn, p)
        except ImportError:
            pass

    except ImportError:
        if '--version' not in sys.argv:
            raise

    # Allow use of environment variables to specify the location of Mercurial
    import modulefinder
    path = os.getenv('MERCURIAL_PATH')
    if path:
        modulefinder.AddPackagePath('mercurial', path)
    path = os.getenv('HGEXT_PATH')
    if path:
        modulefinder.AddPackagePath('hgext', path)
    modulefinder.AddPackagePath('hgext3rd', 'hgext3rd')

    if 'py2exe' in sys.argv:
        import hgext
        hgextdir = os.path.dirname(hgext.__file__)
        hgextmods = set(
            ["hgext." + os.path.splitext(f)[0] for f in os.listdir(hgextdir)])
        # most icons are packed into Qt resource, but .ico files must reside
        # in filesystem so that shell extension can read them
        root = 'icons'
        _data_files.append((root, [
            os.path.join(root, f) for f in os.listdir(root)
            if f.endswith('.ico') or f == 'README.txt'
        ]))

    # for PyQt, see http://www.py2exe.org/index.cgi/Py2exeAndPyQt
    includes = ['sip']

    # Qt4 plugins, see http://stackoverflow.com/questions/2206406/
    def qt4_plugins(subdir, *dlls):
        import PyQt4
        pluginsdir = os.path.join(os.path.dirname(PyQt4.__file__), 'plugins')
        return (subdir, [os.path.join(pluginsdir, subdir, e) for e in dlls])

    def qt5_plugins(subdir, *dlls):
        import PyQt5
        pluginsdir = os.path.join(os.path.dirname(PyQt5.__file__), 'plugins')
        return (subdir, [os.path.join(pluginsdir, subdir, e) for e in dlls])

    from tortoisehg.hgqt.qtcore import QT_API
    if QT_API == 'PyQt4':
        _data_files.append(
            qt4_plugins('imageformats', 'qico4.dll', 'qsvg4.dll'))
    else:
        _data_files.append(qt5_plugins('platforms', 'qwindows.dll'))
        _data_files.append(
            qt5_plugins('imageformats', 'qico.dll', 'qsvg.dll', 'qjpeg.dll',
                        'qgif.dll', 'qicns.dll', 'qtga.dll', 'qtiff.dll',
                        'qwbmp.dll', 'qwebp.dll'))

    # Manually include other modules py2exe can't find by itself.
    if 'hgext.highlight' in hgextmods:
        includes += [
            'pygments.*', 'pygments.lexers.*', 'pygments.formatters.*',
            'pygments.filters.*', 'pygments.styles.*'
        ]
    if 'hgext.patchbomb' in hgextmods:
        includes += ['email.*', 'email.mime.*']

    extra['options'] = {}
    extra['options']['py2exe'] = {
        "skip_archive":
        0,
        # Don't pull in all this MFC stuff used by the makepy UI.
        "excludes": ("pywin,pywin.dialogs,pywin.dialogs.list,setuptools"
                     "setup,distutils"),  # required only for in-place use
        "includes":
        includes,
        "optimize":
        1,
    }
    extra['console'] = [
        {
            'script': 'thg',
            'icon_resources': [(0, 'icons/thg_logo.ico')],
            'description': 'TortoiseHg GUI tools for Mercurial SCM',
            'copyright': thgcopyright,
            'product_version': version,
        },
        {
            'script': 'contrib/hg',
            'icon_resources': [(0, 'icons/hg.ico')],
            'description': 'Mercurial Distributed SCM',
            'copyright': hgcopyright,
            'product_version': version,
        },
        {
            'script': 'win32/docdiff.py',
            'icon_resources': [(0, 'icons/TortoiseMerge.ico')],
            'copyright': thgcopyright,
            'product_version': version,
        },
    ]
    extra['windows'] = [
        {
            'script': 'thg',
            'dest_base': 'thgw',
            'icon_resources': [(0, 'icons/thg_logo.ico')],
            'description': 'TortoiseHg GUI tools for Mercurial SCM',
            'copyright': thgcopyright,
            'product_version': version,
        },
        {
            'script': 'TortoiseHgOverlayServer.py',
            'icon_resources': [(0, 'icons/thg_logo.ico')],
            'description': 'TortoiseHg Overlay Icon Server',
            'copyright': thgcopyright,
            'product_version': version,
        },
    ]
    # put dlls in sub directory so that they won't pollute PATH
    extra['zipfile'] = 'lib/library.zip'

    return _scripts, _packages, _data_files, extra
コード例 #10
0
ファイル: setup.py プロジェクト: zeta1999/breezy
def get_tbzr_py2exe_info(includes, excludes, packages, console_targets,
                         gui_targets, data_files):
    packages.append('tbzrcommands')

    # ModuleFinder can't handle runtime changes to __path__, but
    # win32com uses them.  Hook this in so win32com.shell is found.
    import modulefinder
    import win32com
    import cPickle as pickle
    for p in win32com.__path__[1:]:
        modulefinder.AddPackagePath("win32com", p)
    for extra in ["win32com.shell"]:
        __import__(extra)
        m = sys.modules[extra]
        for p in m.__path__[1:]:
            modulefinder.AddPackagePath(extra, p)

    # TBZR points to the TBZR directory
    tbzr_root = os.environ["TBZR"]

    # Ensure tbreezy itself is on sys.path
    sys.path.append(tbzr_root)

    packages.append("tbreezy")

    # collect up our icons.
    cwd = os.getcwd()
    ico_root = os.path.join(tbzr_root, 'tbreezy', 'resources')
    icos = []  # list of (path_root, relative_ico_path)
    # First always brz's icon and its in the root of the brz tree.
    icos.append(('', 'brz.ico'))
    for root, dirs, files in os.walk(ico_root):
        icos.extend([(ico_root, os.path.join(root, f)[len(ico_root) + 1:])
                     for f in files if f.endswith('.ico')])
    # allocate an icon ID for each file and the full path to the ico
    icon_resources = [(rid, os.path.join(ico_dir, ico_name))
                      for rid, (ico_dir, ico_name) in enumerate(icos)]
    # create a string resource with the mapping.  Might as well save the
    # runtime some effort and write a pickle.
    # Runtime expects unicode objects with forward-slash seps.
    fse = sys.getfilesystemencoding()
    map_items = [(f.replace('\\', '/').decode(fse), rid)
                 for rid, (_, f) in enumerate(icos)]
    ico_map = dict(map_items)
    # Create a new resource type of 'ICON_MAP', and use ID=1
    other_resources = [("ICON_MAP", 1, pickle.dumps(ico_map))]

    excludes.extend("""pywin pywin.dialogs pywin.dialogs.list
                       win32ui crawler.Crawler""".split())

    # tbzrcache executables - a "console" version for debugging and a
    # GUI version that is generally used.
    tbzrcache = dict(
        script=os.path.join(tbzr_root, "scripts", "tbzrcache.py"),
        icon_resources=icon_resources,
        other_resources=other_resources,
    )
    console_targets.append(tbzrcache)

    # Make a windows version which is the same except for the base name.
    tbzrcachew = tbzrcache.copy()
    tbzrcachew["dest_base"] = "tbzrcachew"
    gui_targets.append(tbzrcachew)

    # ditto for the tbzrcommand tool
    tbzrcommand = dict(
        script=os.path.join(tbzr_root, "scripts", "tbzrcommand.py"),
        icon_resources=icon_resources,
        other_resources=other_resources,
    )
    console_targets.append(tbzrcommand)
    tbzrcommandw = tbzrcommand.copy()
    tbzrcommandw["dest_base"] = "tbzrcommandw"
    gui_targets.append(tbzrcommandw)

    # A utility to see python output from both C++ and Python based shell
    # extensions
    tracer = dict(script=os.path.join(tbzr_root, "scripts", "tbzrtrace.py"))
    console_targets.append(tracer)

    # The C++ implemented shell extensions.
    dist_dir = os.path.join(tbzr_root, "shellext", "build")
    data_files.append(('', [os.path.join(dist_dir, 'tbzrshellext_x86.dll')]))
    data_files.append(('', [os.path.join(dist_dir, 'tbzrshellext_x64.dll')]))
コード例 #11
0
ファイル: setup.py プロジェクト: velorientc/git_test7
def setup_windows(version):
    # Specific definitios for Windows NT-alike installations
    _scripts = []
    _data_files = []
    _packages = ['tortoisehg.hgqt', 'tortoisehg.util', 'tortoisehg']
    extra = {}
    hgextmods = []

    # py2exe needs to be installed to work
    try:
        import py2exe

        # Help py2exe to find win32com.shell
        try:
            import modulefinder
            import win32com
            for p in win32com.__path__[1:]: # Take the path to win32comext
                modulefinder.AddPackagePath("win32com", p)
            pn = "win32com.shell"
            __import__(pn)
            m = sys.modules[pn]
            for p in m.__path__[1:]:
                modulefinder.AddPackagePath(pn, p)
        except ImportError:
            pass

    except ImportError:
        if '--version' not in sys.argv:
            raise

    # Allow use of environment variables to specify the location of Mercurial
    import modulefinder
    path = os.getenv('MERCURIAL_PATH')
    if path:
        modulefinder.AddPackagePath('mercurial', path)
    path = os.getenv('HGEXT_PATH')
    if path:
        modulefinder.AddPackagePath('hgext', path)

    if 'py2exe' in sys.argv:
        import hgext
        hgextdir = os.path.dirname(hgext.__file__)
        hgextmods = set(["hgext." + os.path.splitext(f)[0]
                      for f in os.listdir(hgextdir)])
        _data_files = [(root, [os.path.join(root, file_) for file_ in files])
                            for root, dirs, files in os.walk('icons')]

    # for PyQt, see http://www.py2exe.org/index.cgi/Py2exeAndPyQt
    includes = ['sip']

    # Qt4 plugins, see http://stackoverflow.com/questions/2206406/
    def qt4_plugins(subdir, *dlls):
        import PyQt4
        pluginsdir = join(os.path.dirname(PyQt4.__file__), 'plugins')
        return (subdir, [join(pluginsdir, subdir, e) for e in dlls])
    _data_files.append(qt4_plugins('imageformats', 'qico4.dll', 'qsvg4.dll'))

    # Manually include other modules py2exe can't find by itself.
    if 'hgext.highlight' in hgextmods:
        includes += ['pygments.*', 'pygments.lexers.*', 'pygments.formatters.*',
                     'pygments.filters.*', 'pygments.styles.*']
    if 'hgext.patchbomb' in hgextmods:
        includes += ['email.*', 'email.mime.*']

    extra['options'] = {
       "py2exe" : {
           "skip_archive" : 0,

           # Don't pull in all this MFC stuff used by the makepy UI.
           "excludes" : "pywin,pywin.dialogs,pywin.dialogs.list"
                        ",setup,distutils",  # required only for in-place use
           "includes" : includes,
           "optimize" : 1
       }
    }
    shutil.copyfile('thg', 'thgw')
    extra['console'] = [
            {'script':'thg',
             'icon_resources':[(0,'icons/thg_logo.ico')],
             'description':'TortoiseHg GUI tools for Mercurial SCM',
             'copyright':thgcopyright,
             'product_version':version},
            {'script':'contrib/hg',
             'icon_resources':[(0,'icons/hg.ico')],
             'description':'Mercurial Distributed SCM',
             'copyright':hgcopyright,
             'product_version':version},
            {'script':'win32/docdiff.py',
             'icon_resources':[(0,'icons/TortoiseMerge.ico')],
             'copyright':thgcopyright,
             'product_version':version}
            ]
    extra['windows'] = [
            {'script':'thgw',
             'icon_resources':[(0,'icons/thg_logo.ico')],
             'description':'TortoiseHg GUI tools for Mercurial SCM',
             'copyright':thgcopyright,
             'product_version':version},
            {'script':'TortoiseHgOverlayServer.py',
             'icon_resources':[(0,'icons/thg_logo.ico')],
             'description':'TortoiseHg Overlay Icon Server',
             'copyright':thgcopyright,
             'product_version':version}
            ]

    return _scripts, _packages, _data_files, extra
コード例 #12
0
import sys
if sys.platform == "win32":
    from distutils.core import setup
    import py2exe
    import glob
    import modulefinder
    import win32com.client
    is_debug = False

    #this block code used to add win32com.shell and win32com.shellcon module to library.zip
    ###******************************************###########
    for p in win32com.__path__[1:]:
        modulefinder.AddPackagePath('win32com', p)
    for extra in ['win32com.taskscheduler']:
        __import__(extra)
        m = sys.modules[extra]
        for p in m.__path__[1:]:
            modulefinder.AddPackagePath(extra, p)
    ###******************************************###########

    for i, argv in enumerate(sys.argv):
        if argv == "debug" or argv == "-debug":
            is_debug = True
            del sys.argv[i]

    if is_debug:
        print 'executable run in console mode'
        setup(console=[{"script":"NovalIDE.py","icon_resources":[(1, u"noval.ico")]}],
              options = { "py2exe":{"dll_excludes":["MSVCP90.dll"],"packages": ['wx.lib.pubsub']}},
                data_files=[("noval/tool/bmp_source", glob.glob("noval/tool/bmp_source/*.ico") + glob.glob("noval/tool/bmp_source/*.jpg") \
                             + glob.glob("noval/tool/bmp_source/*.png") + glob.glob("noval/tool/bmp_source/*.gif")),
コード例 #13
0
ファイル: modulefinder_test.py プロジェクト: zosimos/pyston
# Make sure we can at least support people who want to register themselves with modulefinder,
# even if we don't actually support using modulefinder to find modules.

import modulefinder
modulefinder.AddPackagePath("foo", "bar")
コード例 #14
0
try:
    import pkg_resources
    pkg_resources.declare_namespace(__name__)
except ImportError:
    # don't prevent use of paste if pkg_resources isn't installed
    from pkgutil import extend_path
    __path__ = extend_path(__path__, __name__) 

try:
    import modulefinder
except ImportError:
    pass
else:
    for p in __path__:
        modulefinder.AddPackagePath(__name__, p)
コード例 #15
0
    }
}
goptions[option_name].update(extra_options)
print goptions

pgl_dir = 'C:/Python27/Lib/site-packages/VPlants.PlantGL-2.20.0-py2.7-win32.egg/'
libdirs = pj(pgl_dir, 'lib')
pgl_py = pj(pgl_dir, 'openalea/plantgl')
#libdirs = pj('../vplants/PlantGL',build_prefix,'lib')

import openalea.plantgl as pgl
pgl_pys = pgl.__path__

import modulefinder
for p in pgl.__path__:
    modulefinder.AddPackagePath('openalea', abspath(pj(p, '..')))

import openalea.mtg as mtg
for p in mtg.__path__:
    modulefinder.AddPackagePath('openalea', abspath(pj(p, '..')))

import openalea.vpltk as mtg
for p in mtg.__path__:
    modulefinder.AddPackagePath('openalea', abspath(pj(p, '..')))

import openalea
for p in openalea.__path__:
    modulefinder.AddPackagePath('openalea', p)

pgl_py = pgl_pys[0]
if len(pgl_pys) > 1:
コード例 #16
0
ファイル: setup_all.py プロジェクト: clamwin/clamwin
sys.path.append(sb_top_dir)
sys.path.append(os.path.join(sb_top_dir, "py"))
sys.path.append(os.path.join(sb_top_dir, "../addons/pyc/build/lib.win32-2.3"))
sys.path.append(
    os.path.join(sb_top_dir, "../clamav-release/contrib/msvc/Release/Win32"))
#sys.path.append(os.path.join(sb_top_dir,"Setup/Dependencies/pthread"))

import version

# ModuleFinder can't handle runtime changes to __path__, but win32com uses them,
# particularly for people who build from sources.  Hook this in.
try:
    import modulefinder
    import win32com
    for p in win32com.__path__[1:]:
        modulefinder.AddPackagePath("win32com", p)
    for extra in ["win32com.shell", "win32com.mapi"]:
        __import__(extra)
        m = sys.modules[extra]
        for p in m.__path__[1:]:
            modulefinder.AddPackagePath(extra, p)
except ImportError:
    # no build path setup, no worries.
    pass

from distutils.core import setup
import py2exe

ver = version.clamwin_version.replace('0:', '')
while ver.count(".") < 3:
    ver = ver + ".0"
コード例 #17
0
ファイル: setup.py プロジェクト: jianzhou722/schism_svn_tags
import sys

try:
    import modulefinder
    #import win32com
    #for p in win32com.__path__[1:]:
    #    modulefinder.AddPackagePath("win32com", p)
    for extra in ["win32com", "win32com.shell"]:  #,"win32com.mapi"
        __import__(extra)
        m = sys.modules[extra]
        for p in m.__path__[1:]:
            modulefinder.AddPackagePath(extra, p)
except ImportError:
    # no build path setup, no worries.
    pass

from distutils.core import setup
import py2exe

from distutils.filelist import findall
import os, os.path
import matplotlib


def adddir(path, localtarget=None):
    if localtarget == None: localtarget = path
    for f in findall(path):
        localname = os.path.join(localtarget, f[len(path) + 1:])
        if 'CVS' in localname: continue
        own_data_files.append((os.path.dirname(localname), [f]))