Example #1
0
def package(*args, **kwds):
    try:
        import argparse
    except ImportError:
        import imp

        argparse = imp.load_source("argparse", "lib-python/2.7/argparse.py")
    if sys.platform == "win32":
        pypy_exe = "pypy.exe"
    else:
        pypy_exe = "pypy"
    parser = argparse.ArgumentParser()
    args = list(args)
    if args:
        args[0] = str(args[0])
    else:
        args.append("--help")
    for key, module in sorted(cffi_build_scripts.items()):
        if module is not None:
            parser.add_argument(
                "--without-" + key,
                dest="no_" + key,
                action="store_true",
                help="do not build and package the %r cffi module" % (key,),
            )
    parser.add_argument(
        "--without-cffi", dest="no_cffi", action="store_true", help="skip building *all* the cffi modules listed above"
    )
    parser.add_argument(
        "--nostrip", dest="nostrip", action="store_true", help="do not strip the exe, making it ~10MB larger"
    )
    parser.add_argument(
        "--rename_pypy_c", dest="pypy_c", type=str, default=pypy_exe, help='target executable name, defaults to "pypy"'
    )
    parser.add_argument("--archive-name", dest="name", type=str, default="", help="pypy-VER-PLATFORM")
    parser.add_argument("--builddir", type=str, default="", help="tmp dir for packaging")
    parser.add_argument("--targetdir", type=str, default="", help="destination dir for archive")
    parser.add_argument("--override_pypy_c", type=str, default="", help="use as pypy exe instead of pypy/goal/pypy-c")
    options = parser.parse_args(args)

    if os.environ.has_key("PYPY_PACKAGE_NOSTRIP"):
        options.nostrip = True
    if os.environ.has_key("PYPY_PACKAGE_WITHOUTTK"):
        options.no_tk = True
    if not options.builddir:
        # The import actually creates the udir directory
        from rpython.tool.udir import udir

        options.builddir = udir.ensure("build", dir=True)
    else:
        # if a user provides a path it must be converted to a local file system path
        # otherwise ensure in create_package will fail
        options.builddir = py.path.local(options.builddir)
    assert "/" not in options.pypy_c
    return create_package(basedir, options, **kwds)
Example #2
0
def package(*args, **kwds):
    try:
        import argparse
    except ImportError:
        import imp
        argparse = imp.load_source('argparse', 'lib-python/2.7/argparse.py')
    if sys.platform == 'win32':
        pypy_exe = 'pypy.exe'
    else:
        pypy_exe = 'pypy'
    parser = argparse.ArgumentParser()
    args = list(args)
    if args:
        args[0] = str(args[0])
    else:
        args.append('--help')
    for key, module in sorted(cffi_build_scripts.items()):
        if module is not None:
            parser.add_argument('--without-' + key,
                    dest='no_' + key,
                    action='store_true',
                    help='do not build and package the %r cffi module' % (key,))
    parser.add_argument('--without-cffi', dest='no_cffi', action='store_true',
        help='skip building *all* the cffi modules listed above')
    parser.add_argument('--no-keep-debug', dest='keep_debug',
                        action='store_false', help='do not keep debug symbols')
    parser.add_argument('--rename_pypy_c', dest='pypy_c', type=str, default=pypy_exe,
        help='target executable name, defaults to "pypy"')
    parser.add_argument('--archive-name', dest='name', type=str, default='',
        help='pypy-VER-PLATFORM')
    parser.add_argument('--builddir', type=str, default='',
        help='tmp dir for packaging')
    parser.add_argument('--targetdir', type=str, default='',
        help='destination dir for archive')
    parser.add_argument('--override_pypy_c', type=str, default='',
        help='use as pypy exe instead of pypy/goal/pypy-c')
    options = parser.parse_args(args)

    if os.environ.has_key("PYPY_PACKAGE_NOKEEPDEBUG"):
        options.keep_debug = False
    if os.environ.has_key("PYPY_PACKAGE_WITHOUTTK"):
        options.no_tk = True
    if not options.builddir:
        # The import actually creates the udir directory
        from rpython.tool.udir import udir
        options.builddir = udir.ensure("build", dir=True)
    else:
        # if a user provides a path it must be converted to a local file system path
        # otherwise ensure in create_package will fail
        options.builddir = py.path.local(options.builddir)
    assert '/' not in options.pypy_c
    return create_package(basedir, options, **kwds)
Example #3
0
def package(*args, **kwds):
    import argparse

    class NegateAction(argparse.Action):
        def __init__(self, option_strings, dest, nargs=0, **kwargs):
            super(NegateAction, self).__init__(option_strings, dest, nargs,
                                               **kwargs)

        def __call__(self, parser, ns, values, option):
            setattr(ns, self.dest, option[2:4] != 'no')

    if sys.platform == 'win32':
        pypy_exe = 'pypy.exe'
    else:
        pypy_exe = 'pypy'
    parser = argparse.ArgumentParser()
    args = list(args)
    if args:
        args[0] = str(args[0])
    else:
        args.append('--help')
    for key, module in sorted(cffi_build_scripts.items()):
        if module is not None:
            parser.add_argument(
                '--without-' + key,
                dest='no_' + key,
                action='store_true',
                help='do not build and package the %r cffi module' % (key, ))
    parser.add_argument(
        '--without-cffi',
        dest='no_cffi',
        action='store_true',
        help='skip building *all* the cffi modules listed above')
    parser.add_argument('--no-keep-debug',
                        dest='keep_debug',
                        action='store_false',
                        help='do not keep debug symbols')
    parser.add_argument('--rename_pypy_c',
                        dest='pypy_c',
                        type=str,
                        default=pypy_exe,
                        help='target executable name, defaults to "%s"' %
                        pypy_exe)
    parser.add_argument('--archive-name',
                        dest='name',
                        type=str,
                        default='',
                        help='pypy-VER-PLATFORM')
    parser.add_argument('--builddir',
                        type=str,
                        default='',
                        help='tmp dir for packaging')
    parser.add_argument('--targetdir',
                        type=str,
                        default='',
                        help='destination dir for archive')
    parser.add_argument('--override_pypy_c',
                        type=str,
                        default='',
                        help='use as pypy3 exe instead of pypy/goal/pypy3-c')
    parser.add_argument('--embedded-dependencies',
                        '--no-embedded-dependencies',
                        dest='embed_dependencies',
                        action=NegateAction,
                        default=(sys.platform == 'darwin'),
                        help='whether to embed dependencies for distribution '
                        '(default on OS X)')
    options = parser.parse_args(args)

    if os.environ.has_key("PYPY_PACKAGE_NOKEEPDEBUG"):
        options.keep_debug = False
    if os.environ.has_key("PYPY_PACKAGE_WITHOUTTK"):
        options.no_tk = True
    if os.environ.has_key("PYPY_EMBED_DEPENDENCIES"):
        options.embed_dependencies = True
    elif os.environ.has_key("PYPY_NO_EMBED_DEPENDENCIES"):
        options.embed_dependencies = False
    if not options.builddir:
        # The import actually creates the udir directory
        from rpython.tool.udir import udir
        options.builddir = udir.ensure("build", dir=True)
    else:
        # if a user provides a path it must be converted to a local file system path
        # otherwise ensure in create_package will fail
        options.builddir = py.path.local(options.builddir)
    assert '/' not in options.pypy_c
    return create_package(basedir, options, **kwds)
Example #4
0
def package(*args, **kwds):
    try:
        import argparse
    except ImportError:
        import imp
        argparse = imp.load_source('argparse', 'lib-python/2.7/argparse.py')
    if sys.platform == 'win32':
        pypy_exe = 'pypy.exe'
    else:
        pypy_exe = 'pypy'
    parser = argparse.ArgumentParser()
    args = list(args)
    if args:
        args[0] = str(args[0])
    else:
        args.append('--help')
    for key, module in sorted(cffi_build_scripts.items()):
        if module is not None:
            parser.add_argument(
                '--without-' + key,
                dest='no_' + key,
                action='store_true',
                help='do not build and package the %r cffi module' % (key, ))
    parser.add_argument(
        '--without-cffi',
        dest='no_cffi',
        action='store_true',
        help='skip building *all* the cffi modules listed above')
    parser.add_argument('--nostrip',
                        dest='nostrip',
                        action='store_true',
                        help='do not strip the exe, making it ~10MB larger')
    parser.add_argument('--rename_pypy_c',
                        dest='pypy_c',
                        type=str,
                        default=pypy_exe,
                        help='target executable name, defaults to "pypy"')
    parser.add_argument('--archive-name',
                        dest='name',
                        type=str,
                        default='',
                        help='pypy-VER-PLATFORM')
    parser.add_argument('--builddir',
                        type=str,
                        default='',
                        help='tmp dir for packaging')
    parser.add_argument('--targetdir',
                        type=str,
                        default='',
                        help='destination dir for archive')
    parser.add_argument('--override_pypy_c',
                        type=str,
                        default='',
                        help='use as pypy exe instead of pypy/goal/pypy-c')
    # Positional arguments, for backward compatability with buldbots
    parser.add_argument(
        'extra_args',
        help='optional interface to positional arguments',
        nargs=argparse.REMAINDER,
        metavar='[archive-name] [rename_pypy_c] [targetdir] [override_pypy_c]',
    )
    options = parser.parse_args(args)

    # Handle positional arguments, choke if both methods are used
    for i, target, default in ([1, 'name', ''], [2, 'pypy_c', pypy_exe],
                               [3, 'targetdir',
                                ''], [4, 'override_pypy_c', '']):
        if len(options.extra_args) > i:
            if getattr(options, target) != default:
                print 'positional argument', i, target, 'already has value', getattr(
                    options, target)
                parser.print_help()
                return
            setattr(options, target, options.extra_args[i])
    if os.environ.has_key("PYPY_PACKAGE_NOSTRIP"):
        options.nostrip = True

    if os.environ.has_key("PYPY_PACKAGE_WITHOUTTK"):
        options.tk = True
    if not options.builddir:
        # The import actually creates the udir directory
        from rpython.tool.udir import udir
        options.builddir = udir.ensure("build", dir=True)
    else:
        # if a user provides a path it must be converted to a local file system path
        # otherwise ensure in create_package will fail
        options.builddir = py.path.local(options.builddir)
    assert '/' not in options.pypy_c
    return create_package(basedir, options, **kwds)
Example #5
0
def package(*args, **kwds):
    try:
        import argparse
    except ImportError:
        import imp
        argparse = imp.load_source('argparse', 'lib-python/2.7/argparse.py')
    if sys.platform == 'win32':
        pypy_exe = 'pypy.exe'
    else:
        pypy_exe = 'pypy'
    parser = argparse.ArgumentParser()
    args = list(args)
    if args:
        args[0] = str(args[0])
    else:
        args.append('--help')
    for key, module in sorted(cffi_build_scripts.items()):
        if module is not None:
            parser.add_argument('--without-' + key,
                    dest='no_' + key,
                    action='store_true',
                    help='do not build and package the %r cffi module' % (key,))
    parser.add_argument('--without-cffi', dest='no_cffi', action='store_true',
        help='skip building *all* the cffi modules listed above')
    parser.add_argument('--nostrip', dest='nostrip', action='store_true',
        help='do not strip the exe, making it ~10MB larger')
    parser.add_argument('--rename_pypy_c', dest='pypy_c', type=str, default=pypy_exe,
        help='target executable name, defaults to "pypy"')
    parser.add_argument('--archive-name', dest='name', type=str, default='',
        help='pypy-VER-PLATFORM')
    parser.add_argument('--builddir', type=str, default='',
        help='tmp dir for packaging')
    parser.add_argument('--targetdir', type=str, default='',
        help='destination dir for archive')
    parser.add_argument('--override_pypy_c', type=str, default='',
        help='use as pypy exe instead of pypy/goal/pypy-c')
    # Positional arguments, for backward compatability with buldbots
    parser.add_argument('extra_args', help='optional interface to positional arguments', nargs=argparse.REMAINDER,
        metavar='[archive-name] [rename_pypy_c] [targetdir] [override_pypy_c]',
        )
    options = parser.parse_args(args)

    # Handle positional arguments, choke if both methods are used
    for i,target, default in ([1, 'name', ''], [2, 'pypy_c', pypy_exe],
                              [3, 'targetdir', ''], [4,'override_pypy_c', '']):
        if len(options.extra_args)>i:
            if getattr(options, target) != default:
                print 'positional argument',i,target,'already has value',getattr(options, target)
                parser.print_help()
                return
            setattr(options, target, options.extra_args[i])
    if os.environ.has_key("PYPY_PACKAGE_NOSTRIP"):
        options.nostrip = True

    if os.environ.has_key("PYPY_PACKAGE_WITHOUTTK"):
        options.tk = True
    if not options.builddir:
        # The import actually creates the udir directory
        from rpython.tool.udir import udir
        options.builddir = udir.ensure("build", dir=True)
    else:
        # if a user provides a path it must be converted to a local file system path
        # otherwise ensure in create_package will fail
        options.builddir = py.path.local(options.builddir)
    assert '/' not in options.pypy_c
    return create_package(basedir, options, **kwds)