<commit_before>#!/usr/bin/env python

# Copyright (c) 2001, MetaSlash Inc.  All rights reserved.

"""
Setup a lot of info about Python builtin types, functions, methods, etc.
"""

import types
import sys

from pychecker import utils
from pychecker import Stack
from pychecker import Warning

BOOL = types.IntType
#                    name   (type,  args: min, max, kwArgs?
GLOBAL_FUNC_INFO = { '__import__': (types.ModuleType, 1, 4),
                     'abs': (Stack.TYPE_UNKNOWN, 1, 1),
                     'apply': (Stack.TYPE_UNKNOWN, 2, 3),
                     'buffer': (types.BufferType, 1, 3),
                     'callable': (BOOL, 1, 1),
                     'chr': (types.StringType, 1, 1),
                     'cmp': (int, 2, 2),
                     'coerce': ([ types.NoneType, types.TupleType ], 2, 2),
                     'compile': (types.CodeType, 3, 3),
                     'complex': (types.ComplexType, 1, 2),
                     'delattr': (types.NoneType, 2, 2),
                     'dir': (types.ListType, 0, 1),
                     'divmod': (types.TupleType, 2, 2),
                     'eval': (Stack.TYPE_UNKNOWN, 1, 3),
                     'execfile': (types.NoneType, 1, 3),
                     'filter': (types.ListType, 2, 2),
                     'float': (types.FloatType, 1, 1),
                     'getattr': (Stack.TYPE_UNKNOWN, 2, 3),
                     'globals': (types.DictType, 0, 0),
                     'hasattr': (BOOL, 2, 2),
                     'hash': (types.IntType, 1, 1),
                     'hex': (types.StringType, 1, 1),
                     'id': (types.IntType, 1, 1),
                     'input': (Stack.TYPE_UNKNOWN, 0, 1),
                     'int': (types.IntType, 1, 2),
                     'intern': (types.StringType, 1, 1),
                     'isinstance': (BOOL, 2, 2),
                     'issubclass': (BOOL, 2, 2),
                     'len': (types.IntType, 1, 1),
                     'list': (types.ListType, 1, 1),
                     'locals': (types.DictType, 0, 0),
                     'long': (types.LongType, 1, 2),
                     'map': (types.ListType, 2, None),
                     'max': (Stack.TYPE_UNKNOWN, 1, None),
                     'min': (Stack.TYPE_UNKNOWN, 1, None),
                     'oct': (types.StringType, 1, 1),
                     'open': (types.FileType, 1, 3),
                     'ord': (types.IntType, 1, 1),
                     'pow': (Stack.TYPE_UNKNOWN, 2, 3),
                     'range': (types.ListType, 1, 3),
                     'raw_input': (types.StringType, 0, 1),
                     'reduce': (Stack.TYPE_UNKNOWN, 2, 3),
                     'reload': (types.ModuleType, 1, 1),
                     'repr': (types.StringType, 1, 1),
                     'round': (types.FloatType, 1, 2),
                     'setattr': (types.NoneType, 3, 3),
                     'slice': (types.SliceType, 1, 3),
                     'str': (types.StringType, 1, 1),
                     'tuple': (types.TupleType, 1, 1),
                     'type': (types.TypeType, 1, 1),
                     'vars': (types.DictType, 0, 1),
                     'xrange': (types.ListType, 1, 3),
                   }

if utils.pythonVersion() >= utils.PYTHON_2_2 :
    GLOBAL_FUNC_INFO['compile'] = (types.CodeType, 3, 5)
    GLOBAL_FUNC_INFO['dict'] = (types.DictType, 0, 1)
    GLOBAL_FUNC_INFO['int'] = (types.IntType, 0, 2)
    GLOBAL_FUNC_INFO['list'] = (types.ListType, 0, 1)
    GLOBAL_FUNC_INFO['long'] = (types.LongType, 0, 2)
    GLOBAL_FUNC_INFO['str'] = (types.StringType, 0, 1)
    GLOBAL_FUNC_INFO['type'] = (types.TypeType, 1, 3)     # FIXME: not 2 args
    GLOBAL_FUNC_INFO['tuple'] = (types.TupleType, 0, 1)

    GLOBAL_FUNC_INFO['classmethod'] = (types.MethodType, 1, 1)
    GLOBAL_FUNC_INFO['iter'] = (Stack.TYPE_UNKNOWN, 1, 2)
    GLOBAL_FUNC_INFO['property'] = (Stack.TYPE_UNKNOWN, 0, 4)
    GLOBAL_FUNC_INFO['super'] = (Stack.TYPE_UNKNOWN, 1, 2)
    GLOBAL_FUNC_INFO['staticmethod'] = (types.MethodType, 1, 1)

if hasattr(types, 'UnicodeType') :
    GLOBAL_FUNC_INFO['unichr'] = (types.UnicodeType, 1, 1)
    GLOBAL_FUNC_INFO['unicode'] = (types.UnicodeType, 1, 3)

if globals().has_key('zip') :
    GLOBAL_FUNC_INFO['zip'] = (types.ListType, 1, None)

_STRING_METHODS = { 'capitalize': (types.StringType, 0, 0),
                    'center': (types.StringType, 1, 1),
                    'count': (types.IntType, 1, 1),
                    'encode': (types.StringType, 0, 2),
                    'endswith': (BOOL, 1, 3),
                    'expandtabs': (types.StringType, 0, 1),
                    'find': (types.IntType, 1, 3),
                    'index': (types.IntType, 1, 3),
                    'isalnum': (BOOL, 0, 0),
                    'isalpha': (BOOL, 0, 0),
                    'isdigit': (BOOL, 0, 0),
                    'islower': (BOOL, 0, 0),
                    'isspace': (BOOL, 0, 0),
                    'istitle': (BOOL, 0, 0),
                    'isupper': (BOOL, 0, 0),
                    'join': (types.StringType, 1, 1),
                    'ljust': (types.StringType, 1, 1),
                    'lower': (types.StringType, 0, 0),
                    'lstrip': (types.StringType, 0, 0),
                    'replace': (types.StringType, 2, 3),
                    'rfind': (types.IntType, 1, 3),
                    'rindex': (types.IntType, 1, 3),
                    'rjust': (types.StringType, 1, 1),
                    'rstrip': (types.StringType, 0, 0),
                    'split': (types.ListType, 0, 2),
                    'splitlines': (types.ListType, 0, 1),
                    'startswith': (BOOL, 1, 3),
                    'strip': (types.StringType, 0, 0),
                    'swapcase': (types.StringType, 0, 0),
                    'title': (types.StringType, 0, 0),
                    'translate': (types.StringType, 1, 2),
                    'upper': (types.StringType, 0, 0),
                  }

if utils.pythonVersion() >= utils.PYTHON_2_2 :
    _STRING_METHODS['decode'] = (types.UnicodeType, 0, 2)

BUILTIN_METHODS = { types.DictType :
                    { 'clear': (types.NoneType, 0, 0),
                      'copy': (types.DictType, 0, 0),
                      'get': (Stack.TYPE_UNKNOWN, 1, 2),
                      'has_key': (BOOL, 1, 1),
                      'items': (types.ListType, 0, 0),
                      'keys': (types.ListType, 0, 0),
                      'popitem': (types.TupleType, 0, 0),
                      'setdefault': (Stack.TYPE_UNKNOWN, 1, 2),
                      'update': (types.NoneType, 1, 1),
                      'values': (types.ListType, 0, 0),
                    },
                    types.ListType :
                    { 'append': (types.NoneType, 1, 1),
                      'count': (types.IntType, 1, 1),
                      'extend': (types.NoneType, 1, 1),
                      'index': (types.IntType, 1, 1),
                      'insert': (types.NoneType, 2, 2),
                      'pop': (Stack.TYPE_UNKNOWN, 0, 1),
                      'remove': (types.NoneType, 1, 1),
                      'reverse': (types.NoneType, 0, 0),
                      'sort': (types.NoneType, 0, 1),
                    },
                    types.FileType :
                    { 'close': (types.NoneType, 0, 0),
                      'fileno': (types.IntType, 0, 0),
                      'flush': (types.NoneType, 0, 0),
                      'isatty': (BOOL, 0, 0),
                      'read': (types.StringType, 0, 1),
                      'readinto': (types.NoneType, 1, 1),
                      'readline': (types.StringType, 0, 1),
                      'readlines': (types.ListType, 0, 1),
                      'seek': (types.NoneType, 1, 2),
                      'tell': (types.IntType, 0, 0),
                      'truncate': (types.NoneType, 0, 1),
                      'write': (types.NoneType, 1, 1),
                      'writelines': (types.NoneType, 1, 1),
                      'xreadlines': (types.ListType, 0, 0),
                    },
                  }

def _setupBuiltinMethods() :
    if utils.pythonVersion() >= utils.PYTHON_2_2 :
        PY22_DICT_METHODS = { 'iteritems': (types.ListType, 0, 0),
                              'iterkeys': (types.ListType, 0, 0),
                              'itervalues': (types.ListType, 0, 0),
                            }

        BUILTIN_METHODS[types.DictType].update(PY22_DICT_METHODS)

    try :
        BUILTIN_METHODS[types.ComplexType] = \
                                  { 'conjugate': (types.ComplexType, 0, 0), }
    except AttributeError :
        pass

    if len(dir('')) > 0 :
        BUILTIN_METHODS[types.StringType] = _STRING_METHODS

    try :
        BUILTIN_METHODS[types.UnicodeType] = _STRING_METHODS
    except AttributeError :
        pass

_setupBuiltinMethods()

MUTABLE_TYPES = (types.ListType, types.DictType, types.InstanceType,)

# identifiers which will become a keyword in a future version
FUTURE_KEYWORDS = { 'yield': '2.2' }

METHODLESS_OBJECTS = { types.NoneType : None, types.IntType : None,
                       types.LongType : None, types.FloatType : None,
                       types.BufferType : None, types.TupleType : None,
                       types.EllipsisType : None,
                     }

def _setupBuiltinAttrs() :
    w = Warning.Warning('', 0, '')
    BUILTIN_ATTRS[types.MethodType] = dir(w.__init__)
    del w

    if utils.pythonVersion() >= utils.PYTHON_2_2 :
        # FIXME: I'm sure more types need to be added here
        BUILTIN_ATTRS[types.StringType] = dir(''.__class__)
        BUILTIN_ATTRS[types.ListType] = dir([].__class__)
        BUILTIN_ATTRS[types.DictType] = dir({}.__class__)

    try :
        import warnings
        _MSG = "xrange object's 'start', 'stop' and 'step' attributes are deprecated"
        warnings.filterwarnings('ignore', _MSG)
        del warnings, _MSG
    except ImportError :
        pass
    BUILTIN_ATTRS[types.XRangeType] = dir(xrange(0))

    try: BUILTIN_ATTRS[types.ComplexType] = dir(complex(0, 1))
    except: pass

    try: BUILTIN_ATTRS[types.UnicodeType] = dir(unicode(''))
    except: pass

    try: BUILTIN_ATTRS[types.CodeType] = dir(_setupBuiltinAttrs.func_code)
    except: pass

    try: BUILTIN_ATTRS[types.FileType] = dir(sys.__stdin__)
    except: pass

    try:
        raise TypeError
    except TypeError :
        try:
            tb = sys.exc_info()[2]
            BUILTIN_ATTRS[types.TracebackType] = dir(tb)
            BUILTIN_ATTRS[types.FrameType] = dir(tb.tb_frame)
        except:
            pass
        tb = None

BUILTIN_ATTRS = { types.StringType : dir(''),
                  types.TypeType : dir(type(0)),
                  types.ListType : dir([]),
                  types.DictType : dir({}),
                  types.FunctionType : dir(_setupBuiltinAttrs),
                  types.BuiltinFunctionType : dir(len),
                  types.BuiltinMethodType : dir([].append),
                  types.ClassType : dir(Stack.Item),
                  types.UnboundMethodType : dir(Stack.Item.__init__),
                  types.LambdaType : dir(lambda: None),
                  types.SliceType : dir(slice(0)),
                }

# have to setup the rest this way to support different versions of Python
_setupBuiltinAttrs()
<commit_msg>gotta stop doing something, that was just crap, make it the int TYPE!!!<commit_after>#!/usr/bin/env python

# Copyright (c) 2001, MetaSlash Inc.  All rights reserved.

"""
Setup a lot of info about Python builtin types, functions, methods, etc.
"""

import types
import sys

from pychecker import utils
from pychecker import Stack
from pychecker import Warning

BOOL = types.IntType
#                    name   (type,  args: min, max, kwArgs?
GLOBAL_FUNC_INFO = { '__import__': (types.ModuleType, 1, 4),
                     'abs': (Stack.TYPE_UNKNOWN, 1, 1),
                     'apply': (Stack.TYPE_UNKNOWN, 2, 3),
                     'buffer': (types.BufferType, 1, 3),
                     'callable': (BOOL, 1, 1),
                     'chr': (types.StringType, 1, 1),
                     'cmp': (types.IntType, 2, 2),
                     'coerce': ([ types.NoneType, types.TupleType ], 2, 2),
                     'compile': (types.CodeType, 3, 3),
                     'complex': (types.ComplexType, 1, 2),
                     'delattr': (types.NoneType, 2, 2),
                     'dir': (types.ListType, 0, 1),
                     'divmod': (types.TupleType, 2, 2),
                     'eval': (Stack.TYPE_UNKNOWN, 1, 3),
                     'execfile': (types.NoneType, 1, 3),
                     'filter': (types.ListType, 2, 2),
                     'float': (types.FloatType, 1, 1),
                     'getattr': (Stack.TYPE_UNKNOWN, 2, 3),
                     'globals': (types.DictType, 0, 0),
                     'hasattr': (BOOL, 2, 2),
                     'hash': (types.IntType, 1, 1),
                     'hex': (types.StringType, 1, 1),
                     'id': (types.IntType, 1, 1),
                     'input': (Stack.TYPE_UNKNOWN, 0, 1),
                     'int': (types.IntType, 1, 2),
                     'intern': (types.StringType, 1, 1),
                     'isinstance': (BOOL, 2, 2),
                     'issubclass': (BOOL, 2, 2),
                     'len': (types.IntType, 1, 1),
                     'list': (types.ListType, 1, 1),
                     'locals': (types.DictType, 0, 0),
                     'long': (types.LongType, 1, 2),
                     'map': (types.ListType, 2, None),
                     'max': (Stack.TYPE_UNKNOWN, 1, None),
                     'min': (Stack.TYPE_UNKNOWN, 1, None),
                     'oct': (types.StringType, 1, 1),
                     'open': (types.FileType, 1, 3),
                     'ord': (types.IntType, 1, 1),
                     'pow': (Stack.TYPE_UNKNOWN, 2, 3),
                     'range': (types.ListType, 1, 3),
                     'raw_input': (types.StringType, 0, 1),
                     'reduce': (Stack.TYPE_UNKNOWN, 2, 3),
                     'reload': (types.ModuleType, 1, 1),
                     'repr': (types.StringType, 1, 1),
                     'round': (types.FloatType, 1, 2),
                     'setattr': (types.NoneType, 3, 3),
                     'slice': (types.SliceType, 1, 3),
                     'str': (types.StringType, 1, 1),
                     'tuple': (types.TupleType, 1, 1),
                     'type': (types.TypeType, 1, 1),
                     'vars': (types.DictType, 0, 1),
                     'xrange': (types.ListType, 1, 3),
                   }

if utils.pythonVersion() >= utils.PYTHON_2_2 :
    GLOBAL_FUNC_INFO['compile'] = (types.CodeType, 3, 5)
    GLOBAL_FUNC_INFO['dict'] = (types.DictType, 0, 1)
    GLOBAL_FUNC_INFO['int'] = (types.IntType, 0, 2)
    GLOBAL_FUNC_INFO['list'] = (types.ListType, 0, 1)
    GLOBAL_FUNC_INFO['long'] = (types.LongType, 0, 2)
    GLOBAL_FUNC_INFO['str'] = (types.StringType, 0, 1)
    GLOBAL_FUNC_INFO['type'] = (types.TypeType, 1, 3)     # FIXME: not 2 args
    GLOBAL_FUNC_INFO['tuple'] = (types.TupleType, 0, 1)

    GLOBAL_FUNC_INFO['classmethod'] = (types.MethodType, 1, 1)
    GLOBAL_FUNC_INFO['iter'] = (Stack.TYPE_UNKNOWN, 1, 2)
    GLOBAL_FUNC_INFO['property'] = (Stack.TYPE_UNKNOWN, 0, 4)
    GLOBAL_FUNC_INFO['super'] = (Stack.TYPE_UNKNOWN, 1, 2)
    GLOBAL_FUNC_INFO['staticmethod'] = (types.MethodType, 1, 1)

if hasattr(types, 'UnicodeType') :
    GLOBAL_FUNC_INFO['unichr'] = (types.UnicodeType, 1, 1)
    GLOBAL_FUNC_INFO['unicode'] = (types.UnicodeType, 1, 3)

if globals().has_key('zip') :
    GLOBAL_FUNC_INFO['zip'] = (types.ListType, 1, None)

_STRING_METHODS = { 'capitalize': (types.StringType, 0, 0),
                    'center': (types.StringType, 1, 1),
                    'count': (types.IntType, 1, 1),
                    'encode': (types.StringType, 0, 2),
                    'endswith': (BOOL, 1, 3),
                    'expandtabs': (types.StringType, 0, 1),
                    'find': (types.IntType, 1, 3),
                    'index': (types.IntType, 1, 3),
                    'isalnum': (BOOL, 0, 0),
                    'isalpha': (BOOL, 0, 0),
                    'isdigit': (BOOL, 0, 0),
                    'islower': (BOOL, 0, 0),
                    'isspace': (BOOL, 0, 0),
                    'istitle': (BOOL, 0, 0),
                    'isupper': (BOOL, 0, 0),
                    'join': (types.StringType, 1, 1),
                    'ljust': (types.StringType, 1, 1),
                    'lower': (types.StringType, 0, 0),
                    'lstrip': (types.StringType, 0, 0),
                    'replace': (types.StringType, 2, 3),
                    'rfind': (types.IntType, 1, 3),
                    'rindex': (types.IntType, 1, 3),
                    'rjust': (types.StringType, 1, 1),
                    'rstrip': (types.StringType, 0, 0),
                    'split': (types.ListType, 0, 2),
                    'splitlines': (types.ListType, 0, 1),
                    'startswith': (BOOL, 1, 3),
                    'strip': (types.StringType, 0, 0),
                    'swapcase': (types.StringType, 0, 0),
                    'title': (types.StringType, 0, 0),
                    'translate': (types.StringType, 1, 2),
                    'upper': (types.StringType, 0, 0),
                  }

if utils.pythonVersion() >= utils.PYTHON_2_2 :
    _STRING_METHODS['decode'] = (types.UnicodeType, 0, 2)

BUILTIN_METHODS = { types.DictType :
                    { 'clear': (types.NoneType, 0, 0),
                      'copy': (types.DictType, 0, 0),
                      'get': (Stack.TYPE_UNKNOWN, 1, 2),
                      'has_key': (BOOL, 1, 1),
                      'items': (types.ListType, 0, 0),
                      'keys': (types.ListType, 0, 0),
                      'popitem': (types.TupleType, 0, 0),
                      'setdefault': (Stack.TYPE_UNKNOWN, 1, 2),
                      'update': (types.NoneType, 1, 1),
                      'values': (types.ListType, 0, 0),
                    },
                    types.ListType :
                    { 'append': (types.NoneType, 1, 1),
                      'count': (types.IntType, 1, 1),
                      'extend': (types.NoneType, 1, 1),
                      'index': (types.IntType, 1, 1),
                      'insert': (types.NoneType, 2, 2),
                      'pop': (Stack.TYPE_UNKNOWN, 0, 1),
                      'remove': (types.NoneType, 1, 1),
                      'reverse': (types.NoneType, 0, 0),
                      'sort': (types.NoneType, 0, 1),
                    },
                    types.FileType :
                    { 'close': (types.NoneType, 0, 0),
                      'fileno': (types.IntType, 0, 0),
                      'flush': (types.NoneType, 0, 0),
                      'isatty': (BOOL, 0, 0),
                      'read': (types.StringType, 0, 1),
                      'readinto': (types.NoneType, 1, 1),
                      'readline': (types.StringType, 0, 1),
                      'readlines': (types.ListType, 0, 1),
                      'seek': (types.NoneType, 1, 2),
                      'tell': (types.IntType, 0, 0),
                      'truncate': (types.NoneType, 0, 1),
                      'write': (types.NoneType, 1, 1),
                      'writelines': (types.NoneType, 1, 1),
                      'xreadlines': (types.ListType, 0, 0),
                    },
                  }

def _setupBuiltinMethods() :
    if utils.pythonVersion() >= utils.PYTHON_2_2 :
        PY22_DICT_METHODS = { 'iteritems': (types.ListType, 0, 0),
                              'iterkeys': (types.ListType, 0, 0),
                              'itervalues': (types.ListType, 0, 0),
                            }

        BUILTIN_METHODS[types.DictType].update(PY22_DICT_METHODS)

    try :
        BUILTIN_METHODS[types.ComplexType] = \
                                  { 'conjugate': (types.ComplexType, 0, 0), }
    except AttributeError :
        pass

    if len(dir('')) > 0 :
        BUILTIN_METHODS[types.StringType] = _STRING_METHODS

    try :
        BUILTIN_METHODS[types.UnicodeType] = _STRING_METHODS
    except AttributeError :
        pass

_setupBuiltinMethods()

MUTABLE_TYPES = (types.ListType, types.DictType, types.InstanceType,)

# identifiers which will become a keyword in a future version
FUTURE_KEYWORDS = { 'yield': '2.2' }

METHODLESS_OBJECTS = { types.NoneType : None, types.IntType : None,
                       types.LongType : None, types.FloatType : None,
                       types.BufferType : None, types.TupleType : None,
                       types.EllipsisType : None,
                     }

def _setupBuiltinAttrs() :
    w = Warning.Warning('', 0, '')
    BUILTIN_ATTRS[types.MethodType] = dir(w.__init__)
    del w

    if utils.pythonVersion() >= utils.PYTHON_2_2 :
        # FIXME: I'm sure more types need to be added here
        BUILTIN_ATTRS[types.StringType] = dir(''.__class__)
        BUILTIN_ATTRS[types.ListType] = dir([].__class__)
        BUILTIN_ATTRS[types.DictType] = dir({}.__class__)

    try :
        import warnings
        _MSG = "xrange object's 'start', 'stop' and 'step' attributes are deprecated"
        warnings.filterwarnings('ignore', _MSG)
        del warnings, _MSG
    except ImportError :
        pass
    BUILTIN_ATTRS[types.XRangeType] = dir(xrange(0))

    try: BUILTIN_ATTRS[types.ComplexType] = dir(complex(0, 1))
    except: pass

    try: BUILTIN_ATTRS[types.UnicodeType] = dir(unicode(''))
    except: pass

    try: BUILTIN_ATTRS[types.CodeType] = dir(_setupBuiltinAttrs.func_code)
    except: pass

    try: BUILTIN_ATTRS[types.FileType] = dir(sys.__stdin__)
    except: pass

    try:
        raise TypeError
    except TypeError :
        try:
            tb = sys.exc_info()[2]
            BUILTIN_ATTRS[types.TracebackType] = dir(tb)
            BUILTIN_ATTRS[types.FrameType] = dir(tb.tb_frame)
        except:
            pass
        tb = None

BUILTIN_ATTRS = { types.StringType : dir(''),
                  types.TypeType : dir(type(0)),
                  types.ListType : dir([]),
                  types.DictType : dir({}),
                  types.FunctionType : dir(_setupBuiltinAttrs),
                  types.BuiltinFunctionType : dir(len),
                  types.BuiltinMethodType : dir([].append),
                  types.ClassType : dir(Stack.Item),
                  types.UnboundMethodType : dir(Stack.Item.__init__),
                  types.LambdaType : dir(lambda: None),
                  types.SliceType : dir(slice(0)),
                }

# have to setup the rest this way to support different versions of Python
_setupBuiltinAttrs()
<|endoftext|>


<commit_before>#!/usr/bin/env python3

from setuptools import setup
import setuptools
from setuptools.command.install_lib import install_lib
import setuptools.command.build_py
from .install_resources import main as install_resources_main
import os
import sys

executable_list = [
    'makeblastdb',
    'tandem',
    'tandem.exe',
    'qvality',
    'percolator',
    'percolator_2_08',
    'omssacl',
    'myrimatch_2_1_138',
    'myrimatch.exe',
    'MSAmanda.exe',
    'PepNovo_bin',
    'novor.bat',
    'novor.sh',
    'PepNovo.exe',
]

if sys.platform in ['win32']:
    class my_install_lib(setuptools.command.install_lib.install_lib):
        pass
else:
    class my_install_lib(setuptools.command.install_lib.install_lib):
        def run(self):
            setuptools.command.install_lib.install_lib.run(self)
            for fn in self.get_outputs():
                if os.path.basename(fn) in executable_list:
                    # copied from setuptools source - make the binaries executable
                    mode = ((os.stat(fn).st_mode) | 0o555) & 0o7777
                    print("changing mode of %s to %o", fn, mode)
                    os.chmod(fn, mode)

class BuildPyWithResources(setuptools.command.build_py.build_py):
  """Includes install_resources.py before the setuptools build"""

  def run(self):
    install_resources_main(None)
    setuptools.command.build_py.build_py.run(self)

# We store our version number in a simple text file:
version_path = os.path.join(
    os.path.dirname(__file__),
    'ursgal', 'version.txt'
)
with open(version_path, 'r') as version_file:
    ursgal_version = version_file.read().strip()

with open('requirements.txt') as req:
    requirements = req.readlines()

setup(
    name='ursgal',
    version=ursgal_version,
    packages=['ursgal'],
    package_dir={'ursgal': 'ursgal'},
    description='ursgal',
    package_data={
        'ursgal' : [
            'version.txt',
            'wrappers/*.py',
            'resources/*/*/*',
            'resources/*/*/*/*',
            'resources/*/*/*/*/*',
        ]
    },
    build_requires=[
        'numpy',
    ],
    install_requires=requirements,
    long_description='Universal Python module combining common bottom-up proteomics tools for large-scale analysis',
    author='Lukas P. M. Kremer, Purevdulam Oyunchimeg, Johannes Barth, Stefan Schulze and Christian Fufezan',
    author_email='christian@fufezan.net',
    url='http://ursgal.github.com',
    license='Lesser GNU General Public License (LGPL)',
    platforms='any that supports python 3.5',
    classifiers=[
        'Development Status :: 4 - Beta',
        'Environment :: Console',
        'Intended Audience :: Education',
        'Intended Audience :: Science/Research',
        'Intended Audience :: Developers',
        'Operating System :: MacOS :: MacOS X',
        'Operating System :: Microsoft :: Windows',
        'Operating System :: POSIX',
        'Operating System :: POSIX :: SunOS/Solaris',
        'Operating System :: Unix',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.5',
        'Topic :: Scientific/Engineering :: Bio-Informatics',
        'Topic :: Scientific/Engineering :: Chemistry',
        'Topic :: Scientific/Engineering :: Medical Science Apps.',
        'Topic :: Software Development :: Libraries :: Python Modules'
    ],
    cmdclass={
        'install_lib': my_install_lib,
        'build_py': BuildPyWithResources,
    }
)<commit_msg>fixing setup.py<commit_after>#!/usr/bin/env python3

from setuptools import setup
import setuptools
from setuptools.command.install_lib import install_lib
import setuptools.command.build_py
import os
import sys
import ursgal
# from .install_resources import main as install_resources_main

executable_list = [
    'makeblastdb',
    'tandem',
    'tandem.exe',
    'qvality',
    'percolator',
    'percolator_2_08',
    'omssacl',
    'myrimatch_2_1_138',
    'myrimatch.exe',
    'MSAmanda.exe',
    'PepNovo_bin',
    'novor.bat',
    'novor.sh',
    'PepNovo.exe',
]

if sys.platform in ['win32']:
    class my_install_lib(setuptools.command.install_lib.install_lib):
        pass
else:
    class my_install_lib(setuptools.command.install_lib.install_lib):
        def run(self):
            setuptools.command.install_lib.install_lib.run(self)
            for fn in self.get_outputs():
                if os.path.basename(fn) in executable_list:
                    # copied from setuptools source - make the binaries executable
                    mode = ((os.stat(fn).st_mode) | 0o555) & 0o7777
                    print("changing mode of %s to %o", fn, mode)
                    os.chmod(fn, mode)

class BuildPyWithResources(setuptools.command.build_py.build_py):
  """Includes install_resources.py before the setuptools build"""

  def run(self):
    install_resources_main(None)
    # setuptools.command.build_py.build_py.run(self)

# We store our version number in a simple text file:
version_path = os.path.join(
    os.path.dirname(__file__),
    'ursgal', 'version.txt'
)
with open(version_path, 'r') as version_file:
    ursgal_version = version_file.read().strip()

with open('requirements.txt') as req:
    requirements = req.readlines()

setup(
    name='ursgal',
    version=ursgal_version,
    packages=['ursgal'],
    package_dir={'ursgal': 'ursgal'},
    description='ursgal',
    package_data={
        'ursgal' : [
            'version.txt',
            'wrappers/*.py',
            'resources/*/*/*',
            'resources/*/*/*/*',
            'resources/*/*/*/*/*',
        ]
    },
    build_requires=[
        'numpy',
    ],
    install_requires=requirements,
    long_description='Universal Python module combining common bottom-up proteomics tools for large-scale analysis',
    author='Lukas P. M. Kremer, Purevdulam Oyunchimeg, Johannes Barth, Stefan Schulze and Christian Fufezan',
    author_email='christian@fufezan.net',
    url='http://ursgal.github.com',
    license='Lesser GNU General Public License (LGPL)',
    platforms='any that supports python 3.5',
    classifiers=[
        'Development Status :: 4 - Beta',
        'Environment :: Console',
        'Intended Audience :: Education',
        'Intended Audience :: Science/Research',
        'Intended Audience :: Developers',
        'Operating System :: MacOS :: MacOS X',
        'Operating System :: Microsoft :: Windows',
        'Operating System :: POSIX',
        'Operating System :: POSIX :: SunOS/Solaris',
        'Operating System :: Unix',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.5',
        'Topic :: Scientific/Engineering :: Bio-Informatics',
        'Topic :: Scientific/Engineering :: Chemistry',
        'Topic :: Scientific/Engineering :: Medical Science Apps.',
        'Topic :: Software Development :: Libraries :: Python Modules'
    ],
    cmdclass={
        'install_lib': my_install_lib,
        'build_py': BuildPyWithResources,
    }
)<|endoftext|>


<commit_before>#! /usr/bin/env python

# Copyright (c) 2008, Stefano Taschini <taschini@ieee.org>
# All rights reserved.
# See LICENSE for details.

"""Script for setting the distribution of the interval package and the
crlibm extension.

Typical usage
-------------

Build crlibm and place it in the current directory:

    python setup.py build_ext -i

Create a source distribution:

    python setup.py sdist --formats=gztar,zip

"""

try:
    from setuptools import setup, Extension
except ImportError:
    from distutils.core import setup, Extension
from distutils.command.build_py import build_py
from distutils.command.build_ext import build_ext
from distutils import cygwinccompiler

class Msys2CCompiler (cygwinccompiler.CygwinCCompiler):
    # From https://github.com/aleaxit/gmpy/blob/ff2a8cca8e6f6901aa8ebb7e56a5fb19b236aaf0/msys2_build.txt

    compiler_type = 'msys2'

    def __init__ (self,
                  verbose=0,
                  dry_run=0,
                  force=0):

        cygwinccompiler.CygwinCCompiler.__init__ (self, verbose, dry_run, force)
        shared_option = "-shared" if self.ld_version >= "2.13" else "-mdll -static"
        entry_point = '--entry _DllMain@12' if self.gcc_version <= "2.91.57" else ''
        common_flags = ' -O2 -Wall -fno-strict-aliasing -fwrapv'
        import sys
        if sys.maxsize > 2**32:
            common_flags += ' -DMS_WIN64'
        self.set_executables(compiler     = 'gcc'       + common_flags,
                             compiler_so  = 'gcc -mdll' + common_flags,
                             compiler_cxx = 'g++'       + common_flags,
                             linker_exe='gcc',
                             linker_so='%s %s %s' % (self.linker_dll, shared_option, entry_point))
        self.dll_libraries=[]

@apply
def register_msys2ccompiler():
    from distutils.ccompiler import compiler_class
    cygwinccompiler.Msys2CCompiler = Msys2CCompiler
    compiler_class['msys2'] = ('cygwinccompiler', 'Msys2CCompiler', "MSYS2/MinGW-w64 port of GNU C Compiler for MS Windows")
    return 'Done'

class custom_build_py(build_py):
    # Copy the license file into the package directory
    def run(self):
        from os import path as op
        def fix(package, src_dir, build_dir, filenames):
            assert filenames == [op.join('..', 'LICENSE')]
            return (package, '.', build_dir, ['LICENSE'])
        self.data_files = [fix(*t) for t in self.data_files]
        return build_py.run(self)

class custom_build_ext(build_ext):
    """Build C/C++ extensions, without aborting in case of failure."""

    def run(self):
        try:
            build_ext.run(self)
        except Exception as ex:
            import sys
            sys.stderr.write("*** Could not build any of the extensions: {!r}\n*** Skipping...\n".format(ex))

    def build_extension(self, ext):
        try:
            build_ext.build_extension(self, ext)
        except Exception as ex:
            import sys
            sys.stderr.write("*** Could not build the extension {!r}: {!r}\n*** Skipping...\n".format(ext.name, ex))

# A subset of http://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers = [
    'Development Status :: 4 - Beta',
    'License :: OSI Approved :: BSD License',
    'Operating System :: MacOS :: MacOS X',
    'Operating System :: Microsoft :: Windows',
    'Operating System :: POSIX :: Linux',
    'Programming Language :: C',
    'Programming Language :: Python',
    'Topic :: Scientific/Engineering :: Mathematics'
]

@apply
def long_description():
    with open('README.rst') as f:
        return f.read().decode('utf8')

metadata = dict(
    author           = 'Stefano Taschini',
    author_email     = 'taschini@gmail.com',
    classifiers      = classifiers,
    description      = 'Interval arithmetic in Python',
    long_description = long_description,
    url              = "https://github.com/taschini/pyinterval",
);

data = dict(
    name          = 'pyinterval',
    version       = '1.0b21',
    packages      = ['interval'],
    package_data  = dict(interval=['../LICENSE']),
    cmdclass      = dict(build_py=custom_build_py, build_ext=custom_build_ext),
    test_suite    = 'test',
    ext_modules   = [
        Extension(
            'crlibm',
            sources      = ['ext/crlibmmodule.c'],
            include_dirs = ['deps/build/include'],
            library_dirs = ['deps/build/lib'],
            libraries    = ['crlibm'])
        ],
    **metadata)

if __name__ == '__main__':
    setup(**data)
<commit_msg>Set the version number to 1.0.0<commit_after>#! /usr/bin/env python

# Copyright (c) 2008, Stefano Taschini <taschini@ieee.org>
# All rights reserved.
# See LICENSE for details.

"""Script for setting the distribution of the interval package and the
crlibm extension.

Typical usage
-------------

Build crlibm and place it in the current directory:

    python setup.py build_ext -i

Create a source distribution:

    python setup.py sdist --formats=gztar,zip

"""

try:
    from setuptools import setup, Extension
except ImportError:
    from distutils.core import setup, Extension
from distutils.command.build_py import build_py
from distutils.command.build_ext import build_ext
from distutils import cygwinccompiler

class Msys2CCompiler (cygwinccompiler.CygwinCCompiler):
    # From https://github.com/aleaxit/gmpy/blob/ff2a8cca8e6f6901aa8ebb7e56a5fb19b236aaf0/msys2_build.txt

    compiler_type = 'msys2'

    def __init__ (self,
                  verbose=0,
                  dry_run=0,
                  force=0):

        cygwinccompiler.CygwinCCompiler.__init__ (self, verbose, dry_run, force)
        shared_option = "-shared" if self.ld_version >= "2.13" else "-mdll -static"
        entry_point = '--entry _DllMain@12' if self.gcc_version <= "2.91.57" else ''
        common_flags = ' -O2 -Wall -fno-strict-aliasing -fwrapv'
        import sys
        if sys.maxsize > 2**32:
            common_flags += ' -DMS_WIN64'
        self.set_executables(compiler     = 'gcc'       + common_flags,
                             compiler_so  = 'gcc -mdll' + common_flags,
                             compiler_cxx = 'g++'       + common_flags,
                             linker_exe='gcc',
                             linker_so='%s %s %s' % (self.linker_dll, shared_option, entry_point))
        self.dll_libraries=[]

@apply
def register_msys2ccompiler():
    from distutils.ccompiler import compiler_class
    cygwinccompiler.Msys2CCompiler = Msys2CCompiler
    compiler_class['msys2'] = ('cygwinccompiler', 'Msys2CCompiler', "MSYS2/MinGW-w64 port of GNU C Compiler for MS Windows")
    return 'Done'

class custom_build_py(build_py):
    # Copy the license file into the package directory
    def run(self):
        from os import path as op
        def fix(package, src_dir, build_dir, filenames):
            assert filenames == [op.join('..', 'LICENSE')]
            return (package, '.', build_dir, ['LICENSE'])
        self.data_files = [fix(*t) for t in self.data_files]
        return build_py.run(self)

class custom_build_ext(build_ext):
    """Build C/C++ extensions, without aborting in case of failure."""

    def run(self):
        try:
            build_ext.run(self)
        except Exception as ex:
            import sys
            sys.stderr.write("*** Could not build any of the extensions: {!r}\n*** Skipping...\n".format(ex))

    def build_extension(self, ext):
        try:
            build_ext.build_extension(self, ext)
        except Exception as ex:
            import sys
            sys.stderr.write("*** Could not build the extension {!r}: {!r}\n*** Skipping...\n".format(ext.name, ex))

# A subset of http://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers = [
    'Development Status :: 4 - Beta',
    'License :: OSI Approved :: BSD License',
    'Operating System :: MacOS :: MacOS X',
    'Operating System :: Microsoft :: Windows',
    'Operating System :: POSIX :: Linux',
    'Programming Language :: C',
    'Programming Language :: Python',
    'Topic :: Scientific/Engineering :: Mathematics'
]

@apply
def long_description():
    with open('README.rst') as f:
        return f.read().decode('utf8')

metadata = dict(
    author           = 'Stefano Taschini',
    author_email     = 'taschini@gmail.com',
    classifiers      = classifiers,
    description      = 'Interval arithmetic in Python',
    long_description = long_description,
    url              = "https://github.com/taschini/pyinterval",
);

data = dict(
    name          = 'pyinterval',
    version       = '1.0.0',
    packages      = ['interval'],
    package_data  = dict(interval=['../LICENSE']),
    cmdclass      = dict(build_py=custom_build_py, build_ext=custom_build_ext),
    test_suite    = 'test',
    ext_modules   = [
        Extension(
            'crlibm',
            sources      = ['ext/crlibmmodule.c'],
            include_dirs = ['deps/build/include'],
            library_dirs = ['deps/build/lib'],
            libraries    = ['crlibm'])
        ],
    **metadata)

if __name__ == '__main__':
    setup(**data)
<|endoftext|>


<commit_before>#!/usr/bin/env python
# -*- coding: latin-1 -*-
#
# Copyright 2009-2014 Ghent University
#
# This file is part of vsc-base,
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
# with support of Ghent University (http://ugent.be/hpc),
# the Flemish Supercomputer Centre (VSC) (https://vscentrum.be/nl/en),
# the Hercules foundation (http://www.herculesstichting.be/in_English)
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en).
#
# http://github.com/hpcugent/vsc-base
#
# vsc-base is free software: you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# vsc-base is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with vsc-base. If not, see <http://www.gnu.org/licenses/>.
#
"""
vsc-base base distribution setup.py

@author: Stijn De Weirdt (Ghent University)
@author: Andy Georges (Ghent University)
"""
import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "lib"))

import vsc.install.shared_setup as shared_setup
from vsc.install.shared_setup import ag, jt, sdw

def remove_bdist_rpm_source_file():
    """List of files to remove from the (source) RPM."""
    return []

shared_setup.remove_extra_bdist_rpm_files = remove_bdist_rpm_source_file
shared_setup.SHARED_TARGET.update({
    'url': 'https://github.com/hpcugent/vsc-base',
    'download_url': 'https://github.com/hpcugent/vsc-base'
})

PACKAGE = {
    'name': 'vsc-base',
    'version': '1.9.5',
    'author': [sdw, jt, ag],
    'maintainer': [sdw, jt, ag],
    'packages': ['vsc', 'vsc.utils', 'vsc.install'],
    'scripts': ['bin/logdaemon.py', 'bin/startlogdaemon.sh', 'bin/bdist_rpm.sh', 'bin/optcomplete.bash'],
    'install_requires' : ['setuptools'],
}

if __name__ == '__main__':
    shared_setup.action_target(PACKAGE)
<commit_msg>bump version<commit_after>#!/usr/bin/env python
# -*- coding: latin-1 -*-
#
# Copyright 2009-2014 Ghent University
#
# This file is part of vsc-base,
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
# with support of Ghent University (http://ugent.be/hpc),
# the Flemish Supercomputer Centre (VSC) (https://vscentrum.be/nl/en),
# the Hercules foundation (http://www.herculesstichting.be/in_English)
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en).
#
# http://github.com/hpcugent/vsc-base
#
# vsc-base is free software: you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# vsc-base is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with vsc-base. If not, see <http://www.gnu.org/licenses/>.
#
"""
vsc-base base distribution setup.py

@author: Stijn De Weirdt (Ghent University)
@author: Andy Georges (Ghent University)
"""
import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "lib"))

import vsc.install.shared_setup as shared_setup
from vsc.install.shared_setup import ag, jt, sdw

def remove_bdist_rpm_source_file():
    """List of files to remove from the (source) RPM."""
    return []

shared_setup.remove_extra_bdist_rpm_files = remove_bdist_rpm_source_file
shared_setup.SHARED_TARGET.update({
    'url': 'https://github.com/hpcugent/vsc-base',
    'download_url': 'https://github.com/hpcugent/vsc-base'
})

PACKAGE = {
    'name': 'vsc-base',
    'version': '1.9.6',
    'author': [sdw, jt, ag],
    'maintainer': [sdw, jt, ag],
    'packages': ['vsc', 'vsc.utils', 'vsc.install'],
    'scripts': ['bin/logdaemon.py', 'bin/startlogdaemon.sh', 'bin/bdist_rpm.sh', 'bin/optcomplete.bash'],
    'install_requires' : ['setuptools'],
}

if __name__ == '__main__':
    shared_setup.action_target(PACKAGE)
<|endoftext|>


<commit_before>"""Set up the package."""

import os
import re
import sys
from codecs import open as codecs_open
from setuptools import setup, find_packages

REQUIREMENTS = [
    'flask',
    'requests',
    'zappa',
]

if sys.version_info <= (3, 6):
    sys.stderr.write('Python 3.6+ is required.' + os.linesep)
    sys.exit(1)

# Get the long description from the relevant file
with codecs_open('README.md', encoding='utf-8') as f:
    LONG_DESCRIPTION = f.read()

with open('klaxer/__init__.py', "r") as f:
    VERSION = re.search(r"^__version__\s*=\s*[\"']([^\"']*)[\"']", f.read(), re.MULTILINE).group(1)

setup(name='klaxer',
      version=VERSION,
      description='Restore sanity to your Slack service alerting',
      long_description=LONG_DESCRIPTION,
      classifiers=[
          'Development Status :: 1 - Pre-Alpha',
          'Environment :: Web Environment',
          'Intended Audience :: Developers',
          'Intended Audience :: System Administrators',
          'License :: OSI Approved :: MIT License',
          'Framework :: Flask',
          'Programming Language :: Python :: 3.6',
          'Programming Language :: Python :: 3 :: Only',
          'Topic :: Communications :: Chat',
      ],
      keywords='slack alerting alerts notifications debounce silence mute',
      author='Aru Sahni',
      author_email='arusahni@gmail.com',
      url='https://github.com/arusahni/klaxer',
      license='MIT',
      package_data={'': ['LICENSE']},
      packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
      include_package_data=True,
      zip_safe=True,
      install_requires=REQUIREMENTS,
      extras_require={
          'dev': ['pytest', 'coverage', 'pylint', 'pytest-cov'],
      },
     )
<commit_msg>Add Slacker dependency<commit_after>"""Set up the package."""

import os
import re
import sys
from codecs import open as codecs_open
from setuptools import setup, find_packages

REQUIREMENTS = [
    'flask',
    'requests',
    'zappa',
    'slacker'
]

if sys.version_info <= (3, 6):
    sys.stderr.write('Python 3.6+ is required.' + os.linesep)
    sys.exit(1)

# Get the long description from the relevant file
with codecs_open('README.md', encoding='utf-8') as f:
    LONG_DESCRIPTION = f.read()

with open('klaxer/__init__.py', "r") as f:
    VERSION = re.search(r"^__version__\s*=\s*[\"']([^\"']*)[\"']", f.read(), re.MULTILINE).group(1)

setup(name='klaxer',
      version=VERSION,
      description='Restore sanity to your Slack service alerting',
      long_description=LONG_DESCRIPTION,
      classifiers=[
          'Development Status :: 1 - Pre-Alpha',
          'Environment :: Web Environment',
          'Intended Audience :: Developers',
          'Intended Audience :: System Administrators',
          'License :: OSI Approved :: MIT License',
          'Framework :: Flask',
          'Programming Language :: Python :: 3.6',
          'Programming Language :: Python :: 3 :: Only',
          'Topic :: Communications :: Chat',
      ],
      keywords='slack alerting alerts notifications debounce silence mute',
      author='Aru Sahni',
      author_email='arusahni@gmail.com',
      url='https://github.com/arusahni/klaxer',
      license='MIT',
      package_data={'': ['LICENSE']},
      packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
      include_package_data=True,
      zip_safe=True,
      install_requires=REQUIREMENTS,
      extras_require={
          'dev': ['pytest', 'coverage', 'pylint', 'pytest-cov'],
      },
     )
<|endoftext|>


<commit_before>from setuptools import setup
from os         import path

here = path.abspath(path.dirname(__file__))

with open(path.join(here, 'README.md'), encoding='utf-8') as f:
    long_description = f.read()

setup(
    name             = 'neovim-remote',
    author           = 'Marco Hinz',
    author_email     = 'mh.codebro@gmail.com',
    url              = 'https://github.com/mhinz/neovim-remote',
    description      = 'Control nvim processes using "nvr" commandline tool',
    long_description = long_description,
    python_requires  = '>=3.4, <3.7',
    install_requires = ['neovim>=0.2.3', 'psutil', 'setuptools'],
    entry_points     = {
        'console_scripts': ['nvr = nvr.nvr:main']
    },
    packages         = ['nvr'],
    version          = '2.0.8',
    license          = 'MIT',
    keywords         = 'neovim nvim nvr remote helper',
    classifiers      = [
        'Topic :: Utilities',
        'License :: OSI Approved :: MIT License',
        'Development Status :: 5 - Production/Stable',
        'Intended Audience :: End Users/Desktop',
        'Intended Audience :: Developers',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.4',
        'Programming Language :: Python :: 3.5',
        'Programming Language :: Python :: 3.6',
    ],
)

<commit_msg>Allow Python 3.7 installation<commit_after>from setuptools import setup
from os         import path

here = path.abspath(path.dirname(__file__))

with open(path.join(here, 'README.md'), encoding='utf-8') as f:
    long_description = f.read()

setup(
    name             = 'neovim-remote',
    author           = 'Marco Hinz',
    author_email     = 'mh.codebro@gmail.com',
    url              = 'https://github.com/mhinz/neovim-remote',
    description      = 'Control nvim processes using "nvr" commandline tool',
    long_description = long_description,
    python_requires  = '>=3.4, <3.8',
    install_requires = ['neovim>=0.2.3', 'psutil', 'setuptools'],
    entry_points     = {
        'console_scripts': ['nvr = nvr.nvr:main']
    },
    packages         = ['nvr'],
    version          = '2.0.8',
    license          = 'MIT',
    keywords         = 'neovim nvim nvr remote helper',
    classifiers      = [
        'Topic :: Utilities',
        'License :: OSI Approved :: MIT License',
        'Development Status :: 5 - Production/Stable',
        'Intended Audience :: End Users/Desktop',
        'Intended Audience :: Developers',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.4',
        'Programming Language :: Python :: 3.5',
        'Programming Language :: Python :: 3.6',
    ],
)

<|endoftext|>


<commit_before>#!/usr/bin/env python
from setuptools import setup

install_requires = [
    'argparse',
    'jsonschema',
    'M2Crypto',
    'pycrypto',
    'python-augeas',
    'python2-pythondialog',
    'requests',
]

docs_extras = [
    'Sphinx',
]

testing_extras = [
    'coverage',
    'nose',
    'nosexcover',
    'pylint',
    'tox',
]

setup(
    name="letsencrypt",
    version="0.1",
    description="Let's Encrypt",
    author="Let's Encrypt Project",
    license="",
    url="https://letsencrypt.org",
    packages=[
        'letsencrypt',
        'letsencrypt.client',
        'letsencrypt.scripts',
    ],
    install_requires=install_requires,
    tests_require=install_requires,
    test_suite='letsencrypt',
    extras_require={
        'docs': docs_extras,
        'testing': testing_extras,
    },
    entry_points={
        'console_scripts': [
            'letsencrypt = letsencrypt.scripts.main:main',
        ],
    },
    zip_safe=False,
    include_package_data=True,
)
<commit_msg>Pin pylint<1.4<commit_after>#!/usr/bin/env python
from setuptools import setup

install_requires = [
    'argparse',
    'jsonschema',
    'M2Crypto',
    'pycrypto',
    'python-augeas',
    'python2-pythondialog',
    'requests',
]

docs_extras = [
    'Sphinx',
]

testing_extras = [
    'coverage',
    'nose',
    'nosexcover',
    'pylint<1.4',  # py2.6 compat, c.f #97
    'tox',
]

setup(
    name="letsencrypt",
    version="0.1",
    description="Let's Encrypt",
    author="Let's Encrypt Project",
    license="",
    url="https://letsencrypt.org",
    packages=[
        'letsencrypt',
        'letsencrypt.client',
        'letsencrypt.scripts',
    ],
    install_requires=install_requires,
    tests_require=install_requires,
    test_suite='letsencrypt',
    extras_require={
        'docs': docs_extras,
        'testing': testing_extras,
    },
    entry_points={
        'console_scripts': [
            'letsencrypt = letsencrypt.scripts.main:main',
        ],
    },
    zip_safe=False,
    include_package_data=True,
)
<|endoftext|>


<commit_before>"""Classes that generate the summary pages."""

from twisted.web.template import tags
from twisted.web.template import Element, renderer, XMLFile

from pydoctor import epydoc2stan, model
from pydoctor.nevowhtml.util import fillSlots, taglink, templatefile

def moduleSummary(modorpack):
    r = tags.li(taglink(modorpack, tags=tags), ' - ', epydoc2stan.doc2html(modorpack, summary=True, tags=tags)[0])
    if not isinstance(modorpack, model.Package):
        return r
    contents = [m for m in modorpack.orderedcontents
                if m.isVisible and m.name != '__init__']
    if not contents:
        return r
    ul = tags.ul()
    for m in sorted(contents, key=lambda m:m.fullName()):
        ul(moduleSummary(m))
    return r(ul)

def _lckey(x):
    return x.fullName().lower()

class ModuleIndexPage(Element):
    filename = 'moduleIndex.html'
    loader = XMLFile(templatefile('summary.html'))
    def __init__(self, system):
        self.system = system
    @renderer
    def title(self, request, tag):
        return tag.clear()("Module Index")
    @renderer
    def stuff(self, request, tag):
        r = []
        for o in self.system.rootobjects:
            r.append(moduleSummary(o))
        return tag.clear()(r)
    @renderer
    def heading(self, request, tag):
        return tag().clear()("Module Index")

def findRootClasses(system):
    roots = {}
    for cls in system.objectsOfType(model.Class):
        if ' ' in cls.name or not cls.isVisible:
            continue
        if cls.bases:
            for n, b in zip(cls.bases, cls.baseobjects):
                if b is None or not b.isVisible:
                    roots.setdefault(n, []).append(cls)
                elif b.system is not system:
                    roots[b.fullName()] = b
        else:
            roots[cls.fullName()] = cls
    return sorted(roots.items(), key=lambda x:x[0].lower())

def subclassesFrom(hostsystem, cls, anchors):
    r = tags.li()
    name = cls.fullName()
    if name not in anchors:
        r[tags.a(name=name)]
        anchors.add(name)
    r[taglink(cls), ' - ', epydoc2stan.doc2html(cls, summary=True)[0]]
    scs = [sc for sc in cls.subclasses if sc.system is hostsystem and ' ' not in sc.fullName()
           and sc.isVisible]
    if len(scs) > 0:
        ul = tags.ul()
        for sc in sorted(scs, key=_lckey):
            ul[subclassesFrom(hostsystem, sc, anchors)]
        r[ul]
    return r

class ClassIndexPage(Element):
    filename = 'classIndex.html'
    loader = XMLFile(templatefile('summary.html'))
    def __init__(self, system):
        self.system = system
    @renderer
    def title(self, request, tag):
        return tag.clear()["Class Hierarchy"]
    @renderer
    def stuff(self, request, tag):
        t = tag
        anchors = set()
        for b, o in findRootClasses(self.system):
            if isinstance(o, model.Class):
                t[subclassesFrom(self.system, o, anchors)]
            else:
                item = tags.li[b]
                if o:
                    ul = tags.ul()
                    for sc in sorted(o, key=_lckey):
                        ul[subclassesFrom(self.system, sc, anchors)]
                    item[ul]
                t[item]
        return t
    @renderer
    def heading(self, request, tag):
        return tag.clear()["Class Hierarchy"]

class NameIndexPage(Element):
    filename = 'nameIndex.html'
    loader = XMLFile(templatefile('nameIndex.html'))
    def __init__(self, system):
        self.system = system

    @renderer
    def title(self, request, tag):
        return tag.clear()("Index Of Names")

    @renderer
    def heading(self, request, tag):
        return tag.clear()("Index Of Names")

    @renderer
    def index(self, request, tag):
        letter = tag.patternGenerator('letter')
        singleName = tag.patternGenerator('singleName')
        manyNames = tag.patternGenerator('manyNames')
        initials = {}
        for ob in self.system.orderedallobjects:
            if ob.isVisible:
                initials.setdefault(ob.name[0].upper(), []).append(ob)
        for initial in sorted(initials):
            letterlinks = []
            for initial2 in sorted(initials):
                if initial == initial2:
                    letterlinks.append(initial2)
                else:
                    letterlinks.append(tags.a(href='#'+initial2)[initial2])
                letterlinks.append(' - ')
            if letterlinks:
                del letterlinks[-1]
            name2obs = {}
            for obj in initials[initial]:
                name2obs.setdefault(obj.name, []).append(obj)
            lettercontents = []
            for name in sorted(name2obs, key=lambda x:x.lower()):
                obs = sorted(name2obs[name], key=lambda x:x.fullName().lower())
                if len(obs) == 1:
                    ob, = obs
                    lettercontents.append(fillSlots(singleName,
                                                    name=ob.name,
                                                    link=taglink(ob)))
                else:
                    lettercontents.append(fillSlots(manyNames,
                                                    name=obs[0].name,
                                                    manyNames=[tags.li[taglink(ob)] for ob in obs]))

            tag[fillSlots(letter,
                          letter=initial,
                          letterlinks=letterlinks,
                          lettercontents=lettercontents)]
        return tag

class IndexPage(Element):
    filename = 'index.html'
    loader = XMLFile(templatefile('index.html'))

    def __init__(self, system):
        self.system = system

    @renderer
    def project_link(self, request, tag):
        if self.system.options.projecturl:
            return tags.a(href=self.system.options.projecturl)(
                self.system.options.projectname)
        elif self.system.options.projectname:
            return self.system.options.projectname
        else:
            return self.system.guessedprojectname

    @renderer
    def project(self, request, tag):
        if self.system.options.projectname:
            return self.system.options.projectname
        else:
            return self.system.guessedprojectname

    @renderer
    def recentChanges(self, request, tag):
        return ()

    @renderer
    def problemObjects(self, request, tag):
        return ()

    @renderer
    def onlyIfOneRoot(self, request, tag):
        if len(self.system.rootobjects) != 1:
            return []
        else:
            root, = self.system.rootobjects
            return tag.clear()(
                "Start at ", taglink(root),
                ", the root ", root.kind.lower(), ".")

    @renderer
    def onlyIfMultipleRoots(self, request, tag):
        if len(self.system.rootobjects) == 1:
            return []
        else:
            return tag

    @renderer
    def roots(self, request, tag):
        r = []
        for o in self.system.rootobjects:
            r.append(tag.clone().fillSlots(root=taglink(o)))
        return r

    @renderer
    def rootkind(self, request, tag):
        rootkinds = {}
        for o in self.system.rootobjects:
            rootkinds[o.kind.lower() + 's']  = 1
        return tag.clear()('/'.join(sorted(rootkinds)))

    @renderer
    def buildtime(self, request, tag):
        return self.system.buildtime.strftime("%Y-%m-%d %H:%M:%S")

def hasdocstring(ob):
    for source in ob.docsources():
        if source.docstring is not None:
            return True
    return False

class UndocumentedSummaryPage(Element):
    filename = 'undoccedSummary.html'
    loader = XMLFile(templatefile('summary.html'))
    def __init__(self, system):
        self.system = system

    @renderer
    def title(self, request, tag):
        return tag.clear()["Summary of Undocumented Objects"]

    @renderer
    def heading(self, request, tag):
        return tag.clear()["Summary of Undocumented Objects"]

    @renderer
    def stuff(self, request, tag):
        undoccedpublic = [o for o in self.system.orderedallobjects
                          if o.isVisible and not hasdocstring(o)]
        undoccedpublic.sort(key=lambda o:o.fullName())
        for o in undoccedpublic:
            tag[tags.li[o.kind, " - ", taglink(o)]]
        return tag

summarypages = [
    ModuleIndexPage,
    ClassIndexPage,
    IndexPage,
    NameIndexPage,
    UndocumentedSummaryPage,
    ]

<commit_msg>classIndex<commit_after>"""Classes that generate the summary pages."""

from twisted.web.template import tags
from twisted.web.template import Element, renderer, XMLFile

from pydoctor import epydoc2stan, model
from pydoctor.nevowhtml.util import fillSlots, taglink, templatefile

def moduleSummary(modorpack):
    r = tags.li(taglink(modorpack, tags=tags), ' - ', epydoc2stan.doc2html(modorpack, summary=True, tags=tags)[0])
    if not isinstance(modorpack, model.Package):
        return r
    contents = [m for m in modorpack.orderedcontents
                if m.isVisible and m.name != '__init__']
    if not contents:
        return r
    ul = tags.ul()
    for m in sorted(contents, key=lambda m:m.fullName()):
        ul(moduleSummary(m))
    return r(ul)

def _lckey(x):
    return x.fullName().lower()

class ModuleIndexPage(Element):
    filename = 'moduleIndex.html'
    loader = XMLFile(templatefile('summary.html'))
    def __init__(self, system):
        self.system = system
    @renderer
    def title(self, request, tag):
        return tag.clear()("Module Index")
    @renderer
    def stuff(self, request, tag):
        r = []
        for o in self.system.rootobjects:
            r.append(moduleSummary(o))
        return tag.clear()(r)
    @renderer
    def heading(self, request, tag):
        return tag().clear()("Module Index")

def findRootClasses(system):
    roots = {}
    for cls in system.objectsOfType(model.Class):
        if ' ' in cls.name or not cls.isVisible:
            continue
        if cls.bases:
            for n, b in zip(cls.bases, cls.baseobjects):
                if b is None or not b.isVisible:
                    roots.setdefault(n, []).append(cls)
                elif b.system is not system:
                    roots[b.fullName()] = b
        else:
            roots[cls.fullName()] = cls
    return sorted(roots.items(), key=lambda x:x[0].lower())

def subclassesFrom(hostsystem, cls, anchors):
    r = tags.li()
    name = cls.fullName()
    if name not in anchors:
        r(tags.a(name=name))
        anchors.add(name)
    r(taglink(cls), ' - ', epydoc2stan.doc2html(cls, summary=True, tags=tags)[0])
    scs = [sc for sc in cls.subclasses if sc.system is hostsystem and ' ' not in sc.fullName()
           and sc.isVisible]
    if len(scs) > 0:
        ul = tags.ul()
        for sc in sorted(scs, key=_lckey):
            ul(subclassesFrom(hostsystem, sc, anchors))
        r(ul)
    return r

class ClassIndexPage(Element):
    filename = 'classIndex.html'
    loader = XMLFile(templatefile('summary.html'))

    def __init__(self, system):
        self.system = system

    @renderer
    def title(self, request, tag):
        return tag.clear()("Class Hierarchy")

    @renderer
    def stuff(self, request, tag):
        t = tag
        anchors = set()
        for b, o in findRootClasses(self.system):
            if isinstance(o, model.Class):
                t(subclassesFrom(self.system, o, anchors))
            else:
                item = tags.li(b)
                if o:
                    ul = tags.ul()
                    for sc in sorted(o, key=_lckey):
                        ul(subclassesFrom(self.system, sc, anchors))
                    item(ul)
                t(item)
        return t

    @renderer
    def heading(self, request, tag):
        return tag.clear()("Class Hierarchy")

class NameIndexPage(Element):
    filename = 'nameIndex.html'
    loader = XMLFile(templatefile('nameIndex.html'))
    def __init__(self, system):
        self.system = system

    @renderer
    def title(self, request, tag):
        return tag.clear()("Index Of Names")

    @renderer
    def heading(self, request, tag):
        return tag.clear()("Index Of Names")

    @renderer
    def index(self, request, tag):
        letter = tag.patternGenerator('letter')
        singleName = tag.patternGenerator('singleName')
        manyNames = tag.patternGenerator('manyNames')
        initials = {}
        for ob in self.system.orderedallobjects:
            if ob.isVisible:
                initials.setdefault(ob.name[0].upper(), []).append(ob)
        for initial in sorted(initials):
            letterlinks = []
            for initial2 in sorted(initials):
                if initial == initial2:
                    letterlinks.append(initial2)
                else:
                    letterlinks.append(tags.a(href='#'+initial2)[initial2])
                letterlinks.append(' - ')
            if letterlinks:
                del letterlinks[-1]
            name2obs = {}
            for obj in initials[initial]:
                name2obs.setdefault(obj.name, []).append(obj)
            lettercontents = []
            for name in sorted(name2obs, key=lambda x:x.lower()):
                obs = sorted(name2obs[name], key=lambda x:x.fullName().lower())
                if len(obs) == 1:
                    ob, = obs
                    lettercontents.append(fillSlots(singleName,
                                                    name=ob.name,
                                                    link=taglink(ob)))
                else:
                    lettercontents.append(fillSlots(manyNames,
                                                    name=obs[0].name,
                                                    manyNames=[tags.li[taglink(ob)] for ob in obs]))

            tag[fillSlots(letter,
                          letter=initial,
                          letterlinks=letterlinks,
                          lettercontents=lettercontents)]
        return tag

class IndexPage(Element):
    filename = 'index.html'
    loader = XMLFile(templatefile('index.html'))

    def __init__(self, system):
        self.system = system

    @renderer
    def project_link(self, request, tag):
        if self.system.options.projecturl:
            return tags.a(href=self.system.options.projecturl)(
                self.system.options.projectname)
        elif self.system.options.projectname:
            return self.system.options.projectname
        else:
            return self.system.guessedprojectname

    @renderer
    def project(self, request, tag):
        if self.system.options.projectname:
            return self.system.options.projectname
        else:
            return self.system.guessedprojectname

    @renderer
    def recentChanges(self, request, tag):
        return ()

    @renderer
    def problemObjects(self, request, tag):
        return ()

    @renderer
    def onlyIfOneRoot(self, request, tag):
        if len(self.system.rootobjects) != 1:
            return []
        else:
            root, = self.system.rootobjects
            return tag.clear()(
                "Start at ", taglink(root),
                ", the root ", root.kind.lower(), ".")

    @renderer
    def onlyIfMultipleRoots(self, request, tag):
        if len(self.system.rootobjects) == 1:
            return []
        else:
            return tag

    @renderer
    def roots(self, request, tag):
        r = []
        for o in self.system.rootobjects:
            r.append(tag.clone().fillSlots(root=taglink(o)))
        return r

    @renderer
    def rootkind(self, request, tag):
        rootkinds = {}
        for o in self.system.rootobjects:
            rootkinds[o.kind.lower() + 's']  = 1
        return tag.clear()('/'.join(sorted(rootkinds)))

    @renderer
    def buildtime(self, request, tag):
        return self.system.buildtime.strftime("%Y-%m-%d %H:%M:%S")

def hasdocstring(ob):
    for source in ob.docsources():
        if source.docstring is not None:
            return True
    return False

class UndocumentedSummaryPage(Element):
    filename = 'undoccedSummary.html'
    loader = XMLFile(templatefile('summary.html'))
    def __init__(self, system):
        self.system = system

    @renderer
    def title(self, request, tag):
        return tag.clear()["Summary of Undocumented Objects"]

    @renderer
    def heading(self, request, tag):
        return tag.clear()["Summary of Undocumented Objects"]

    @renderer
    def stuff(self, request, tag):
        undoccedpublic = [o for o in self.system.orderedallobjects
                          if o.isVisible and not hasdocstring(o)]
        undoccedpublic.sort(key=lambda o:o.fullName())
        for o in undoccedpublic:
            tag[tags.li[o.kind, " - ", taglink(o)]]
        return tag

summarypages = [
    ModuleIndexPage,
    ClassIndexPage,
    IndexPage,
    NameIndexPage,
    UndocumentedSummaryPage,
    ]

<|endoftext|>


<commit_before>from setuptools import setup,find_packages

setup(name='pyjade',
      version = '2.0.1',
      download_url = 'git@github.com:syrusakbary/pyjade.git',
      packages = find_packages(),
      author = 'Syrus Akbary',
      author_email = 'me@syrusakbary.com',
      description = 'Jade syntax template adapter for Django, Jinja2, Mako and Tornado templates',
      long_description=open('README.rst').read(),
      keywords = 'jade template converter',
      url = 'http://github.com/syrusakbary/pyjade',
      license = 'MIT',
      entry_points = {
          'console_scripts' : ['pyjade = pyjade.convert:convert_file',]
      },
      install_requires = ['six'],
    )
<commit_msg>Update pyjade version<commit_after>from setuptools import setup,find_packages

setup(name='pyjade',
      version = '2.0.3',
      download_url = 'git@github.com:syrusakbary/pyjade.git',
      packages = find_packages(),
      author = 'Syrus Akbary',
      author_email = 'me@syrusakbary.com',
      description = 'Jade syntax template adapter for Django, Jinja2, Mako and Tornado templates',
      long_description=open('README.rst').read(),
      keywords = 'jade template converter',
      url = 'http://github.com/syrusakbary/pyjade',
      license = 'MIT',
      entry_points = {
          'console_scripts' : ['pyjade = pyjade.convert:convert_file',]
      },
      install_requires = ['six'],
    )
<|endoftext|>


<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# __BEGIN_LICENSE__
#  Copyright (c) 2009-2013, United States Government as represented by the
#  Administrator of the National Aeronautics and Space Administration. All
#  rights reserved.
#
#  The NGT platform is licensed under the Apache License, Version 2.0 (the
#  "License"); you may not use this file except in compliance with the
#  License. You may obtain a copy of the License at
#  http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
# __END_LICENSE__

"""
General system related utilities
"""

import sys, os, re, shutil, subprocess, string, time, errno, multiprocessing
import os.path as P
import asp_string_utils, asp_cmd_utils

def die(msg, code=-1):
    '''Exit the program with a message'''
    print >>sys.stderr, msg
    sys.exit(code)

def verify_python_version_is_supported():
    '''Verifies that a supported version of Python is being used.'''

    if sys.version_info < (2, 6, 0):
        print('\nERROR: Must use Python 2.6.x or 2.7.x.')
        sys.exit(1)

    if sys.version_info[0] > 2:
        print('\nERROR: Python 3 is not supported, must use Python 2.6.x or 2.7.x')
        sys.exit(1)

def get_prog_version(prog):
    '''Get the version of a command line program.'''
    try:
        p = subprocess.Popen([prog,"--version"], stdout=subprocess.PIPE)
        out, err = p.communicate()
    except:
        raise Exception("Could not find: " + prog)
    if p.returncode != 0:
        raise Exception("Checking " + prog + " version caused errors")

    m = re.match("^.*? ([\d\.]+)", out)
    if not m:
        raise Exception("Could not find " + prog + " version")
    return m.group(1)

def get_num_cpus():
    """Return the number of CPUs on the current machine."""

    import sys
    if sys.version_info < (2, 6, 0):
        num_cpus = 8
    else:
        from multiprocessing import cpu_count
        num_cpus = cpu_count()

    return num_cpus

def checkIfToolExists(toolName):
    """Returns true if the system knows about the utility with this name (it is on the PATH)"""

    # Look for the tool using the 'which' command
    cmd = ['which', toolName]
    p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    translateOut, err = p.communicate()

    # Check if that command failed to find the file
    failString = 'no ' + toolName + ' in ('
    if translateOut.find(failString) >= 0:
        raise Exception('Missing required executable "' + toolName + '", please add it to your PATH.')
    else:
        return True

# Find if a program is in the path
def which(program):

    checkIfToolExists(program)

    def is_exe(fpath):
        return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

    fpath, fname = os.path.split(program)
    if fpath:
        if is_exe(program):
            return program
    else:
        for path in os.environ["PATH"].split(os.pathsep):
            path = path.strip('"')
            exe_file = os.path.join(path, program)
            if is_exe(exe_file):
                return exe_file

    return None

def getNumNodesInList(nodesListPath):
    """Get number of Pleiades nodes listed in a file"""

    if nodesListPath is None:
        return 1 # local machine

    # Count the number of nodes without repetition
    # (need this for Pleiades).
    nodes     = {}
    num_nodes = 0
    try:
        fileHandle = open(nodesListPath, "r")
        for line in fileHandle:
            if re.match('^\s*$', line): continue # skip empty lines
            matches = re.match('^\s*([^\s]*)', line)
            if matches:
                nodes[matches.group(1)] = 1

        num_nodes = len(nodes)
    except Exception as e: # Fail on exception
        die(e)
    if num_nodes == 0:
        raise Exception('The list of computing nodes is empty')

    return num_nodes

def check_parallel_version():
    # This error will never be reached for users of our packaged final
    # product as that one bundles 'parallel' with it.
    ver = get_prog_version('parallel')
    if ver < '2013':
        die("Expecting a version of GNU parallel from at least 2013.")

def runInGnuParallel(numParallelProcesses, commandString, argumentFilePath, parallelArgs=[], nodeListPath=None, verbose=False):
    """Use GNU Parallel to spread task across multiple computers and processes"""

    # Make sure GNU parallel is installed
    if not checkIfToolExists('parallel'):
        raise Exception('Need GNU Parallel to distribute the jobs.')

    # Ensure our 'parallel' is not out of date
    check_parallel_version()

    # Use GNU parallel with given number of processes.
    # Let output be interspersed, read input series from file
    # Start in the same directory on remote machines. Ensure
    # that vital env variables are copied over.
    cmd = ['parallel',  '--workdir', os.getcwd(), '-u',
           '--env', 'PATH', '--env', 'PYTHONPATH', '--env', 'ISISROOT',
           '--env', 'ISIS3DATA', '-a', argumentFilePath]

    # Add number of processes if specified (default is one job per CPU core)
    if numParallelProcesses is not None:
        cmd += ['-P', str(numParallelProcesses)]

    # Add list of nodes as argument to the parallel tool if it is available
    if nodeListPath is not None:
        cmd += ['--sshloginfile', nodeListPath]

    # Append any additional arguments to parallel
    cmd += parallelArgs

    # Append the actual command we want to call to the GNU Parallel call
    cmd += [commandString]

    if verbose: # Echo the command line call we are about to make
        print(" ".join(cmd))

    returnCode = subprocess.call(cmd)
    return returnCode

# When user-exposed ASP executables are installed, they are in
# 'bin'. Otherwise, in dev mode, they are in the same dir as __file__.
# We prefer absolute paths below, in case some intermediate directories
# do not exist.
def bin_path(prog, **kw):
    currpath = kw.get('path', P.dirname(P.abspath(__file__)))
    binpath = os.path.abspath(P.join(currpath, '..', 'bin', prog))
    if not P.isfile(binpath):
        binpath = os.path.abspath(P.join(currpath, '..', 'Tools', prog))
    if not P.isfile(binpath):
        binpath = os.path.abspath(P.join(currpath, prog))
    return binpath

# When hidden ASP executables are installed, they are in
# 'libexec'. Otherwise, in dev mode, they are in the same dir as
# __file__.
def libexec_path(prog, **kw):
    currpath = kw.get('path', P.dirname(P.abspath(__file__)))
    libexecpath = os.path.abspath(P.join(currpath, '..', 'libexec', prog))
    if not P.isfile(libexecpath):
        libexecpath = os.path.abspath(P.join(currpath, '..', 'Tools', prog))
    if not P.isfile(libexecpath):
        libexecpath = os.path.abspath(P.join(currpath, prog))

    if not P.isfile(libexecpath):
        # Could not find prog in libexec either. We will come
        # here only for executables like gdalinfo that will
        # be packages in the release, but are not yet
        # in dev mode. Just print a warning and hope
        # this tool is somewhere in user's path.
        print("Could not find: " + libexecpath)
        libexecpath = which(prog)
        if libexecpath is None:
            raise Exception('Could not find: ' + prog)
        print("Using instead: " + libexecpath)

    return libexecpath

# mkdir without throw
def mkdir_p(path):
    try:
        os.makedirs(path)
    except OSError:
        pass

# Execute a given command stored in the libexec directory and parse
# its output. The output format is expected to be lines of
# comma-separated values.  The first value on each line becomes the
# output variable name, the other values are read into the array of
# variable values.
def run_and_parse_output(cmd, args, sep, verbose, **kw ):
    libexecpath = libexec_path(cmd)
    call = [libexecpath]
    call.extend(args)

    if verbose:
        print(" ".join(call))

    try:
        p = subprocess.Popen(call, stdout=subprocess.PIPE)
    except OSError as e:
        raise Exception('%s: %s' % (libexecpath, e))
    (stdout, stderr) = p.communicate()

    p.wait()
    if p.returncode != 0:
        print(stdout)
        print(stderr)
        raise Exception('Failed executing: ' + " ".join(call))
    data = {}
    if verbose:
        if stdout is not None: print(stdout)
        if stderr is not None: print(stderr)

    for line in stdout.split('\n'):

        # Print warning messages to stdout
        if re.match("^Warning", line): print(line)

        if sep in line:
            keywords = line.split(sep)
            for index, item in enumerate(keywords):
                # Strip whitespace from ends
                keywords[index] = item.strip(' \t\n\r')
            data[keywords[0]] = keywords[1:]

    return data

def run_with_return_code(cmd, verbose=False):

    if verbose:
        print(" ".join(cmd))

    try:
        p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
    except OSError as e:
        print('Error: %s: %s' % (" ".join(cmd), e))

    (stdout, stderr) = p.communicate()
    p.wait()

    if p.returncode != 0 and verbose:
        if stdout is not None: print(stdout)
        if stderr is not None: print(stderr)
        print ('Failed executing: ' + " ".join(cmd))

    return p.returncode

# TODO: Improve this function a bit
def executeCommand(cmd,
                   outputPath=None,      # If given, throw if the file is not created.  Don't run if it already exists.
                   suppressOutput=False, # If true, don't print anything!
                   redo=False):          # If true, run even if outputPath already exists.
    '''Executes a command with multiple options'''

    if cmd == '': # An empty task
        return False

    # Convert the input to list format if needed
    if not asp_string_utils.isNotString(cmd):
        cmd = asp_string_utils.stringToArgList(cmd)

    # Run the command if conditions are met
    if redo or (not outputPath) or (not os.path.exists(outputPath)):

        if suppressOutput: # Process silently
            FNULL = open(os.devnull, 'w')
            subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
        else: # Display output
            print " ".join(cmd)
            subprocess.call(cmd)

    # Optionally check that the output file was created
    if outputPath and (not os.path.exists(outputPath)):
        raise asp_cmd_utils.CmdRunException('Failed to create output file: ' + outputPath)
    return True
<commit_msg>asp_system_utils: Fix gnu parallel issue on certain machines<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# __BEGIN_LICENSE__
#  Copyright (c) 2009-2013, United States Government as represented by the
#  Administrator of the National Aeronautics and Space Administration. All
#  rights reserved.
#
#  The NGT platform is licensed under the Apache License, Version 2.0 (the
#  "License"); you may not use this file except in compliance with the
#  License. You may obtain a copy of the License at
#  http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
# __END_LICENSE__

"""
General system related utilities
"""

import sys, os, re, shutil, subprocess, string, time, errno, multiprocessing
import os.path as P
import asp_string_utils, asp_cmd_utils

def die(msg, code=-1):
    '''Exit the program with a message'''
    print >>sys.stderr, msg
    sys.exit(code)

def verify_python_version_is_supported():
    '''Verifies that a supported version of Python is being used.'''

    if sys.version_info < (2, 6, 0):
        print('\nERROR: Must use Python 2.6.x or 2.7.x.')
        sys.exit(1)

    if sys.version_info[0] > 2:
        print('\nERROR: Python 3 is not supported, must use Python 2.6.x or 2.7.x')
        sys.exit(1)

def get_prog_version(prog):
    '''Get the version of a command line program.'''
    try:
        p = subprocess.Popen([prog,"--version"], stdout=subprocess.PIPE)
        out, err = p.communicate()
    except:
        raise Exception("Could not find: " + prog)
    if p.returncode != 0:
        raise Exception("Checking " + prog + " version caused errors")

    # This is a fix for sometimes GNU Parallel printing a warning at the beginning
    for line in out.split("\n"):
        m = re.match("^.*?warning", line, re.IGNORECASE)
        if m: continue
        m = re.match("^.*? ([\d\.]+)", line)
        if not m:
           raise Exception("Could not find " + prog + " version")
        return m.group(1)
    return ""

def get_num_cpus():
    """Return the number of CPUs on the current machine."""

    import sys
    if sys.version_info < (2, 6, 0):
        num_cpus = 8
    else:
        from multiprocessing import cpu_count
        num_cpus = cpu_count()

    return num_cpus

def checkIfToolExists(toolName):
    """Returns true if the system knows about the utility with this name (it is on the PATH)"""

    # Look for the tool using the 'which' command
    cmd = ['which', toolName]
    p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    translateOut, err = p.communicate()

    # Check if that command failed to find the file
    failString = 'no ' + toolName + ' in ('
    if translateOut.find(failString) >= 0:
        raise Exception('Missing required executable "' + toolName + '", please add it to your PATH.')
    else:
        return True

# Find if a program is in the path
def which(program):

    checkIfToolExists(program)

    def is_exe(fpath):
        return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

    fpath, fname = os.path.split(program)
    if fpath:
        if is_exe(program):
            return program
    else:
        for path in os.environ["PATH"].split(os.pathsep):
            path = path.strip('"')
            exe_file = os.path.join(path, program)
            if is_exe(exe_file):
                return exe_file

    return None

def getNumNodesInList(nodesListPath):
    """Get number of Pleiades nodes listed in a file"""

    if nodesListPath is None:
        return 1 # local machine

    # Count the number of nodes without repetition
    # (need this for Pleiades).
    nodes     = {}
    num_nodes = 0
    try:
        fileHandle = open(nodesListPath, "r")
        for line in fileHandle:
            if re.match('^\s*$', line): continue # skip empty lines
            matches = re.match('^\s*([^\s]*)', line)
            if matches:
                nodes[matches.group(1)] = 1

        num_nodes = len(nodes)
    except Exception as e: # Fail on exception
        die(e)
    if num_nodes == 0:
        raise Exception('The list of computing nodes is empty')

    return num_nodes

def check_parallel_version():
    # This error will never be reached for users of our packaged final
    # product as that one bundles 'parallel' with it.
    ver = get_prog_version('parallel')
    if ver < '2013':
        die("Expecting a version of GNU parallel from at least 2013.")

def runInGnuParallel(numParallelProcesses, commandString, argumentFilePath, parallelArgs=[], nodeListPath=None, verbose=False):
    """Use GNU Parallel to spread task across multiple computers and processes"""

    # Make sure GNU parallel is installed
    if not checkIfToolExists('parallel'):
        raise Exception('Need GNU Parallel to distribute the jobs.')

    # Ensure our 'parallel' is not out of date
    check_parallel_version()

    # Use GNU parallel with given number of processes.
    # Let output be interspersed, read input series from file
    # Start in the same directory on remote machines. Ensure
    # that vital env variables are copied over.
    cmd = ['parallel',  '--workdir', os.getcwd(), '-u',
           '--env', 'PATH', '--env', 'PYTHONPATH', '--env', 'ISISROOT',
           '--env', 'ISIS3DATA', '-a', argumentFilePath]

    # Add number of processes if specified (default is one job per CPU core)
    if numParallelProcesses is not None:
        cmd += ['-P', str(numParallelProcesses)]

    # Add list of nodes as argument to the parallel tool if it is available
    if nodeListPath is not None:
        cmd += ['--sshloginfile', nodeListPath]

    # Append any additional arguments to parallel
    cmd += parallelArgs

    # Append the actual command we want to call to the GNU Parallel call
    cmd += [commandString]

    if verbose: # Echo the command line call we are about to make
        print(" ".join(cmd))

    returnCode = subprocess.call(cmd)
    return returnCode

# When user-exposed ASP executables are installed, they are in
# 'bin'. Otherwise, in dev mode, they are in the same dir as __file__.
# We prefer absolute paths below, in case some intermediate directories
# do not exist.
def bin_path(prog, **kw):
    currpath = kw.get('path', P.dirname(P.abspath(__file__)))
    binpath = os.path.abspath(P.join(currpath, '..', 'bin', prog))
    if not P.isfile(binpath):
        binpath = os.path.abspath(P.join(currpath, '..', 'Tools', prog))
    if not P.isfile(binpath):
        binpath = os.path.abspath(P.join(currpath, prog))
    return binpath

# When hidden ASP executables are installed, they are in
# 'libexec'. Otherwise, in dev mode, they are in the same dir as
# __file__.
def libexec_path(prog, **kw):
    currpath = kw.get('path', P.dirname(P.abspath(__file__)))
    libexecpath = os.path.abspath(P.join(currpath, '..', 'libexec', prog))
    if not P.isfile(libexecpath):
        libexecpath = os.path.abspath(P.join(currpath, '..', 'Tools', prog))
    if not P.isfile(libexecpath):
        libexecpath = os.path.abspath(P.join(currpath, prog))

    if not P.isfile(libexecpath):
        # Could not find prog in libexec either. We will come
        # here only for executables like gdalinfo that will
        # be packages in the release, but are not yet
        # in dev mode. Just print a warning and hope
        # this tool is somewhere in user's path.
        print("Could not find: " + libexecpath)
        libexecpath = which(prog)
        if libexecpath is None:
            raise Exception('Could not find: ' + prog)
        print("Using instead: " + libexecpath)

    return libexecpath

# mkdir without throw
def mkdir_p(path):
    try:
        os.makedirs(path)
    except OSError:
        pass

# Execute a given command stored in the libexec directory and parse
# its output. The output format is expected to be lines of
# comma-separated values.  The first value on each line becomes the
# output variable name, the other values are read into the array of
# variable values.
def run_and_parse_output(cmd, args, sep, verbose, **kw ):
    libexecpath = libexec_path(cmd)
    call = [libexecpath]
    call.extend(args)

    if verbose:
        print(" ".join(call))

    try:
        p = subprocess.Popen(call, stdout=subprocess.PIPE)
    except OSError as e:
        raise Exception('%s: %s' % (libexecpath, e))
    (stdout, stderr) = p.communicate()

    p.wait()
    if p.returncode != 0:
        print(stdout)
        print(stderr)
        raise Exception('Failed executing: ' + " ".join(call))
    data = {}
    if verbose:
        if stdout is not None: print(stdout)
        if stderr is not None: print(stderr)

    for line in stdout.split('\n'):

        # Print warning messages to stdout
        if re.match("^Warning", line): print(line)

        if sep in line:
            keywords = line.split(sep)
            for index, item in enumerate(keywords):
                # Strip whitespace from ends
                keywords[index] = item.strip(' \t\n\r')
            data[keywords[0]] = keywords[1:]

    return data

def run_with_return_code(cmd, verbose=False):

    if verbose:
        print(" ".join(cmd))

    try:
        p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
    except OSError as e:
        print('Error: %s: %s' % (" ".join(cmd), e))

    (stdout, stderr) = p.communicate()
    p.wait()

    if p.returncode != 0 and verbose:
        if stdout is not None: print(stdout)
        if stderr is not None: print(stderr)
        print ('Failed executing: ' + " ".join(cmd))

    return p.returncode

# TODO: Improve this function a bit
def executeCommand(cmd,
                   outputPath=None,      # If given, throw if the file is not created.  Don't run if it already exists.
                   suppressOutput=False, # If true, don't print anything!
                   redo=False):          # If true, run even if outputPath already exists.
    '''Executes a command with multiple options'''

    if cmd == '': # An empty task
        return False

    # Convert the input to list format if needed
    if not asp_string_utils.isNotString(cmd):
        cmd = asp_string_utils.stringToArgList(cmd)

    # Run the command if conditions are met
    if redo or (not outputPath) or (not os.path.exists(outputPath)):

        if suppressOutput: # Process silently
            FNULL = open(os.devnull, 'w')
            subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
        else: # Display output
            print " ".join(cmd)
            subprocess.call(cmd)

    # Optionally check that the output file was created
    if outputPath and (not os.path.exists(outputPath)):
        raise asp_cmd_utils.CmdRunException('Failed to create output file: ' + outputPath)
    return True
<|endoftext|>