コード例 #1
0
ファイル: __init__.py プロジェクト: shedskin/shedskin
def parse_command_line_options():
    gx = GlobalInfo()
    gx.terminal = blessings.Terminal()

    # --- command-line options
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'vbchef:wad:m:rolspxngL:', ['help', 'extmod', 'nobounds', 'nowrap', 'flags=', 'debug=', 'makefile=', 'random', 'noassert', 'long', 'msvc', 'ann', 'strhash', 'pypy', 'traceback', 'silent', 'nogcwarns', 'lib'])
    except getopt.GetoptError:
        usage()

    logging_level = logging.INFO
    ifa_logging_level = logging.INFO

    for opt, value in opts:
        if opt in ['-h', '--help']:
            usage()
        if opt in ['-b', '--nobounds']:
            gx.bounds_checking = False
        if opt in ['-e', '--extmod']:
            gx.extension_module = True
        if opt in ['-a', '--ann']:
            gx.annotation = True
        if opt in ['-d', '--debug']:
            logging_level = logging.DEBUG
            if int(value) == 3:
                ifa_logging_level = logging.DEBUG
        if opt in ['-l', '--long']:
            gx.longlong = True
        if opt in ['-g', '--nogcwarns']:
            gx.gcwarns = False
        if opt in ['-w', '--nowrap']:
            gx.wrap_around_check = False
        if opt in ['-r', '--random']:
            gx.fast_random = True
        if opt in ['-o', '--noassert']:
            gx.assertions = False
        if opt in ['-p', '--pypy']:
            gx.pypy = True
        if opt in ['-m', '--makefile']:
            gx.makefile_name = value
        if opt in ['-n', '--silent']:
            logging_level = logging.WARNING
        if opt in ['-s', '--strhash']:
            gx.fast_hash = True
        if opt in ['-v', '--msvc']:
            gx.msvc = True
        if opt in ['-x', '--traceback']:
            gx.backtrace = True
        if opt in ['-L', '--lib']:
            gx.libdirs = [value] + gx.libdirs
        if opt in ['-f', '--flags']:
            if not os.path.isfile(value):
                logging.error("no such file: '%s'", value)
                sys.exit(1)
            gx.flags = value

    # silent -> WARNING only, debug -> DEBUG, default -> INFO
    console = logging.StreamHandler(stream=sys.stdout)
    console.setFormatter(ShedskinFormatter(gx))
    root = logging.getLogger('')
    root.addHandler(console)
    root.setLevel(logging_level)
    # debug=3 -> IFA (iterative flow analysis) logging enabled.
    logging.getLogger('infer.ifa').setLevel(ifa_logging_level)

    logging.info('*** SHED SKIN Python-to-C++ Compiler 0.9.4 *** - ')
    logging.info('Copyright 2005-2019 Mark Dufour and contributors; License GNU GPL version 3 (See LICENSE)')
    logging.info('')

    # --- some checks
    major, minor = sys.version_info[:2]
    if (major, minor) not in [(2, 4), (2, 5), (2, 6), (2, 7)]:
        logging.error('Shed Skin is not compatible with this version of Python')
        sys.exit(1)
    if sys.platform == 'win32' and os.path.isdir('c:/mingw'):
        logging.error('please rename or remove c:/mingw, as it conflicts with Shed Skin')
        sys.exit()
    if sys.platform == 'win32' and struct.calcsize('P') == 8 and gx.extension_module:
        logging.warning('64-bit python may not come with necessary file to build extension module')

    # --- argument
    if len(args) != 1:
        usage()
    name = args[0]
    if not name.endswith('.py'):
        name += '.py'
    if not os.path.isfile(name):
        logging.error("no such file: '%s'", name)
        sys.exit(1)
    main_module_name = os.path.splitext(name)[0]

    return gx, main_module_name
コード例 #2
0
ファイル: __init__.py プロジェクト: The-Mad-Pirate/shedskin
def parse_command_line_options():
    gx = GlobalInfo()
    gx.terminal = blessings.Terminal()

    # --- command-line options
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'vbchef:wad:m:rolspxngL:', [
            'help', 'extmod', 'nobounds', 'nowrap', 'flags=', 'debug=',
            'makefile=', 'random', 'noassert', 'long', 'msvc', 'ann',
            'strhash', 'pypy', 'traceback', 'silent', 'nogcwarns', 'lib'
        ])
    except getopt.GetoptError:
        usage()

    logging_level = logging.INFO
    ifa_logging_level = logging.INFO

    for opt, value in opts:
        if opt in ['-h', '--help']:
            usage()
        if opt in ['-b', '--nobounds']:
            gx.bounds_checking = False
        if opt in ['-e', '--extmod']:
            gx.extension_module = True
        if opt in ['-a', '--ann']:
            gx.annotation = True
        if opt in ['-d', '--debug']:
            logging_level = logging.DEBUG
            if int(value) == 3:
                ifa_logging_level = logging.DEBUG
        if opt in ['-l', '--long']:
            gx.longlong = True
        if opt in ['-g', '--nogcwarns']:
            gx.gcwarns = False
        if opt in ['-w', '--nowrap']:
            gx.wrap_around_check = False
        if opt in ['-r', '--random']:
            gx.fast_random = True
        if opt in ['-o', '--noassert']:
            gx.assertions = False
        if opt in ['-p', '--pypy']:
            gx.pypy = True
        if opt in ['-m', '--makefile']:
            gx.makefile_name = value
        if opt in ['-n', '--silent']:
            logging_level = logging.WARNING
        if opt in ['-s', '--strhash']:
            gx.fast_hash = True
        if opt in ['-v', '--msvc']:
            gx.msvc = True
        if opt in ['-x', '--traceback']:
            gx.backtrace = True
        if opt in ['-L', '--lib']:
            gx.libdirs = [value] + gx.libdirs
        if opt in ['-f', '--flags']:
            if not os.path.isfile(value):
                logging.error("no such file: '%s'", value)
                sys.exit(1)
            gx.flags = value

    # silent -> WARNING only, debug -> DEBUG, default -> INFO
    console = logging.StreamHandler(stream=sys.stdout)
    console.setFormatter(ShedskinFormatter(gx))
    root = logging.getLogger('')
    root.addHandler(console)
    root.setLevel(logging_level)
    # debug=3 -> IFA (iterative flow analysis) logging enabled.
    logging.getLogger('infer.ifa').setLevel(ifa_logging_level)

    logging.info('*** SHED SKIN Python-to-C++ Compiler 0.9.4 *** - ')
    logging.info(
        'Copyright 2005-2019 Mark Dufour and contributors; License GNU GPL version 3 (See LICENSE)'
    )
    logging.info('')

    # --- some checks
    major, minor = sys.version_info[:2]
    if (major, minor) not in [(2, 4), (2, 5), (2, 6), (2, 7)]:
        logging.error(
            'Shed Skin is not compatible with this version of Python')
        sys.exit(1)
    if sys.platform == 'win32' and os.path.isdir('c:/mingw'):
        logging.error(
            'please rename or remove c:/mingw, as it conflicts with Shed Skin')
        sys.exit()
    if sys.platform == 'win32' and struct.calcsize(
            'P') == 8 and gx.extension_module:
        logging.warning(
            '64-bit python may not come with necessary file to build extension module'
        )

    # --- argument
    if len(args) != 1:
        usage()
    name = args[0]
    if not name.endswith('.py'):
        name += '.py'
    if not os.path.isfile(name):
        logging.error("no such file: '%s'", name)
        sys.exit(1)
    main_module_name = os.path.splitext(name)[0]

    return gx, main_module_name
コード例 #3
0
def parse_command_line_options():
    gx = GlobalInfo()
    # --- command-line options
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'vbchef:wad:m:rolspxngL:', ['help', 'extmod', 'nobounds', 'nowrap', 'flags=', 'debug=', 'makefile=', 'random', 'noassert', 'long', 'msvc', 'ann', 'strhash', 'pypy', 'traceback', 'silent', 'nogcwarns', 'lib'])
    except getopt.GetoptError:
        usage()

    for opt, value in opts:
        if opt in ['-h', '--help']:
            usage()
        if opt in ['-b', '--nobounds']:
            gx.bounds_checking = False
        if opt in ['-e', '--extmod']:
            gx.extension_module = True
        if opt in ['-a', '--ann']:
            gx.annotation = True
        if opt in ['-d', '--debug']:
            gx.debug_level = int(value)
        if opt in ['-l', '--long']:
            gx.longlong = True
        if opt in ['-g', '--nogcwarns']:
            gx.gcwarns = False
        if opt in ['-w', '--nowrap']:
            gx.wrap_around_check = False
        if opt in ['-r', '--random']:
            gx.fast_random = True
        if opt in ['-o', '--noassert']:
            gx.assertions = False
        if opt in ['-p', '--pypy']:
            gx.pypy = True
        if opt in ['-m', '--makefile']:
            gx.makefile_name = value
        if opt in ['-n', '--silent']:
            gx.silent = True
        if opt in ['-s', '--strhash']:
            gx.fast_hash = True
        if opt in ['-v', '--msvc']:
            gx.msvc = True
        if opt in ['-x', '--traceback']:
            gx.backtrace = True
        if opt in ['-L', '--lib']:
            gx.libdirs = [value] + gx.libdirs
        if opt in ['-f', '--flags']:
            if not os.path.isfile(value):
                print "*ERROR* no such file: '%s'" % value
                sys.exit(1)
            gx.flags = value

    if not gx.silent:
        print '*** SHED SKIN Python-to-C++ Compiler 0.9.4 ***'
        print 'Copyright 2005-2011 Mark Dufour; License GNU GPL version 3 (See LICENSE)'
        print

    # --- some checks
    major, minor = sys.version_info[:2]
    if (major, minor) not in [(2, 4), (2, 5), (2, 6), (2, 7)]:
        print '*ERROR* Shed Skin is not compatible with this version of Python'
        sys.exit(1)
    if sys.platform == 'win32' and os.path.isdir('c:/mingw'):
        print '*ERROR* please rename or remove c:/mingw, as it conflicts with Shed Skin'
        sys.exit()
    if sys.platform == 'win32' and struct.calcsize('P') == 8 and gx.extension_module:
        print '*WARNING* 64-bit python may not come with necessary file to build extension module'

    # --- argument
    if len(args) != 1:
        usage()
    name = args[0]
    if not name.endswith('.py'):
        name += '.py'
    if not os.path.isfile(name):
        print "*ERROR* no such file: '%s'" % name
        sys.exit(1)
    main_module_name = os.path.splitext(name)[0]

    return gx, main_module_name