def test_parse_platform():
    for p in conda_api.default_platforms_plus_32_bit:
        (name, bits) = conda_api.parse_platform(p)
        assert bits in ('32', '64')
        assert name in conda_api.known_platform_names

    assert ('linux-cos5', '64') == conda_api.parse_platform('linux-cos5-64')
    def is_most_general(platform_or_platform_name):
        if '-' in platform_or_platform_name:
            platform_name = conda_api.parse_platform(platform_or_platform_name)[0]
            if platform_name in result:
                return False

        if 'unix' in result and is_unix(platform_or_platform_name) and platform_or_platform_name != 'unix':
            return False

        # we don't call this after adding 'all'
        assert platform_or_platform_name != 'all'

        return True
def _extract_common(by_platform):
    # convert from dict of platform-to-lists to platform-to-sets
    result = {name: set(values) for (name, values) in by_platform.items()}

    # linux-64,linux-32 => linux, etc.
    platform_names = set([
        conda_api.parse_platform(platform)[0]
        for platform in by_platform.keys()
    ])
    for name in platform_names:
        result = _refactor_common_packages(
            result, lambda p: p.startswith("%s-" % name), name)

    # is it a candidate for the "unix" grouping
    def is_unix(platform_or_platform_name):
        for unix_name in conda_api.unix_platform_names:
            if platform_or_platform_name.startswith(unix_name):
                return True
        return False

    # if we have "linux","linux-64","osx-64", we should consider "linux","osx-64"
    # and leave out "linux-64".
    def is_most_general(platform_or_platform_name):
        if '-' in platform_or_platform_name:
            platform_name = conda_api.parse_platform(
                platform_or_platform_name)[0]
            if platform_name in result:
                return False

        if 'unix' in result and is_unix(
                platform_or_platform_name
        ) and platform_or_platform_name != 'unix':
            return False

        # we don't call this after adding 'all'
        assert platform_or_platform_name != 'all'

        return True

    # linux*, osx* => unix
    result = _refactor_common_packages(
        result, lambda p: is_unix(p) and is_most_general(p), "unix")

    # everything => all
    result = _refactor_common_packages(result, lambda p: is_most_general(p),
                                       "all")

    return {name: sorted(list(value)) for (name, value) in result.items()}
Esempio n. 4
0
    def package_specs_for_platform(self, platform):
        """Sequence of package spec strings for the requested platform."""
        assert platform in self.platforms
        assert self.enabled

        # we merge "all", "unix", "linux", then "linux-64" for example
        shared = self._package_specs_by_platform.get("all", [])

        platform_name = conda_api.parse_platform(platform)[0]

        if platform_name in conda_api.unix_platform_names:
            shared_unix = self._package_specs_by_platform.get("unix", [])
            shared = _combine_conda_package_lists(shared, shared_unix)

        shared_across_bits = self._package_specs_by_platform.get(platform_name, [])
        shared = _combine_conda_package_lists(shared, shared_across_bits)

        per_platform = self._package_specs_by_platform.get(platform, [])
        return _combine_conda_package_lists(shared, per_platform)
def test_msys_for_all_platforms():
    for p in conda_api.default_platforms_plus_32_bit:
        (name, bits) = conda_api.parse_platform(p)
        info = conda_api.info(platform=p)
        print("*** info() for %s" % p)
        pprint(info)
        assert 'channels' in info

        # conda 4.1 has a slash on the channels and 4.3 does not
        def no_slash(url):
            if url.endswith("/"):
                return url[:-1]
            else:
                return url

        channels = [no_slash(channel) for channel in info['channels']]
        if name == 'win':
            assert ('https://repo.continuum.io/pkgs/msys2/%s' % p) in channels
            assert ('https://repo.continuum.io/pkgs/msys2/noarch') in channels
        else:
            for c in channels:
                assert 'msys' not in c
def test_msys_for_all_platforms():
    for p in conda_api.default_platforms_plus_32_bit:
        (name, bits) = conda_api.parse_platform(p)
        info = conda_api.info(platform=p)
        print("*** info() for %s" % p)
        pprint(info)
        assert 'channels' in info

        # conda 4.1 has a slash on the channels and 4.3 does not
        def no_slash(url):
            if url.endswith("/"):
                return url[:-1]
            else:
                return url

        channels = [no_slash(channel) for channel in info['channels']]
        # Designed to handle repo.continuum.io and repo.anaconda.com
        channels = '\n'.join(channels)
        if name == 'win':
            assert '/msys2/%s' % p in channels
            assert '/msys2/noarch' in channels
        else:
            assert '/msys2' not in channels