Example #1
0
    def get_pyvers_name(self, url, cuda_version):
        """Checks if a provided url is available for a given cuda version

            It checks what package is available and is compatible with the available platforms
            returned by the pip

            Parameters
            ----------
            `url`: str
                Package url to be tested. `{cuda_v}` is replaced by cuda_version and  `{platform}`
                by the platform tag
            `cuda_version`: str
                Cuda version used for this query
        """
        if isinstance(p.get_supported()[0], tuple):
            # old PIP returns tuple
            for py_ver in [(x, y, z) for (x, y, z) in p.get_supported()
                           if y != 'none' and 'any' not in y]:
                py_ver = "-".join(py_ver)
                ret = self.test_request(
                    url.format(platform=py_ver, cuda_v=cuda_version))
                if ret:
                    return ret
        else:
            # new PIP returns object
            for py_ver in [
                    tag for tag in p.get_supported()
                    if tag.abi != 'none' and tag.platform != 'any'
            ]:
                py_ver = str(py_ver)
                ret = self.test_request(
                    url.format(platform=py_ver, cuda_v=cuda_version))
                if ret:
                    return ret
        return ""
Example #2
0
    def test_not_supported_multiarch_darwin(self):
        """
        Single-arch wheels (x86_64) are not supported on multi-arch (intel)
        """
        universal = compatibility_tags.get_supported(
            '27', platforms=['macosx_10_5_universal'], impl='cp')
        intel = compatibility_tags.get_supported(
            '27', platforms=['macosx_10_5_intel'], impl='cp')

        w = Wheel('simple-0.1-cp27-none-macosx_10_5_i386.whl')
        assert not w.supported(tags=intel)
        assert not w.supported(tags=universal)
        w = Wheel('simple-0.1-cp27-none-macosx_10_5_x86_64.whl')
        assert not w.supported(tags=intel)
        assert not w.supported(tags=universal)
Example #3
0
    def test_not_supported_multiarch_darwin(self) -> None:
        """
        Single-arch wheels (x86_64) are not supported on multi-arch (intel)
        """
        universal = compatibility_tags.get_supported(
            "27", platforms=["macosx_10_5_universal"], impl="cp")
        intel = compatibility_tags.get_supported(
            "27", platforms=["macosx_10_5_intel"], impl="cp")

        w = Wheel("simple-0.1-cp27-none-macosx_10_5_i386.whl")
        assert not w.supported(tags=intel)
        assert not w.supported(tags=universal)
        w = Wheel("simple-0.1-cp27-none-macosx_10_5_x86_64.whl")
        assert not w.supported(tags=intel)
        assert not w.supported(tags=universal)
Example #4
0
 def test_create__target_python_none(self):
     """
     Test passing target_python=None.
     """
     evaluator = CandidateEvaluator.create('my-project')
     expected_tags = get_supported()
     assert evaluator._supported_tags == expected_tags
Example #5
0
    def _populate_link(self, req: InstallRequirement) -> None:
        """Ensure that if a link can be found for this, that it is found.

        Note that req.link may still be None - if the requirement is already
        installed and not needed to be upgraded based on the return value of
        _is_upgrade_allowed().

        If preparer.require_hashes is True, don't use the wheel cache, because
        cached wheels, always built locally, have different hashes than the
        files downloaded from the index server and thus throw false hash
        mismatches. Furthermore, cached wheels at present have undeterministic
        contents due to file modification times.
        """
        if req.link is None:
            req.link = self._find_requirement_link(req)

        if self.wheel_cache is None or self.preparer.require_hashes:
            return
        cache_entry = self.wheel_cache.get_cache_entry(
            link=req.link,
            package_name=req.name,
            supported_tags=get_supported(),
        )
        if cache_entry is not None:
            logger.debug("Using cached wheel link: %s", cache_entry.link)
            if req.link is req.original_link and cache_entry.persistent:
                req.original_link_is_in_wheel_cache = True
            req.link = cache_entry.link
Example #6
0
    def populate_link(self, finder, upgrade, require_hashes):
        # type: (PackageFinder, bool, bool) -> None
        """Ensure that if a link can be found for this, that it is found.

        Note that self.link may still be None - if Upgrade is False and the
        requirement is already installed.

        If require_hashes is True, don't use the wheel cache, because cached
        wheels, always built locally, have different hashes than the files
        downloaded from the index server and thus throw false hash mismatches.
        Furthermore, cached wheels at present have undeterministic contents due
        to file modification times.
        """
        if self.link is None:
            self.link = finder.find_requirement(self, upgrade)
        if self._wheel_cache is not None and not require_hashes:
            old_link = self.link
            supported_tags = compatibility_tags.get_supported()
            self.link = self._wheel_cache.get(
                link=self.link,
                package_name=self.name,
                supported_tags=supported_tags,
            )
            if old_link != self.link:
                logger.debug('Using cached wheel link: %s', self.link)
Example #7
0
    def get_tags(self):
        # type: () -> List[Tag]
        """
        Return the supported PEP 425 tags to check wheel candidates against.

        The tags are returned in order of preference (most preferred first).
        """
        if self._valid_tags is None:
            # Pass versions=None if no py_version_info was given since
            # versions=None uses special default logic.
            py_version_info = self._given_py_version_info
            if py_version_info is None:
                version = None
            else:
                version = version_info_to_nodot(py_version_info)

            tags = get_supported(
                version=version,
                platform=self.platform,
                abi=self.abi,
                impl=self.implementation,
            )
            self._valid_tags = tags

        return self._valid_tags
Example #8
0
 def test_not_supported_osx_version(self) -> None:
     """
     Wheels built for macOS 10.9 are not supported on 10.6
     """
     tags = compatibility_tags.get_supported(
         "27", platforms=["macosx_10_6_intel"], impl="cp")
     w = Wheel("simple-0.1-cp27-none-macosx_10_9_intel.whl")
     assert not w.supported(tags=tags)
Example #9
0
 def test_not_supported_osx_version(self):
     """
     Wheels built for macOS 10.9 are not supported on 10.6
     """
     tags = compatibility_tags.get_supported(
         '27', platforms=['macosx_10_6_intel'], impl='cp')
     w = Wheel('simple-0.1-cp27-none-macosx_10_9_intel.whl')
     assert not w.supported(tags=tags)
Example #10
0
    def test_supported_multiarch_darwin(self) -> None:
        """
        Multi-arch wheels (intel) are supported on components (i386, x86_64)
        """
        universal = compatibility_tags.get_supported(
            "27", platforms=["macosx_10_5_universal"], impl="cp")
        intel = compatibility_tags.get_supported(
            "27", platforms=["macosx_10_5_intel"], impl="cp")
        x64 = compatibility_tags.get_supported(
            "27", platforms=["macosx_10_5_x86_64"], impl="cp")
        i386 = compatibility_tags.get_supported("27",
                                                platforms=["macosx_10_5_i386"],
                                                impl="cp")
        ppc = compatibility_tags.get_supported("27",
                                               platforms=["macosx_10_5_ppc"],
                                               impl="cp")
        ppc64 = compatibility_tags.get_supported(
            "27", platforms=["macosx_10_5_ppc64"], impl="cp")

        w = Wheel("simple-0.1-cp27-none-macosx_10_5_intel.whl")
        assert w.supported(tags=intel)
        assert w.supported(tags=x64)
        assert w.supported(tags=i386)
        assert not w.supported(tags=universal)
        assert not w.supported(tags=ppc)
        assert not w.supported(tags=ppc64)
        w = Wheel("simple-0.1-cp27-none-macosx_10_5_universal.whl")
        assert w.supported(tags=universal)
        assert w.supported(tags=intel)
        assert w.supported(tags=x64)
        assert w.supported(tags=i386)
        assert w.supported(tags=ppc)
        assert w.supported(tags=ppc64)
Example #11
0
    def test_supported_multiarch_darwin(self):
        """
        Multi-arch wheels (intel) are supported on components (i386, x86_64)
        """
        universal = compatibility_tags.get_supported(
            '27', platforms=['macosx_10_5_universal'], impl='cp')
        intel = compatibility_tags.get_supported(
            '27', platforms=['macosx_10_5_intel'], impl='cp')
        x64 = compatibility_tags.get_supported(
            '27', platforms=['macosx_10_5_x86_64'], impl='cp')
        i386 = compatibility_tags.get_supported('27',
                                                platforms=['macosx_10_5_i386'],
                                                impl='cp')
        ppc = compatibility_tags.get_supported('27',
                                               platforms=['macosx_10_5_ppc'],
                                               impl='cp')
        ppc64 = compatibility_tags.get_supported(
            '27', platforms=['macosx_10_5_ppc64'], impl='cp')

        w = Wheel('simple-0.1-cp27-none-macosx_10_5_intel.whl')
        assert w.supported(tags=intel)
        assert w.supported(tags=x64)
        assert w.supported(tags=i386)
        assert not w.supported(tags=universal)
        assert not w.supported(tags=ppc)
        assert not w.supported(tags=ppc64)
        w = Wheel('simple-0.1-cp27-none-macosx_10_5_universal.whl')
        assert w.supported(tags=universal)
        assert w.supported(tags=intel)
        assert w.supported(tags=x64)
        assert w.supported(tags=i386)
        assert w.supported(tags=ppc)
        assert w.supported(tags=ppc64)
Example #12
0
    def test_manylinux2010_implies_manylinux1(self, manylinux2010, manylinux1):
        """
        Specifying manylinux2010 implies manylinux1.
        """
        groups = {}
        supported = compatibility_tags.get_supported(platforms=[manylinux2010])
        for tag in supported:
            groups.setdefault((tag.interpreter, tag.abi),
                              []).append(tag.platform)

        for arches in groups.values():
            if arches == ['any']:
                continue
            assert arches[:2] == [manylinux2010, manylinux1]
Example #13
0
    def get_wheel_cache_entry(self, link, name):
        # type: (Link, Optional[str]) -> Optional[CacheEntry]
        """Look up the link in the wheel cache.

        If ``preparer.require_hashes`` is True, don't use the wheel cache,
        because cached wheels, always built locally, have different hashes
        than the files downloaded from the index server and thus throw false
        hash mismatches. Furthermore, cached wheels at present have
        nondeterministic contents due to file modification times.
        """
        if self._wheel_cache is None or self.preparer.require_hashes:
            return None
        return self._wheel_cache.get_cache_entry(
            link=link, package_name=name, supported_tags=get_supported())
Example #14
0
def test_debug__tags(script: PipTestEnvironment, args: List[str]) -> None:
    """
    Check the compatible tag output.
    """
    args = ["debug"] + args
    result = script.pip(*args, allow_stderr_warning=True)
    stdout = result.stdout

    tags = compatibility_tags.get_supported()
    expected_tag_header = "Compatible tags: {}".format(len(tags))
    assert expected_tag_header in stdout

    show_verbose_note = "--verbose" not in args
    assert ("...\n  [First 10 tags shown. Pass --verbose to show all.]"
            in stdout) == show_verbose_note
Example #15
0
    def test_manylinux2010_implies_manylinux1(self, manylinux2010: str,
                                              manylinux1: str) -> None:
        """
        Specifying manylinux2010 implies manylinux1.
        """
        groups: Dict[Tuple[str, str], List[str]] = {}
        supported = compatibility_tags.get_supported(platforms=[manylinux2010])
        for tag in supported:
            groups.setdefault((tag.interpreter, tag.abi),
                              []).append(tag.platform)

        for arches in groups.values():
            if arches == ["any"]:
                continue
            assert arches[:2] == [manylinux2010, manylinux1]
Example #16
0
def test_debug__tags(script, args):
    """
    Check the compatible tag output.
    """
    args = ['debug'] + args
    result = script.pip(*args, allow_stderr_warning=True)
    stdout = result.stdout

    tags = compatibility_tags.get_supported()
    expected_tag_header = 'Compatible tags: {}'.format(len(tags))
    assert expected_tag_header in stdout

    show_verbose_note = '--verbose' not in args
    assert ('...\n  [First 10 tags shown. Pass --verbose to show all.]'
            in stdout) == show_verbose_note
Example #17
0
    def test_manylinuxA_implies_manylinuxB(self, manylinuxA, manylinuxB):
        """
        Specifying manylinux2014 implies manylinux2010/manylinux1.
        """
        groups = {}
        supported = compatibility_tags.get_supported(platforms=[manylinuxA])
        for tag in supported:
            groups.setdefault((tag.interpreter, tag.abi),
                              []).append(tag.platform)

        expected_arches = [manylinuxA]
        expected_arches.extend(manylinuxB)
        for arches in groups.values():
            if arches == ['any']:
                continue
            assert arches[:3] == expected_arches
Example #18
0
    def test_manylinuxA_implies_manylinuxB(self, manylinuxA: str,
                                           manylinuxB: List[str]) -> None:
        """
        Specifying manylinux2014 implies manylinux2010/manylinux1.
        """
        groups: Dict[Tuple[str, str], List[str]] = {}
        supported = compatibility_tags.get_supported(platforms=[manylinuxA])
        for tag in supported:
            groups.setdefault((tag.interpreter, tag.abi),
                              []).append(tag.platform)

        expected_arches = [manylinuxA]
        expected_arches.extend(manylinuxB)
        for arches in groups.values():
            if arches == ["any"]:
                continue
            assert arches[:3] == expected_arches
Example #19
0
from pip._internal.utils.compatibility_tags import get_supported

print(get_supported())
    def add_requirement(
        self,
        install_req,  # type: InstallRequirement
        parent_req_name=None,  # type: Optional[str]
        extras_requested=None  # type: Optional[Iterable[str]]
    ):
        # type: (...) -> Tuple[List[InstallRequirement], Optional[InstallRequirement]]
        """Add install_req as a requirement to install.

        :param parent_req_name: The name of the requirement that needed this
            added. The name is used because when multiple unnamed requirements
            resolve to the same name, we could otherwise end up with dependency
            links that point outside the Requirements set. parent_req must
            already be added. note that None implies that this is a user
            supplied requirement, vs an inferred one.
        :param extras_requested: an iterable of extras used to evaluate the
            environment markers.
        :return: Additional requirements to scan. That is either [] if
            the requirement is not applicable, or [install_req] if the
            requirement is applicable and has just been added.
        """
        # If the markers do not match, ignore this requirement.
        if not install_req.match_markers(extras_requested):
            logger.info(
                "Ignoring %s: markers '%s' don't match your environment",
                install_req.name, install_req.markers,
            )
            return [], None

        # If the wheel is not supported, raise an error.
        # Should check this after filtering out based on environment markers to
        # allow specifying different wheels based on the environment/OS, in a
        # single requirements file.
        if install_req.link and install_req.link.is_wheel:
            wheel = Wheel(install_req.link.filename)
            tags = compatibility_tags.get_supported()
            if (self.check_supported_wheels and not wheel.supported(tags)):
                raise InstallationError(
                    "{} is not a supported wheel on this platform.".format(
                        wheel.filename)
                )

        # This next bit is really a sanity check.
        assert not install_req.user_supplied or parent_req_name is None, (
            "a user supplied req shouldn't have a parent"
        )

        # Unnamed requirements are scanned again and the requirement won't be
        # added as a dependency until after scanning.
        if not install_req.name:
            self.add_unnamed_requirement(install_req)
            return [install_req], None

        try:
            existing_req = self.get_requirement(
                install_req.name)  # type: Optional[InstallRequirement]
        except KeyError:
            existing_req = None

        has_conflicting_requirement = (
            parent_req_name is None and
            existing_req and
            not existing_req.constraint and
            existing_req.extras == install_req.extras and
            existing_req.req and
            install_req.req and
            existing_req.req.specifier != install_req.req.specifier
        )
        if has_conflicting_requirement:
            raise InstallationError(
                "Double requirement given: {} (already in {}, name={!r})"
                .format(install_req, existing_req, install_req.name)
            )

        # When no existing requirement exists, add the requirement as a
        # dependency and it will be scanned again after.
        if not existing_req:
            self.add_named_requirement(install_req)
            # We'd want to rescan this requirement later
            return [install_req], install_req

        # Assume there's no need to scan, and that we've already
        # encountered this for scanning.
        if install_req.constraint or not existing_req.constraint:
            return [], existing_req

        does_not_satisfy_constraint = (
            install_req.link and
            not (
                existing_req.link and
                install_req.link.path == existing_req.link.path
            )
        )
        if does_not_satisfy_constraint:
            raise InstallationError(
                "Could not satisfy constraints for '{}': "
                "installation from path or url cannot be "
                "constrained to a version".format(install_req.name)
            )
        # If we're now installing a constraint, mark the existing
        # object for real installation.
        existing_req.constraint = False
        # If we're now installing a user supplied requirement,
        # mark the existing object as such.
        if install_req.user_supplied:
            existing_req.user_supplied = True
        existing_req.extras = tuple(sorted(
            set(existing_req.extras) | set(install_req.extras)
        ))
        logger.debug(
            "Setting %s extras to: %s",
            existing_req, existing_req.extras,
        )
        # Return the existing requirement for addition to the parent and
        # scanning again.
        return [existing_req], existing_req
Example #21
0
        """
<<<<<<< HEAD
        if req.link is None:
            req.link = self._find_requirement_link(req)
=======
        upgrade = self._is_upgrade_allowed(req)
        if req.link is None:
            req.link = self.finder.find_requirement(req, upgrade)
>>>>>>> b66a76afa15ab74019740676a52a071b85ed8f71

        if self.wheel_cache is None or self.preparer.require_hashes:
            return
        cache_entry = self.wheel_cache.get_cache_entry(
            link=req.link,
            package_name=req.name,
            supported_tags=get_supported(),
        )
        if cache_entry is not None:
            logger.debug('Using cached wheel link: %s', cache_entry.link)
            if req.link is req.original_link and cache_entry.persistent:
                req.original_link_is_in_wheel_cache = True
            req.link = cache_entry.link

    def _get_abstract_dist_for(self, req):
        # type: (InstallRequirement) -> AbstractDistribution
        """Takes a InstallRequirement and returns a single AbstractDist \
        representing a prepared variant of the same.
        """
        if req.editable:
            return self.preparer.prepare_editable_requirement(req)