コード例 #1
0
ファイル: update_conda.py プロジェクト: civanlink/addutils
def install_from_pip(distribution_name):
    command = install.InstallCommand()
    opt, args = command.parser.parse_args()
    try:
        r_set = command.run(opt, [distribution_name])
        r_set = command.run(opt, [distribution_name])
    except Exception as e:
        print(e)
        print("Error installing %s, please try manually" % distribution_name)
コード例 #2
0
 def run(self):
     if install is None:
         raise errors.DistutilsSetupError(
             'could not find pip.install module')
     if self._pip_args:
         cmd = install.InstallCommand()
         args = cmd.cmd_opts.parser.parse_args(self._pip_args)
         cmd.run(*args)
     else:
         self.warn('no requirements to install')
コード例 #3
0
 def thread_do(self):
     # TODO: change import to popen https://github.com/pypa/pip/issues/3889
     # NOTE: which pip will use? pip, pip2 or pip3?
     from pip.commands import install
     from pip.utils.logging import _log_state
     leaf = self.leaf
     _log_state.indentation = 0
     install.InstallCommand().main(
         ['--upgrade', '--user',
          leaf.object.get("name")])
     uiutils.show_notification(_("Plugin Installed"),
                               "Now enable {} at preferences".format(
                                   leaf.name),
                               icon_name='info')
コード例 #4
0
def force_install_reqs():
    import logging

    log = logging.getLogger("pip")
    handler = logging.StreamHandler(sys.stderr)
    handler.setFormatter(logging.Formatter("[pip] %(message)s"))
    log.addHandler(handler)
    log.setLevel(logging.INFO)

    log.info("READTHEDOCS is set, force-installing requirements.txt")

    from pip.commands import install
    req = os.path.join(os.path.dirname(__file__), "requirements.txt")
    cmd = install.InstallCommand()
    options, args = cmd.parse_args(["-v", "-U", "-r", req])
    cmd.run(options, args)
コード例 #5
0
from pip import get_installed_distributions
from pip.commands import install

install_cmd = install.InstallCommand()

options, args = install_cmd.parse_args([package.project_name
                                        for package in
                                        get_installed_distributions()])

options.upgrade = True
install_cmd.run(options, args)  # Chuck this in a try/except and print as wanted

コード例 #6
0
def pip_dump_dependencies(name, download_cache=download_cache):
    """
    Returns a dictionary of involved packages and their direct dependencies, uses pip's private APIs.
    Side effects: removes pip build directory before starting (if one existed),
                  populates the downloads cache in `download_cache',
                  populates the build cache with unpacked tarballs
    """
    cmd = install.InstallCommand()
    options, args = cmd.parse_args([name])
    index_urls = [options.index_url] + options.extra_index_urls
    finder = cmd._build_package_finder(options, index_urls, session)

    requirement_set = RequirementSet(
        build_dir=options.build_dir,
        src_dir=options.src_dir,
        download_dir=options.download_dir,
        download_cache=download_cache,
        upgrade=options.upgrade,
        as_egg=options.as_egg,
        ignore_installed=options.ignore_installed,
        ignore_dependencies=options.ignore_dependencies,
        force_reinstall=options.force_reinstall,
        use_user_site=options.use_user_site,
        target_dir=temp_target_dir,
        session=session,
        pycompile=options.compile,
    )

    # i/o
    shutil.rmtree(options.build_dir)

    requirement_set.add_requirement(InstallRequirement.from_line(name, None))

    # i/o
    requirement_set.prepare_files(finder,
                                  force_root_egg_info=cmd.bundle,
                                  bundle=cmd.bundle)

    def safe_requirements(self):
        """
        safe implementation of pip.req.InstallRequirement.requirements() generator, doesn't blow up with OSError
        """

        in_extra = None
        try:
            for line in self.egg_info_lines('requires.txt'):
                match = self._requirements_section_re.match(line.lower())
                if match:
                    in_extra = match.group(1)
                    continue
                if in_extra:
                    logger.debug('skipping extra %s' % in_extra)
                    # Skip requirement for an extra we aren't requiring
                    continue
                yield line
        except OSError:
            pass

    def req_string_to_name_and_specs(s):
        p = pkg_resources.Requirement.parse(s)
        return (p.project_name, p.specs)

    def req_safe_version(req):
        try:
            return req.pkg_info()['version']
        except:
            return ''

    reqs = dict(requirement_set.requirements)
    human_reqs = dict(
        (req.name,
         map(req_string_to_name_and_specs, list(safe_requirements(req))))
        for req in reqs.values())
    actual_versions = dict(
        (req.name, req_safe_version(req)) for req in reqs.values())
    return human_reqs, actual_versions
コード例 #7
0
ファイル: pcli.py プロジェクト: samie820/Social-web-app
def pip_install(package):
    command = install.InstallCommand()
    opts, args = command.parser.parse_args([])
    click.echo("Installing {}...".format(package))
    command.run(opts, [package])
コード例 #8
0
def install_wheel(wheel):
    install = pip_installer.InstallCommand(isolated=True)
    install.run(*install.parse_args("{} --no-cache-dir --upgrade".format(
        wheel).split()))
コード例 #9
0
dependencies['REG_SZ']             = '_winreg' if os.name is 'nt' else None
dependencies['CloseKey']           = '_winreg' if os.name is 'nt' else None
dependencies['DeleteValue']        = '_winreg' if os.name is 'nt' else None
dependencies['OpenKey']            = '_winreg' if os.name is 'nt' else None
dependencies['SetValueEx']         = '_winreg' if os.name is 'nt' else None

for module in dependencies:
    try:
        package = dependencies[module]
        if module not in globals():
            try:
                exec "from %s import %s" % (package, module)
            except:
                try:
                    main_package = package.split('.')[0]
                    install = pip.InstallCommand().main([main_package])
                    exec "from %s import %s" % (package, module)
                except Exception as x:
                    pass
    except Exception as e:
        pass



BLOCK_SIZE = 32
PADDING = '{'
imports = list()
output = list()


choice      = lambda items: items[int([n for n in [ord(os.urandom(1)) for i in xrange(1000)] if n < len(items)][0])]