Пример #1
0
    def get_hashes_for_one(self, ireq):
        if not self.finder:
            from .dependencies import get_finder
            finder_args = []
            if self.allow_prereleases:
                finder_args.append('--pre')
            self.finder = get_finder(*finder_args)

        if ireq.editable:
            return set()

        from pip_shims import VcsSupport
        vcs = VcsSupport()
        if ireq.link and ireq.link.scheme in vcs.all_schemes and 'ssh' in ireq.link.scheme:
            return set()

        if not is_pinned_requirement(ireq):
            raise TypeError("Expected pinned requirement, got {}".format(ireq))

        matching_candidates = set()
        with self.allow_all_wheels():
            from .dependencies import find_all_matches
            matching_candidates = (find_all_matches(
                self.finder, ireq, pre=self.allow_prereleases))

        return {
            self.hash_cache.get_hash(candidate.location)
            for candidate in matching_candidates
        }
Пример #2
0
 def get_hash(self, location):
     from pip_shims import VcsSupport
     # if there is no location hash (i.e., md5 / sha256 / etc) we on't want to store it
     hash_value = None
     vcs = VcsSupport()
     orig_scheme = location.scheme
     new_location = copy.deepcopy(location)
     if orig_scheme in vcs.all_schemes:
         new_location.url = new_location.url.split("+", 1)[-1]
     can_hash = new_location.hash
     if can_hash:
         # hash url WITH fragment
         hash_value = self._get_file_hash(new_location.url) if not new_location.url.startswith("ssh") else None
     if not hash_value:
         hash_value = self._get_file_hash(new_location)
         hash_value = hash_value.encode('utf8')
     if can_hash:
         self.set(new_location.url, hash_value)
     return hash_value.decode('utf8')
Пример #3
0
def test_vcs_support():
    vcs = VcsSupport()
    assert "git+https" in vcs.all_schemes
Пример #4
0
 def get_repo_instance(self):
     from pip_shims import VcsSupport
     VCS_SUPPORT = VcsSupport()
     backend = VCS_SUPPORT._registry.get(self.vcs_type)
     return backend(url=self.url)
Пример #5
0
# -*- coding=utf-8 -*-
import attr
from pip_shims import VcsSupport, parse_version, pip_version
import vistir
import os


VCS_SUPPORT = VcsSupport()


@attr.s
class VCSRepository(object):
    url = attr.ib()
    name = attr.ib()
    checkout_directory = attr.ib()
    vcs_type = attr.ib()
    commit_sha = attr.ib(default=None)
    ref = attr.ib(default=None)
    repo_instance = attr.ib()

    @repo_instance.default
    def get_repo_instance(self):
        backend = VCS_SUPPORT._registry.get(self.vcs_type)
        return backend(url=self.url)

    @property
    def is_local(self):
        url = self.url
        if '+' in url:
            url = url.split('+')[1]
        return url.startswith("file")
Пример #6
0
# -*- coding=utf-8 -*-
from __future__ import absolute_import

import logging
import os

import six

from six.moves.urllib.parse import urlparse, urlsplit

from pip_shims import (Command, VcsSupport, cmdoptions, is_archive_file,
                       is_installable_dir)
from vistir.compat import Path
from vistir.path import is_valid_url, ensure_mkdir_p

VCS_ACCESS = VcsSupport()
VCS_LIST = ("git", "svn", "hg", "bzr")
VCS_SCHEMES = []
SCHEME_LIST = ("http://", "https://", "ftp://", "ftps://", "file://")

if not VCS_SCHEMES:
    VCS_SCHEMES = VcsSupport().all_schemes


def setup_logger():
    logger = logging.getLogger("requirementslib")
    loglevel = logging.DEBUG
    handler = logging.StreamHandler()
    handler.setLevel(loglevel)
    logger.addHandler(handler)
    logger.setLevel(loglevel)