How to use the pip._vendor.six function in pip

To help you get started, we’ve selected a few pip examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github karaninder / Face2Face / f2f / lib / python2.7 / site-packages / pip / _vendor / pkg_resources / __init__.py View on Github external
def get_metadata(self, name):
        if not self.egg_info:
            return ""
        value = self._get(self._fn(self.egg_info, name))
        return value.decode('utf-8') if six.PY3 else value
github pantsbuild / pex / pex / vendor / _vendored / pip / pip / _internal / req / req_install.py View on Github external
def __str__(self):
        # type: () -> str
        if self.req:
            s = str(self.req)
            if self.link:
                s += ' from %s' % redact_auth_from_url(self.link.url)
        elif self.link:
            s = redact_auth_from_url(self.link.url)
        else:
            s = ''
        if self.satisfied_by is not None:
            s += ' in %s' % display_path(self.satisfied_by.location)
        if self.comes_from:
            if isinstance(self.comes_from, six.string_types):
                comes_from = self.comes_from  # type: Optional[str]
            else:
                comes_from = self.comes_from.from_path()
            if comes_from:
                s += ' (from %s)' % comes_from
        return s
github karaninder / Face2Face / f2f / lib / python2.7 / site-packages / pip / _internal / req / req_install.py View on Github external
def setup_py(self):
        assert self.source_dir, "No source dir for %s" % self

        setup_py = os.path.join(self.setup_py_dir, 'setup.py')

        # Python2 __file__ should not be unicode
        if six.PY2 and isinstance(setup_py, six.text_type):
            setup_py = setup_py.encode(sys.getfilesystemencoding())

        return setup_py
github cody1991 / learn / finish / python-learn / 14-virtualenv / venv / Lib / site-packages / pip / _vendor / pkg_resources / __init__.py View on Github external
import importlib.machinery as importlib_machinery
else:
    importlib_machinery = None

try:
    import parser
except ImportError:
    pass

from pip._vendor import packaging
__import__('pip._vendor.packaging.version')
__import__('pip._vendor.packaging.specifiers')


filter = six.moves.filter
map = six.moves.map

if (3, 0) < sys.version_info < (3, 3):
    msg = (
        "Support for Python 3.0-3.2 has been dropped. Future versions "
        "will fail here."
    )
    warnings.warn(msg)

# declare some globals that will be defined later to
# satisfy the linters.
require = None
working_set = None


class PEP440Warning(RuntimeWarning):
    """
github dillon-giacoppo / rules_python_external / third_party / python / pip / _internal / network / session.py View on Github external
# Determine if our origin is a secure origin by looking through our
        # hardcoded list of secure origins, as well as any additional ones
        # configured on this PackageFinder instance.
        for secure_origin in self.iter_secure_origins():
            secure_protocol, secure_host, secure_port = secure_origin
            if origin_protocol != secure_protocol and secure_protocol != "*":
                continue

            try:
                # We need to do this decode dance to ensure that we have a
                # unicode object, even on Python 2.x.
                addr = ipaddress.ip_address(
                    origin_host
                    if (
                        isinstance(origin_host, six.text_type) or
                        origin_host is None
                    )
                    else origin_host.decode("utf8")
                )
                network = ipaddress.ip_network(
                    secure_host
                    if isinstance(secure_host, six.text_type)
                    # setting secure_host to proper Union[bytes, str]
                    # creates problems in other places
                    else secure_host.decode("utf8")  # type: ignore
                )
            except ValueError:
                # We don't have both a valid address or a valid network, so
                # we'll check this origin against hostnames.
                if (
                    origin_host and
github microsoft / PTVS / Python / Product / Miniconda / Miniconda3-x64 / Lib / site-packages / pip / _internal / utils / ui.py View on Github external
def _select_progress_class(preferred, fallback):
    encoding = getattr(preferred.file, "encoding", None)

    # If we don't know what encoding this file is in, then we'll just assume
    # that it doesn't support unicode and use the ASCII bar.
    if not encoding:
        return fallback

    # Collect all of the possible characters we want to use with the preferred
    # bar.
    characters = [
        getattr(preferred, "empty_fill", six.text_type()),
        getattr(preferred, "fill", six.text_type()),
    ]
    characters += list(getattr(preferred, "phases", []))

    # Try to decode the characters we're using for the bar using the encoding
    # of the given file, if this works then we'll assume that we can use the
    # fancier bar and if not we'll fall back to the plaintext bar.
    try:
        six.text_type().join(characters).encode(encoding)
    except UnicodeEncodeError:
        return fallback
    else:
        return preferred
github ali5h / rules_pip / third_party / py / pip / _vendor / pkg_resources / __init__.py View on Github external
from . import py31compat
from pip._vendor import appdirs
from pip._vendor import packaging
__import__('pip._vendor.packaging.version')
__import__('pip._vendor.packaging.specifiers')
__import__('pip._vendor.packaging.requirements')
__import__('pip._vendor.packaging.markers')


__metaclass__ = type


if (3, 0) < sys.version_info < (3, 5):
    raise RuntimeError("Python 3.5 or later is required")

if six.PY2:
    # Those builtin exceptions are only defined in Python 3
    PermissionError = None
    NotADirectoryError = None

# declare some globals that will be defined later to
# satisfy the linters.
require = None
working_set = None
add_activation_listener = None
resources_stream = None
cleanup_resources = None
resource_dir = None
resource_stream = None
set_extraction_path = None
resource_isdir = None
resource_string = None
github ali5h / rules_pip / third_party / py / pip / _internal / pyproject.py View on Github external
def make_pyproject_path(unpacked_source_directory):
    # type: (str) -> str
    path = os.path.join(unpacked_source_directory, 'pyproject.toml')

    # Python2 __file__ should not be unicode
    if six.PY2 and isinstance(path, six.text_type):
        path = path.encode(sys.getfilesystemencoding())

    return path
github dillon-giacoppo / rules_python_external / third_party / python / pip / _internal / commands / list.py View on Github external
def format_for_json(packages, options):
    data = []
    for dist in packages:
        info = {
            'name': dist.project_name,
            'version': six.text_type(dist.version),
        }
        if options.verbose >= 1:
            info['location'] = dist.location
            info['installer'] = get_installer(dist)
        if options.outdated:
            info['latest_version'] = six.text_type(dist.latest_version)
            info['latest_filetype'] = dist.latest_filetype
        data.append(info)
    return json.dumps(data)
github pypa / pip / src / pip / _internal / pyproject.py View on Github external
def make_pyproject_path(unpacked_source_directory):
    # type: (str) -> str
    path = os.path.join(unpacked_source_directory, 'pyproject.toml')

    # Python2 __file__ should not be unicode
    if six.PY2 and isinstance(path, six.text_type):
        path = path.encode(sys.getfilesystemencoding())

    return path