Exemple #1
0
    def _build_package_list(self, package_section):
        """Returns a list of packages for pip-tools to consume."""
        from pipenv.vendor.requirementslib.utils import is_vcs
        ps = {}
        # TODO: Separate the logic for showing packages from the filters for supplying pip-tools
        for k, v in self.parsed_pipfile.get(package_section, {}).items():
            # Skip editable VCS deps.
            if hasattr(v, "keys"):
                # When a vcs url is gven without editable it only appears as a key
                # Eliminate any vcs, path, or url entries which are not editable
                # Since pip-tools can't do deep resolution on them, even setuptools-installable ones
                if (is_vcs(v) or is_vcs(k)
                        or (is_installable_file(k) or is_installable_file(v))
                        or any((prefix in v and (os.path.isfile(v[prefix])
                                                 or is_valid_url(v[prefix])))
                               for prefix in ["path", "file"])):
                    # If they are editable, do resolve them
                    if "editable" not in v:
                        # allow wheels to be passed through
                        if not (hasattr(v, "keys") and v.get(
                                "path", v.get("file", "")).endswith(".whl")):
                            continue
                        ps.update({k: v})

                    else:
                        ps.update({k: v})
                else:
                    ps.update({k: v})
            else:
                # Since these entries have no attributes we know they are not editable
                # So we can safely exclude things that need to be editable in order to be resolved
                # First exclude anything that is a vcs entry either in the key or value
                if not (any(is_vcs(i) for i in [k, v])
                        # Then exclude any installable files that are not directories
                        # Because pip-tools can resolve setup.py for example
                        or any(is_installable_file(i) for i in [k, v])
                        # Then exclude any URLs because they need to be editable also
                        # Things that are excluded can only be 'shallow resolved'
                        or any(is_valid_url(i) for i in [k, v])):
                    ps.update({k: v})
        return ps
Exemple #2
0
    def find_source(self, source):
        """
        Given a source, find it.

        source can be a url or an index name.
        """
        if not is_valid_url(source):
            try:
                source = self.get_source(name=source)
            except SourceNotFound:
                source = self.get_source(url=source)
        else:
            source = self.get_source(url=source)
        return source
Exemple #3
0
def validate_pypi_mirror(ctx, param, value):
    if value and not is_valid_url(value):
        raise BadParameter("Invalid PyPI mirror URL: %s" % value)
    return value