Esempio n. 1
0
def main(initial_args=None):
    if initial_args is None:
        initial_args = sys.argv[1:]
    autocomplete()
    version_control()
    options, args = parser.parse_args(initial_args)
    if options.help and not args:
        args = ['help']
    if not args:
        parser.error(
            'You must give a command (use "pip help" to see a list of commands)'
        )
    command = args[0].lower()
    load_command(command)
    if command not in command_dict:
        close_commands = difflib.get_close_matches(command, command_names())
        if close_commands:
            guess = close_commands[0]
            if args[1:]:
                guess = "%s %s" % (guess, " ".join(args[1:]))
        else:
            guess = 'install %s' % command
        error_dict = {
            'arg': command,
            'guess': guess,
            'script': os.path.basename(sys.argv[0])
        }
        parser.error('No command by the name %(script)s %(arg)s\n  '
                     '(maybe you meant "%(script)s %(guess)s")' % error_dict)
    command = command_dict[command]
    return command.main(args[1:], options)
Esempio n. 2
0
def main(initial_args=None):
    if initial_args is None:
        initial_args = sys.argv[1:]
    autocomplete()
    options, args = parser.parse_args(initial_args)
    if options.help and not args:
        args = ["help"]
    if not args:
        parser.error("You must give a command " '(use "%s help" to see a list of commands)' % get_prog())
    command = args[0].lower()
    load_command(command)
    if command not in command_dict:
        close_commands = difflib.get_close_matches(command, command_names())
        if close_commands:
            guess = close_commands[0]
            if args[1:]:
                guess = "%s %s" % (guess, " ".join(args[1:]))
        else:
            guess = "install %s" % command
        error_dict = {"arg": command, "guess": guess, "script": os.path.basename(sys.argv[0])}
        parser.error(
            "No command by the name %(script)s %(arg)s\n  " '(maybe you meant "%(script)s %(guess)s")' % error_dict
        )
    command = command_dict[command]
    return command.main(args[1:], options)
Esempio n. 3
0
def main(initial_args=None):
    if initial_args is None:
        initial_args = sys.argv[1:]
    autocomplete()
    version_control()
    options, args = parser.parse_args(initial_args)
    if options.help and not args:
        args = ['help']
    if not args:
        parser.error('You must give a command (use "pip help" to see a list of commands)')
    command = args[0].lower()
    load_command(command)
    if command not in command_dict:
        close_commands = difflib.get_close_matches(command, command_names())
        if close_commands:
            guess = close_commands[0]
            if args[1:]:
                guess = "{0!s} {1!s}".format(guess, " ".join(args[1:]))
        else:
            guess = 'install {0!s}'.format(command)
        error_dict = {'arg': command, 'guess': guess,
                      'script': os.path.basename(sys.argv[0])}
        parser.error('No command by the name %(script)s %(arg)s\n  '
                     '(maybe you meant "%(script)s %(guess)s")' % error_dict)
    command = command_dict[command]
    return command.main(initial_args, args[1:], options)
Esempio n. 4
0
def update(upgrade=False):
    '''
    Install packages in virtual environment (call pip install -r
    DJANGO_ENV_UPDATE_REQUIREMENTS)
    '''
    global path, PROJECT_PATH
    if not os.path.isdir(path):
        log.error('Path with environment (%s) not exist. Run `env_create` '
                  'first')
        return
    req_name = getattr(settings, 'DJANGO_ENV_UPDATE_REQUIREMENTS',
                                  DJANGO_ENV_UPDATE_REQUIREMENTS)
    req = req_name 

    if os.path.isabs(req_name):
        req = req_name
    else:
        req = os.path.join(PROJECT_PATH, req_name)

    log.info('Updating environment in: %s' % path)
    import virtualenv as ve
    log.info('Updating pip packages from: %s' % req)
    try:
        from pip.baseparser import parser
        import pip.commands.install
        i = pip.commands.install.InstallCommand()
        params = ['install', '-r', req]
        params.extend(
                 getattr(settings, 'DJANGO_ENV_UPDATE_PIP_ARGUMENTS',
                         DJANGO_ENV_UPDATE_PIP_ARGUMENTS)
        )

        if upgrade:
            params.append('-U')
        opt, args = parser.parse_args(params)
        opt.venv = path
        opt.venv_base = path
        opt.respect_venv = True
        opt.require_venv = True
        opt.no_input = True
        opt.verbose = 2
        log.debug('PIP parsed opts: %s' % opt)
        log.debug('PIP parsed args: %s' % args)

        log.debug('PIP exec: %s' % i.main(args, args[1:], opt))
    except Exception as e:
        log.exception("Error in PIP: %s", e)
        return
Esempio n. 5
0
def main(initial_args=None):
    if initial_args is None:
        initial_args = sys.argv[1:]
    autocomplete()
    options, args = parser.parse_args(initial_args)
    if options.help and not args:
        args = ['help']
    if not args:
        parser.error('You must give a command (use "pip help" see a list of commands)')
    command = args[0].lower()
    load_command(command)
    ## FIXME: search for a command match?
    if command not in command_dict:
        parser.error('No command by the name %(script)s %(arg)s\n  (maybe you meant "%(script)s install %(arg)s")'
                     % dict(script=os.path.basename(sys.argv[0]), arg=command))
    command = command_dict[command]
    return command.main(initial_args, args[1:], options)
Esempio n. 6
0
def update(upgrade=False):
    """
    Install packages in virtual environment (call pip install -r
    DJANGO_ENV_UPDATE_REQUIREMENTS)
    """
    global path, PROJECT_PATH
    if not os.path.isdir(path):
        log.error("Path with environment (%s) not exist. Run `env_create` " "first")
        return
    req_name = getattr(settings, "DJANGO_ENV_UPDATE_REQUIREMENTS", DJANGO_ENV_UPDATE_REQUIREMENTS)
    req = req_name

    if os.path.isabs(req_name):
        req = req_name
    else:
        req = os.path.join(PROJECT_PATH, req_name)

    log.info("Updating environment in: %s" % path)
    import virtualenv as ve

    log.info("Updating pip packages from: %s" % req)
    try:
        from pip.baseparser import parser
        import pip.commands.install

        i = pip.commands.install.InstallCommand()
        params = ["install", "-r", req]
        params.extend(getattr(settings, "DJANGO_ENV_UPDATE_PIP_ARGUMENTS", DJANGO_ENV_UPDATE_PIP_ARGUMENTS))

        if upgrade:
            params.append("-U")
        opt, args = parser.parse_args(params)
        opt.venv = path
        opt.venv_base = path
        opt.respect_venv = True
        opt.require_venv = True
        opt.no_input = True
        opt.verbose = 2
        log.debug("PIP parsed opts: %s" % opt)
        log.debug("PIP parsed args: %s" % args)

        log.debug("PIP exec: %s" % i.main(args, args[1:], opt))
    except Exception as e:
        log.exception("Error in PIP: %s", e)
        return
Esempio n. 7
0
def main(initial_args=None):
    if initial_args is None:
        initial_args = sys.argv[1:]
    autocomplete()
    options, args = parser.parse_args(initial_args)
    if options.help and not args:
        args = ['help']
    if not args:
        parser.error('You must give a command?')
    cmd = 'requisite'
    fn = 'requisite.commands.%s' % cmd
    try:
        __import__(fn)
    except ImportError:
        pass

    command = command_dict[cmd]
    return command.main(args, options)
Esempio n. 8
0
from setuptools import setup, find_packages

from pip.req import parse_requirements as parse_reqs

# Compatibility with older versions of pip
pip_dist = pkg_resources.get_distribution('pip')
pip_version = tuple(map(int, pip_dist.version.split('.')))

# Use a base partial that will be updated depending on the version of pip
parse_requirements = functools.partial(parse_reqs, options=None)

if pip_version < (1, 2):
    # pip versions before 1.2 require an options keyword for using it outside
    # of invoking a pip shell command
    from pip.baseparser import parser
    parse_requirements.keywords['options'] = parser.parse_args()[0]

if pip_version >= (1, 5):
    # pip 1.5 introduced a session kwarg that is required in later versions
    from pip.download import PipSession
    parse_requirements.keywords['session'] = PipSession()

setup(
    name='helga-jira',
    version='0.1.2',
    description=("A helga plugin that can be used to store responses "
                 "that can be returned from a question"),
    classifiers=[
        'Development Status :: 4 - Beta',
        'Topic :: Communications :: Chat :: Internet Relay Chat',
        'Framework :: Twisted',
Esempio n. 9
0
# Get the long description from the relevant file
with open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
    long_description = f.read()

# Compatibility with older versions of pip
pip_dist = pkg_resources.get_distribution('pip')
pip_version = tuple(map(int, pip_dist.version.split('.')))

# Use a base partial that will be updated depending on the version of pip
parse_partial = functools.partial(parse_reqs, options=None)

if pip_version < (1, 2):
    # pip versions before 1.2 require an options keyword for using it outside
    # of invoking a pip shell command
    from pip.baseparser import parser
    parse_partial.keywords['options'] = parser.parse_args()[0]

if pip_version >= (1, 5):
    # pip 1.5 introduced a session kwarg that is required in later versions
    from pip.download import PipSession
    parse_partial.keywords['session'] = PipSession()


def parse_requirements(requirements_path='requirements.txt'):
    return [str(req.req) for req in parse_partial(requirements_path)]


setup(
    name='service_layer',

    # Versions should comply with PEP440.  For a discussion on single-sourcing
Esempio n. 10
0
from pip.req import parse_requirements as parse_reqs


# Compatibility with older versions of pip
pip_dist = pkg_resources.get_distribution("pip")
pip_version = tuple(map(int, pip_dist.version.split(".")))

# Use a base partial that will be updated depending on the version of pip
parse_requirements = functools.partial(parse_reqs, options=None)

if pip_version < (1, 2):
    # pip versions before 1.2 require an options keyword for using it outside
    # of invoking a pip shell command
    from pip.baseparser import parser

    parse_requirements.keywords["options"] = parser.parse_args()[0]

if pip_version >= (1, 5):
    # pip 1.5 introduced a session kwarg that is required in later versions
    from pip.download import PipSession

    parse_requirements.keywords["session"] = PipSession()


setup(
    name="helga-giphy",
    version="0.1.1",
    description="A command plugin to search giphy for an anmiated gif.",
    classifiers=[
        "Development Status :: 4 - Beta",
        "Topic :: Communications :: Chat :: Internet Relay Chat",
Esempio n. 11
0
import helga


# Compatibility with older versions of pip
pip_dist = pkg_resources.get_distribution('pip')
pip_version = tuple(map(int, pip_dist.version.split('.')))

# Use a base partial that will be updated depending on the version of pip
parse_requirements = functools.partial(parse_reqs, options=None)

if pip_version < (1, 2):
    # pip versions before 1.2 require an options keyword for using it outside
    # of invoking a pip shell command
    from pip.baseparser import parser
    parse_requirements.keywords['options'] = parser.parse_args()[0]

if pip_version >= (1, 5):
    # pip 1.5 introduced a session kwarg that is required in later versions
    from pip.download import PipSession
    parse_requirements.keywords['session'] = PipSession()


# If installing on python 2.6, we need to install the argparse backport
extra_requires = []
if sys.version_info[:2] == (2, 6):
    extra_requires = ['argparse==1.3.0']


class PyTest(TestCommand):
    def finalize_options(self):
import functools
import pkg_resources

from pip.req import parse_requirements as parse_reqs

# Compatibility with older versions of pip
pip_dist = pkg_resources.get_distribution('pip')
pip_version = tuple(map(int, pip_dist.version.split('.')))

# Use a base partial that will be updated depending on the version of pip
parse_partial = functools.partial(parse_reqs, options=None)

if pip_version < (1, 2):
    # pip versions before 1.2 require an options keyword for using it outside
    # of invoking a pip shell command
    from pip.baseparser import parser
    parse_partial.keywords['options'] = parser.parse_args()[0]

if pip_version >= (1, 5):
    # pip 1.5 introduced a session kwarg that is required in later versions
    from pip.download import PipSession
    parse_partial.keywords['session'] = PipSession()


def parse_requirements(requirements_path='requirements.txt'):
    return [str(req.req) for req in parse_partial(requirements_path)]