Exemplo n.º 1
0
    def get_repo_backend(self):
        if self.DEFAULT_RUN_ARGS is None:
            default_run_args = self.monkeypatch_pip()
        else:
            default_run_args = self.DEFAULT_RUN_ARGS
        from pip_shims.shims import VcsSupport

        VCS_SUPPORT = VcsSupport()
        backend = VCS_SUPPORT.get_backend(self.vcs_type)
        # repo = backend(url=self.url)
        if backend.run_command.__func__.__defaults__ != default_run_args:
            backend.run_command.__func__.__defaults__ = default_run_args
        return backend
Exemplo n.º 2
0
    def get_hashes_for_one(self, ireq):
        if not self.finder:
            finder_args = []
            if self.allow_prereleases:
                finder_args.append('--pre')
            self.finder = get_finder(*finder_args)

        if ireq.editable:
            return set()

        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():
            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
        }
Exemplo n.º 3
0
    def get_hashes(self, ireq):
        """
        Given an InstallRequirement, return a set of hashes that represent all
        of the files for a given requirement. Editable requirements return an
        empty set. Unpinned requirements raise a TypeError.
        """
        if ireq.editable:
            return set()

        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))

        # We need to get all of the candidates that match our current version
        # pin, these will represent all of the files that could possibly
        # satisfy this constraint.
        matching_candidates = (
            c for c in clean_requires_python(self.find_all_candidates(ireq.name))
            if c.version in ireq.specifier
        )

        return {
            h for h in map(lambda c: self._hash_cache.get_hash(c.location),
                           matching_candidates) if h is not None
        }
Exemplo n.º 4
0
    def get_hashes(self, ireq):
        """
        Given an InstallRequirement, return a set of hashes that represent all
        of the files for a given requirement. Editable requirements return an
        empty set. Unpinned requirements raise a TypeError.
        """
        if ireq.editable:
            return set()

        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))

        # We need to get all of the candidates that match our current version
        # pin, these will represent all of the files that could possibly
        # satisfy this constraint.
        ### Modification -- this is much more efficient....
        ### modification again -- still more efficient
        matching_candidates = (
            c
            for c in clean_requires_python(self.find_all_candidates(ireq.name))
            if c.version in ireq.specifier)
        # candidates_by_version = lookup_table(all_candidates, key=lambda c: c.version)
        # matching_versions = list(
        #     ireq.specifier.filter((candidate.version for candidate in all_candidates)))
        # matching_candidates = candidates_by_version[matching_versions[0]]

        return {
            h
            for h in map(lambda c: self._hash_cache.get_hash(c.location),
                         matching_candidates) if h is not None
        }
Exemplo n.º 5
0
 def get_hash(self, location):
     # 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(new_location.url)
     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')
Exemplo n.º 6
0
import six
import tomlkit

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

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

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)
    return logger


log = setup_logger()

Exemplo n.º 7
0
from six.moves import Mapping, Sequence, Set, ItemsView
from six.moves.urllib.parse import urlparse, urlsplit

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


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

VCS_SUPPORT = VcsSupport()

if not VCS_SCHEMES:
    VCS_SCHEMES = VCS_SUPPORT.all_schemes


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