Example #1
0
    def test_named_custom_channel_w_subchan(self):
        channel = Channel("chuck/subchan")
        assert channel.canonical_name == "chuck/subchan"
        assert channel.location == "another.url:8080/with/path"
        assert channel.url() == "http://another.url:8080/with/path/chuck/subchan/%s" % self.platform
        assert channel.url(
            True) == "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/subchan/%s" % self.platform
        assert channel.urls() == [
            "http://another.url:8080/with/path/chuck/subchan/%s" % self.platform,
            "http://another.url:8080/with/path/chuck/subchan/noarch",
        ]
        assert channel.urls(True) == [
            "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/subchan/%s" % self.platform,
            "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/subchan/noarch",
        ]

        channel = Channel("chuck/subchan/label/main")
        assert channel.canonical_name == "chuck/subchan/label/main"
        assert channel.location == "another.url:8080/with/path"
        assert channel.url() == "http://another.url:8080/with/path/chuck/subchan/label/main/%s" % self.platform
        assert channel.url(
            True) == "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/subchan/label/main/%s" % self.platform
        assert channel.urls() == [
            "http://another.url:8080/with/path/chuck/subchan/label/main/%s" % self.platform,
            "http://another.url:8080/with/path/chuck/subchan/label/main/noarch",
        ]
        assert channel.urls(True) == [
            "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/subchan/label/main/%s" % self.platform,
            "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/subchan/label/main/noarch",
        ]
Example #2
0
    def test_named_custom_channel(self):
        channel = Channel("chuck")
        assert channel.canonical_name == "chuck"
        assert channel.location == "another.url:8080/with/path"
        assert channel.url() == "http://another.url:8080/with/path/chuck/%s" % self.platform
        assert channel.url(True) == "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/%s" % self.platform
        assert channel.urls() == [
            "http://another.url:8080/with/path/chuck/%s" % self.platform,
            "http://another.url:8080/with/path/chuck/noarch",
        ]
        assert channel.urls(True) == [
            "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/%s" % self.platform,
            "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/noarch",
        ]

        channel = Channel("chuck/label/dev")
        assert channel.canonical_name == "chuck/label/dev"
        assert channel.location == "another.url:8080/with/path"
        assert channel.url() == "http://another.url:8080/with/path/chuck/label/dev/%s" % self.platform
        assert channel.url(True) == "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/label/dev/%s" % self.platform
        assert channel.urls() == [
            "http://another.url:8080/with/path/chuck/label/dev/%s" % self.platform,
            "http://another.url:8080/with/path/chuck/label/dev/noarch",
        ]
        assert channel.urls(True) == [
            "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/label/dev/%s" % self.platform,
            "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/label/dev/noarch",
        ]
Example #3
0
    def test_subdirs_env_var(self):
        subdirs = ('linux-highest', 'linux-64', 'noarch')

        def _channel_urls(channels=None):
            for channel in channels or DEFAULT_CHANNELS:
                channel = Channel(channel)
                for subdir in subdirs:
                    yield join_url(channel.base_url, subdir)

        with env_var('CONDA_SUBDIRS', ','.join(subdirs), reset_context):
            c = Channel('defaults')
            assert c.urls() == list(_channel_urls())

            c = Channel('conda-forge')
            assert c.urls() == list(_channel_urls(('conda-forge',)))

            channels = ('bioconda', 'conda-forge')
            prioritized = prioritize_channels(channels)
            assert prioritized == OrderedDict((
                ("https://conda.anaconda.org/bioconda/linux-highest", ("bioconda", 0)),
                ("https://conda.anaconda.org/bioconda/linux-64", ("bioconda", 0)),
                ("https://conda.anaconda.org/bioconda/noarch", ("bioconda", 0)),
                ("https://conda.anaconda.org/conda-forge/linux-highest", ("conda-forge", 1)),
                ("https://conda.anaconda.org/conda-forge/linux-64", ("conda-forge", 1)),
                ("https://conda.anaconda.org/conda-forge/noarch", ("conda-forge", 1)),
            ))

            prioritized = prioritize_channels(channels, subdirs=('linux-again', 'noarch'))
            assert prioritized == OrderedDict((
                ("https://conda.anaconda.org/bioconda/linux-again", ("bioconda", 0)),
                ("https://conda.anaconda.org/bioconda/noarch", ("bioconda", 0)),
                ("https://conda.anaconda.org/conda-forge/linux-again", ("conda-forge", 1)),
                ("https://conda.anaconda.org/conda-forge/noarch", ("conda-forge", 1)),
            ))
Example #4
0
    def setUpClass(cls):
        string = dals("""
        custom_channels:
          darwin: https://some.url.somewhere/stuff
          chuck: http://user1:[email protected]:8080/t/tk-1234/with/path
          pkgs/free: http://192.168.0.15:8080
        migrated_custom_channels:
          darwin: s3://just/cant
          chuck: file:///var/lib/repo/
          pkgs/free: https://repo.continuum.io
        migrated_channel_aliases:
          - https://conda.anaconda.org
        channel_alias: ftp://new.url:8082
        default_channels:
          - http://192.168.0.15:8080/pkgs/free
          - http://192.168.0.15:8080/pkgs/pro
          - http://192.168.0.15:8080/pkgs/msys2
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._add_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir

        cls.DEFAULT_URLS = ['http://192.168.0.15:8080/pkgs/free/%s' % cls.platform,
                            'http://192.168.0.15:8080/pkgs/free/noarch',
                            'http://192.168.0.15:8080/pkgs/pro/%s' % cls.platform,
                            'http://192.168.0.15:8080/pkgs/pro/noarch',
                            'http://192.168.0.15:8080/pkgs/msys2/%s' % cls.platform,
                            'http://192.168.0.15:8080/pkgs/msys2/noarch',
                            ]
Example #5
0
    def test_local_channel(self):
        conda_bld_path = join(gettempdir(), 'conda-bld')
        mkdir_p(conda_bld_path)
        try:
            with env_var('CONDA_CROOT', conda_bld_path, reset_context):
                Channel._reset_state()
                channel = Channel('local')
                assert channel._channels[0].name.rsplit('/', 1)[-1] == 'conda-bld'
                assert channel.channel_name == "local"
                assert channel.platform is None
                assert channel.package_filename is None
                assert channel.auth is None
                assert channel.token is None
                assert channel.scheme is None
                assert channel.canonical_name == "local"
                local_channel_first_subchannel = channel._channels[0].name

                channel = Channel(local_channel_first_subchannel)
                assert channel.channel_name == local_channel_first_subchannel
                assert channel.platform is None
                assert channel.package_filename is None
                assert channel.auth is None
                assert channel.token is None
                assert channel.scheme == "file"
                assert channel.canonical_name == "local"

                assert channel.urls() == Channel(local_channel_first_subchannel).urls()
                assert channel.urls()[0].startswith('file:///')
        finally:
            rm_rf(conda_bld_path)
Example #6
0
 def test_defaults_channel(self):
     channel = Channel('defaults')
     assert channel.name == 'defaults'
     assert channel.platform is None
     assert channel.package_filename is None
     assert channel.auth is None
     assert channel.token is None
     assert channel.scheme is None
     assert channel.canonical_name == 'defaults'
     assert channel.urls() == self.DEFAULT_URLS
Example #7
0
 def add_binstar_token(url):
     clean_url, token = split_anaconda_token(url)
     if not token:
         for binstar_url, token in iteritems(read_binstar_tokens()):
             if clean_url.startswith(binstar_url):
                 log.debug("Adding anaconda token for url <%s>", clean_url)
                 from conda.models.channel import Channel
                 channel = Channel(clean_url)
                 channel.token = token
                 return channel.url(with_credentials=True)
     return url
Example #8
0
 def test_channel_alias_channels(self):
     channel = Channel('binstar/label/dev')
     assert channel.channel_name == "binstar/label/dev"
     assert channel.channel_location == "conda.anaconda.org"
     assert channel.platform is None
     assert channel.package_filename is None
     assert channel.canonical_name == "binstar/label/dev"
     assert channel.urls() == [
         'https://conda.anaconda.org/binstar/label/dev/%s' % context.subdir,
         'https://conda.anaconda.org/binstar/label/dev/noarch',
     ]
Example #9
0
    def setUpClass(cls):
        string = dals("""
        channel_alias: https://10.2.3.4:8080/conda/t/tk-123-45
        migrated_channel_aliases:
          - https://conda.anaconda.org
          - http://10.2.3.4:7070/conda
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._add_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir
Example #10
0
    def test_default_channel(self):
        dc = Channel('defaults')
        assert dc.canonical_name == 'defaults'
        assert dc.urls() == self.DEFAULT_URLS
        assert dc.subdir is None
        assert text_type(dc) == 'defaults'

        dc = Channel('defaults/win-32')
        assert dc.canonical_name == 'defaults'
        assert dc.subdir == 'win-32'
        assert dc.urls()[0] == 'https://repo.anaconda.com/pkgs/main/win-32'
        assert dc.urls()[1] == 'https://repo.anaconda.com/pkgs/main/noarch'
        assert dc.urls()[2].endswith('/win-32')
Example #11
0
    def setUpClass(cls):
        string = dals("""
        default_channels:
           - http://test/conda/anaconda
        channels:
           - http://test/conda/anaconda-cluster
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._set_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir
Example #12
0
    def test_channel_name_subdir_only(self):
        channel = Channel('pkgs/free/win-64')
        assert channel.scheme == "https"
        assert channel.location == "repo.anaconda.com"
        assert channel.platform == 'win-64' == channel.subdir
        assert channel.name == 'pkgs/free'

        assert channel.base_url == 'https://repo.anaconda.com/pkgs/free'
        assert channel.canonical_name == 'defaults'
        assert channel.url() == 'https://repo.anaconda.com/pkgs/free/win-64'
        assert channel.urls() == [
            'https://repo.anaconda.com/pkgs/free/win-64',
            'https://repo.anaconda.com/pkgs/free/noarch',
        ]
Example #13
0
 def test_channel_alias_w_subhcnnale(self):
     channel = Channel('bioconda/label/dev')
     assert channel.channel_name == "bioconda/label/dev"
     assert channel.channel_location == "10.2.3.4:8080/conda"
     assert channel.platform is None
     assert channel.package_filename is None
     assert channel.auth is None
     assert channel.scheme == "https"
     assert channel.canonical_name == 'bioconda/label/dev'
     assert channel.urls() == [
         "https://10.2.3.4:8080/conda/bioconda/label/dev/%s" % self.platform,
         "https://10.2.3.4:8080/conda/bioconda/label/dev/noarch",
     ]
     assert channel.token == "tk-123-45"
Example #14
0
    def test_default_channels(self):
        channel = Channel('defaults')
        assert channel.canonical_name == "defaults"
        assert channel.location is None
        assert channel.url() is None
        assert channel.url(True) is None
        assert channel.urls() == [
            "http://192.168.0.15:8080/pkgs/free/%s" % self.platform,
            "http://192.168.0.15:8080/pkgs/free/noarch",
            "ftp://new.url:8082/donald/label/main/%s" % self.platform,
            "ftp://new.url:8082/donald/label/main/noarch",
            "http://192.168.0.15:8080/pkgs/r/%s" % self.platform,
            "http://192.168.0.15:8080/pkgs/r/noarch",
        ]
        assert channel.urls(True) == [
            "http://192.168.0.15:8080/pkgs/free/%s" % self.platform,
            "http://192.168.0.15:8080/pkgs/free/noarch",
            "ftp://*****:*****@new.url:8082/t/zyx-wvut/donald/label/main/%s" % self.platform,
            "ftp://*****:*****@new.url:8082/t/zyx-wvut/donald/label/main/noarch",
            "http://*****:*****@192.168.0.15:8080/t/tkn-123/pkgs/r/%s" % self.platform,
            "http://*****:*****@192.168.0.15:8080/t/tkn-123/pkgs/r/noarch",
        ]

        channel = Channel("ftp://new.url:8082/donald/label/main")
        assert channel.canonical_name == "defaults"

        channel = Channel("donald/label/main")
        assert channel.canonical_name == "defaults"

        channel = Channel("ftp://new.url:8081/donald")
        assert channel.location == "new.url:8081"
        assert channel.canonical_name == "donald"
Example #15
0
 def test_custom_token_in_channel(self):
     channel = Channel("https://10.2.3.4:8080/conda/t/x1029384756/bioconda")
     assert channel.channel_name == "bioconda"
     assert channel.channel_location == "10.2.3.4:8080/conda"
     assert channel.platform is None
     assert channel.package_filename is None
     assert channel.auth is None
     assert channel.token == "x1029384756"
     assert channel.scheme == "https"
     assert channel.canonical_name == 'bioconda'
     assert channel.urls() == [
         "https://10.2.3.4:8080/conda/bioconda/%s" % self.platform,
         "https://10.2.3.4:8080/conda/bioconda/noarch",
     ]
Example #16
0
    def test_bare_channel(self):
        url = "http://conda-01"
        channel = Channel(url)
        assert channel.scheme == "http"
        assert channel.location == "conda-01"
        assert channel.platform is None
        assert channel.canonical_name == url
        assert channel.name is None

        assert channel.base_url == url
        assert channel.url() == join_url(url, context.subdir)
        assert channel.urls() == [
            join_url(url, context.subdir),
            join_url(url, 'noarch'),
        ]
Example #17
0
    def test_url_channel_w_platform(self):
        channel = Channel('https://repo.continuum.io/pkgs/free/osx-64')

        assert channel.scheme == "https"
        assert channel.location == "repo.continuum.io"
        assert channel.platform == 'osx-64'
        assert channel.name == 'pkgs/free'

        assert channel.base_url == 'https://repo.continuum.io/pkgs/free'
        assert channel.canonical_name == 'defaults'
        assert channel.url() == 'https://repo.continuum.io/pkgs/free/osx-64'
        assert channel.urls() == [
            'https://repo.continuum.io/pkgs/free/osx-64',
            'https://repo.continuum.io/pkgs/free/noarch',
        ]
Example #18
0
 def test_file_channel(self):
     channel = Channel("file:///var/folders/cp/7r2s_s593j7_cpdtp/T/5d9f5e45/osx-64/flask-0.10.1-py35_2.tar.bz2")
     assert channel.name == '5d9f5e45'
     assert channel.location == '/var/folders/cp/7r2s_s593j7_cpdtp/T'
     assert channel.platform == 'osx-64'
     assert channel.package_filename == "flask-0.10.1-py35_2.tar.bz2"
     assert channel.auth is None
     assert channel.token is None
     assert channel.scheme == "file"
     assert channel.url() == "file:///var/folders/cp/7r2s_s593j7_cpdtp/T/5d9f5e45/osx-64/flask-0.10.1-py35_2.tar.bz2"
     assert channel.urls() == [
         "file:///var/folders/cp/7r2s_s593j7_cpdtp/T/5d9f5e45/osx-64",
         "file:///var/folders/cp/7r2s_s593j7_cpdtp/T/5d9f5e45/noarch"
     ]
     assert channel.canonical_name == 'file:///var/folders/cp/7r2s_s593j7_cpdtp/T/5d9f5e45'
Example #19
0
 def test_url_custom_channel(self):
     # scheme and credentials within url should override what's registered in config
     channel = Channel("https://*****:*****@another.url:8080/with/path/t/new-token/chuck/label/dev")
     assert channel.canonical_name == "chuck/label/dev"
     assert channel.location == "another.url:8080/with/path"
     assert channel.url() == "https://another.url:8080/with/path/chuck/label/dev/%s" % self.platform
     assert channel.url(True) == "https://*****:*****@another.url:8080/with/path/t/new-token/chuck/label/dev/%s" % self.platform
     assert channel.urls() == [
         "https://another.url:8080/with/path/chuck/label/dev/%s" % self.platform,
         "https://another.url:8080/with/path/chuck/label/dev/noarch",
     ]
     assert channel.urls(True) == [
         "https://*****:*****@another.url:8080/with/path/t/new-token/chuck/label/dev/%s" % self.platform,
         "https://*****:*****@another.url:8080/with/path/t/new-token/chuck/label/dev/noarch",
     ]
Example #20
0
    def test_channel_name_subdir_only(self):
        with env_unmodified(conda_tests_ctxt_mgmt_def_pol):
            channel = Channel('pkgs/main/win-64')
            assert channel.scheme == "https"
            assert channel.location == "repo.anaconda.com"
            assert channel.platform == 'win-64' == channel.subdir
            assert channel.name == 'pkgs/main'

            assert channel.base_url == 'https://repo.anaconda.com/pkgs/main'
            assert channel.canonical_name == 'defaults'
            assert channel.url() == 'https://repo.anaconda.com/pkgs/main/win-64'
            assert channel.urls() == [
                'https://repo.anaconda.com/pkgs/main/win-64',
                'https://repo.anaconda.com/pkgs/main/noarch',
            ]
Example #21
0
 def test_channel_alias_w_conda_path(self):
     channel = Channel('bioconda')
     assert channel.channel_name == "bioconda"
     assert channel.channel_location == "10.2.3.4:8080/conda"
     assert channel.platform is None
     assert channel.package_filename is None
     assert channel.auth is None
     assert channel.scheme == "https"
     assert channel.canonical_name == 'bioconda'
     assert channel.urls() == [
         "https://10.2.3.4:8080/conda/bioconda/%s" % self.platform,
         "https://10.2.3.4:8080/conda/bioconda/noarch",
     ]
     assert channel.token == "tk-123-45"
     assert text_type(channel) == "https://10.2.3.4:8080/conda/bioconda"
     assert text_type(Channel('bioconda/linux-32')) == "https://10.2.3.4:8080/conda/bioconda/linux-32"
Example #22
0
    def test_file_urls(self):
        url = "file:///machine/shared_folder"
        c = Channel(url)
        assert c.scheme == "file"
        assert c.auth is None
        assert c.location == "/machine"
        assert c.token is None
        assert c.name == "shared_folder"
        assert c.platform is None
        assert c.package_filename is None

        assert c.canonical_name == "file:///machine/shared_folder"
        assert c.url() == "file:///machine/shared_folder/%s" % context.subdir
        assert c.urls() == [
            "file:///machine/shared_folder/%s" % context.subdir,
            "file:///machine/shared_folder/noarch",
        ]
Example #23
0
 def setUp(self):
     string = dals("""
     custom_channels:
       darwin: https://some.url.somewhere/stuff
       chuck: http://another.url:8080/with/path
     migrated_custom_channels:
       darwin: s3://just/cant
       chuck: file:///var/lib/repo/
     migrated_channel_aliases:
       - https://conda.anaconda.org
     channel_alias: ftp://new.url:8082
     anaconda_token: tk-123-456-cba
     """)
     reset_context()
     rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
     context._add_raw_data(rd)
     Channel._reset_state()
Example #24
0
    def test_file_url_with_backslashes(self):
        url = "file://\\machine\\shared_folder\\path\\conda"
        c = Channel(url)
        assert c.scheme == "file"
        assert c.auth is None
        assert c.location == "/machine/shared_folder/path"
        assert c.token is None
        assert c.name == "conda"
        assert c.platform is None
        assert c.package_filename is None

        assert c.canonical_name == "file:///machine/shared_folder/path/conda"
        assert c.url() == "file:///machine/shared_folder/path/conda/%s" % context.subdir
        assert c.urls() == [
            "file:///machine/shared_folder/path/conda/%s" % context.subdir,
            "file:///machine/shared_folder/path/conda/noarch",
        ]
Example #25
0
    def test_pkgs_free(self):
        channel = Channel('pkgs/anaconda')
        assert channel.channel_name == "pkgs/anaconda"
        assert channel.channel_location == "192.168.0.15:8080"
        assert channel.canonical_name == "defaults"
        assert channel.urls() == [
            'http://192.168.0.15:8080/pkgs/anaconda/%s' % self.platform,
            'http://192.168.0.15:8080/pkgs/anaconda/noarch',
        ]

        channel = Channel('https://repo.anaconda.com/pkgs/anaconda')
        assert channel.channel_name == "pkgs/anaconda"
        assert channel.channel_location == "192.168.0.15:8080"
        assert channel.canonical_name == "defaults"
        assert channel.urls() == [
            'http://192.168.0.15:8080/pkgs/anaconda/%s' % self.platform,
            'http://192.168.0.15:8080/pkgs/anaconda/noarch',
        ]

        channel = Channel('https://repo.anaconda.com/pkgs/anaconda/noarch')
        assert channel.channel_name == "pkgs/anaconda"
        assert channel.channel_location == "192.168.0.15:8080"
        assert channel.canonical_name == "defaults"
        assert channel.urls() == [
            'http://192.168.0.15:8080/pkgs/anaconda/noarch',
        ]

        channel = Channel('https://repo.anaconda.com/pkgs/anaconda/label/dev')
        assert channel.channel_name == "pkgs/anaconda/label/dev"
        assert channel.channel_location == "192.168.0.15:8080"
        assert channel.canonical_name == "pkgs/anaconda/label/dev"
        assert channel.urls() == [
            'http://192.168.0.15:8080/pkgs/anaconda/label/dev/%s' % self.platform,
            'http://192.168.0.15:8080/pkgs/anaconda/label/dev/noarch',
        ]

        channel = Channel('https://repo.anaconda.com/pkgs/anaconda/noarch/flask-1.0.tar.bz2')
        assert channel.channel_name == "pkgs/anaconda"
        assert channel.channel_location == "192.168.0.15:8080"
        assert channel.platform == "noarch"
        assert channel.package_filename == "flask-1.0.tar.bz2"
        assert channel.canonical_name == "defaults"
        assert channel.urls() == [
            'http://192.168.0.15:8080/pkgs/anaconda/noarch',
        ]
Example #26
0
    def test_pkgs_pro(self):
        channel = Channel('pkgs/pro')
        assert channel.channel_name == "pkgs/pro"
        assert channel.channel_location == "192.168.0.15:8080"
        assert channel.canonical_name == "defaults"
        assert channel.urls() == [
            'http://192.168.0.15:8080/pkgs/pro/%s' % self.platform,
            'http://192.168.0.15:8080/pkgs/pro/noarch',
        ]

        channel = Channel('https://repo.continuum.io/pkgs/pro')
        assert channel.channel_name == "pkgs/pro"
        assert channel.channel_location == "repo.continuum.io"
        assert channel.canonical_name == "defaults"
        assert channel.urls() == [
            'https://repo.continuum.io/pkgs/pro/%s' % self.platform,
            'https://repo.continuum.io/pkgs/pro/noarch',
        ]

        channel = Channel('https://repo.continuum.io/pkgs/pro/noarch')
        assert channel.channel_name == "pkgs/pro"
        assert channel.channel_location == "repo.continuum.io"
        assert channel.canonical_name == "defaults"
        assert channel.urls() == [
            'https://repo.continuum.io/pkgs/pro/noarch',
        ]

        channel = Channel('https://repo.continuum.io/pkgs/pro/label/dev')
        assert channel.channel_name == "pkgs/pro/label/dev"
        assert channel.channel_location == "repo.continuum.io"
        assert channel.canonical_name == "pkgs/pro/label/dev"
        assert channel.urls() == [
            'https://repo.continuum.io/pkgs/pro/label/dev/%s' % self.platform,
            'https://repo.continuum.io/pkgs/pro/label/dev/noarch',
        ]

        channel = Channel('https://repo.continuum.io/pkgs/pro/noarch/flask-1.0.tar.bz2')
        assert channel.channel_name == "pkgs/pro"
        assert channel.channel_location == "repo.continuum.io"
        assert channel.platform == "noarch"
        assert channel.package_filename == "flask-1.0.tar.bz2"
        assert channel.canonical_name == "defaults"
        assert channel.urls() == [
            'https://repo.continuum.io/pkgs/pro/noarch',
        ]
Example #27
0
    def test_old_channel_alias(self):
        cf_urls = ["ftp://new.url:8082/conda-forge/%s" % self.platform,
                   "ftp://new.url:8082/conda-forge/noarch"]
        assert Channel('conda-forge').urls() == cf_urls

        url = "https://conda.anaconda.org/conda-forge/osx-64/some-great-package.tar.bz2"
        assert Channel(url).canonical_name == 'conda-forge'
        assert Channel(url).base_url == 'ftp://new.url:8082/conda-forge'
        assert Channel(url).url() == "ftp://new.url:8082/conda-forge/osx-64/some-great-package.tar.bz2"
        assert Channel(url).urls() == [
            "ftp://new.url:8082/conda-forge/osx-64",
            "ftp://new.url:8082/conda-forge/noarch",
        ]

        channel = Channel("https://conda.anaconda.org/conda-forge/label/dev/linux-64/some-great-package.tar.bz2")
        assert channel.url() == "ftp://new.url:8082/conda-forge/label/dev/linux-64/some-great-package.tar.bz2"
        assert channel.urls() == [
            "ftp://new.url:8082/conda-forge/label/dev/linux-64",
            "ftp://new.url:8082/conda-forge/label/dev/noarch",
        ]
Example #28
0
    def test_regression_against_unknown_none(self):
        defaults = Channel('defaults')

        channel = Channel(None)
        assert channel.scheme is None
        assert channel.location is None
        assert channel.platform is None
        assert channel.name == "<unknown>"
        assert channel.canonical_name == "<unknown>"

        assert channel.base_url is None
        assert channel.url() == defaults.url()
        assert channel.urls() == defaults.urls()

        channel = Channel('<unknown>')
        assert channel.scheme is None
        assert channel.location is None
        assert channel.platform is None
        assert channel.name == "<unknown>"
        assert channel.canonical_name == "<unknown>"

        assert channel.base_url is None
        assert channel.url() == defaults.url()
        assert channel.urls() == defaults.urls()

        channel = Channel('None:///<unknown>')
        assert channel.scheme is None
        assert channel.location is None
        assert channel.platform is None
        assert channel.name == "<unknown>"
        assert channel.canonical_name == "<unknown>"

        assert channel.base_url is None
        assert channel.url() == defaults.url()
        assert channel.urls() == defaults.urls()

        channel = Channel('None')
        assert channel.scheme is None
        assert channel.location is None
        assert channel.platform is None
        assert channel.name == "<unknown>"
        assert channel.canonical_name == "<unknown>"

        assert channel.base_url is None
        assert channel.url() == defaults.url()
        assert channel.urls() == defaults.urls()
Example #29
0
    def test_migrated_custom_channels(self):
        channel = Channel('s3://just/cant/darwin/osx-64')
        assert channel.channel_name == "darwin"
        assert channel.channel_location == "some.url.somewhere/stuff"
        assert channel.platform == 'osx-64'
        assert channel.package_filename is None
        assert channel.auth is None
        assert channel.token is None
        assert channel.scheme == "https"
        assert channel.canonical_name == "darwin"
        assert channel.url(
        ) == "https://some.url.somewhere/stuff/darwin/osx-64"
        assert channel.urls() == [
            "https://some.url.somewhere/stuff/darwin/osx-64",
            "https://some.url.somewhere/stuff/darwin/noarch",
        ]
        assert Channel(channel.canonical_name).urls() == [
            "https://some.url.somewhere/stuff/darwin/%s" % self.platform,
            "https://some.url.somewhere/stuff/darwin/noarch",
        ]

        channel = Channel(
            'https://some.url.somewhere/stuff/darwin/noarch/a-mighty-fine.tar.bz2'
        )
        assert channel.channel_name == "darwin"
        assert channel.channel_location == "some.url.somewhere/stuff"
        assert channel.platform == 'noarch'
        assert channel.package_filename == 'a-mighty-fine.tar.bz2'
        assert channel.auth is None
        assert channel.token is None
        assert channel.scheme == "https"
        assert channel.canonical_name == "darwin"
        assert channel.url(
        ) == "https://some.url.somewhere/stuff/darwin/noarch/a-mighty-fine.tar.bz2"
        assert channel.urls() == [
            "https://some.url.somewhere/stuff/darwin/noarch",
        ]
        assert Channel(channel.canonical_name).urls() == [
            "https://some.url.somewhere/stuff/darwin/%s" % self.platform,
            "https://some.url.somewhere/stuff/darwin/noarch",
        ]
Example #30
0
def get_index(channel_urls=(),
              prepend=True,
              platform=None,
              use_local=False,
              use_cache=False,
              unknown=None,
              prefix=None,
              repodata_fn="repodata.json"):

    real_urls = calculate_channel_urls(channel_urls, prepend, platform,
                                       use_local)
    check_whitelist(real_urls)

    dlist = api.DownloadTargetList()

    sddata = []
    index = []

    for idx, url in enumerate(real_urls):
        channel = Channel(url)
        full_url = CondaHttpAuth.add_binstar_token(
            channel.url(with_credentials=True) + '/' + repodata_fn)

        full_path_cache = os.path.join(api.create_cache_dir(),
                                       api.cache_fn_url(full_url))
        if channel.name:
            channel_name = channel.name + '/' + channel.subdir
        else:
            channel_name = channel.url(with_credentials=False)
        sd = api.SubdirData(channel_name, full_url, full_path_cache)

        sd.load()
        index.append((sd, channel))
        dlist.add(sd)

    is_downloaded = dlist.download(True)

    if not is_downloaded:
        raise RuntimeError("Error downloading repodata.")

    return index
Example #31
0
    def test_canonicalized_url_gets_correct_token(self):
        channel = Channel("bioconda")
        assert channel.urls() == [
            "https://10.2.3.4:8080/conda/bioconda/%s" % self.platform,
            "https://10.2.3.4:8080/conda/bioconda/noarch",
        ]
        assert channel.urls(with_credentials=True) == [
            "https://10.2.3.4:8080/conda/t/tk-123-45/bioconda/%s" % self.platform,
            "https://10.2.3.4:8080/conda/t/tk-123-45/bioconda/noarch",
        ]

        channel = Channel("https://10.2.3.4:8080/conda/bioconda")
        assert channel.urls() == [
            "https://10.2.3.4:8080/conda/bioconda/%s" % self.platform,
            "https://10.2.3.4:8080/conda/bioconda/noarch",
        ]
        assert channel.urls(with_credentials=True) == [
            "https://10.2.3.4:8080/conda/t/tk-123-45/bioconda/%s" % self.platform,
            "https://10.2.3.4:8080/conda/t/tk-123-45/bioconda/noarch",
        ]

        channel = Channel("https://10.2.3.4:8080/conda/t/x1029384756/bioconda")
        assert channel.urls() == [
            "https://10.2.3.4:8080/conda/bioconda/%s" % self.platform,
            "https://10.2.3.4:8080/conda/bioconda/noarch",
        ]
        assert channel.urls(with_credentials=True) == [
            "https://10.2.3.4:8080/conda/t/x1029384756/bioconda/%s" % self.platform,
            "https://10.2.3.4:8080/conda/t/x1029384756/bioconda/noarch",
        ]

        # what happens with the token if it's in the wrong places?
        channel = Channel("https://10.2.3.4:8080/t/x1029384756/conda/bioconda")
        assert channel.urls() == [
            "https://10.2.3.4:8080/conda/bioconda/%s" % self.platform,
            "https://10.2.3.4:8080/conda/bioconda/noarch",
        ]
        assert channel.urls(with_credentials=True) == [
            "https://10.2.3.4:8080/conda/t/x1029384756/bioconda/%s" % self.platform,
            "https://10.2.3.4:8080/conda/t/x1029384756/bioconda/noarch",
        ]
Example #32
0
 def __init__(self, channel):
     assert channel.subdir
     if channel.package_filename:
         parts = channel.dump()
         del parts['package_filename']
         channel = Channel(**parts)
     self.channel = channel
     self.url_w_subdir = self.channel.url(with_credentials=False)
     self.url_w_credentials = self.channel.url(with_credentials=True)
     self.cache_path_base = join(create_cache_dir(),
                                 splitext(cache_fn_url(self.url_w_credentials))[0])
     self._loaded = False
Example #33
0
    def setUpClass(cls):
        string = dals("""
        custom_channels:
          chuck: http://user1:[email protected]:8080/with/path/t/tk-1234
          chuck/subchan: http://user33:[email protected]:8080/with/path/t/tk-1234
        channel_alias: ftp://nm:[email protected]:8082/t/zyx-wvut/
        channels:
          - mickey
          - https://conda.anaconda.cloud/t/tk-12-token/minnie
          - http://dont-do:[email protected]/daffy/label/main
        default_channels:
          - http://192.168.0.15:8080/pkgs/anaconda
          - donald/label/main
          - http://us:[email protected]:8080/t/tkn-123/pkgs/r
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._set_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir
Example #34
0
    def test_url_channel_w_platform(self):
        channel = Channel('https://repo.continuum.io/pkgs/free/osx-64/')
        assert isinstance(channel, UrlChannel)

        assert channel._scheme == "https"
        assert channel._netloc == "repo.continuum.io"
        assert channel._path == "/pkgs/free"
        assert channel._platform == 'osx-64'

        assert channel.base_url == 'https://repo.continuum.io/pkgs/free'
        assert channel.canonical_name == 'defaults'
        assert channel.urls == ['https://repo.continuum.io/pkgs/free/osx-64/']
Example #35
0
    def test_default_channel(self):
        dc = Channel('defaults')
        # assert isinstance(dc, DefaultChannel)

        assert dc.base_url == 'https://conda.anaconda.org/defaults'
        assert dc.canonical_name == 'defaults'
        assert dc.urls == DEFAULT_URLS

        assert dc._scheme == "https"
        assert dc._netloc == "conda.anaconda.org"
        assert dc._path == "/defaults"
        assert dc._platform is None
Example #36
0
    def setUpClass(cls):
        string = dals("""
        custom_channels:
          chuck: http://user1:[email protected]:8080/with/path/t/tk-1234
          chuck/subchan: http://user33:[email protected]:8080/with/path/t/tk-1234
        channel_alias: ftp://nm:[email protected]:8082/t/zyx-wvut/
        channels:
          - mickey
          - https://conda.anaconda.cloud/t/tk-12-token/minnie
          - http://dont-do:[email protected]/daffy/label/main
        default_channels:
          - http://192.168.0.15:8080/pkgs/free
          - donald/label/main
          - http://us:[email protected]:8080/t/tkn-123/pkgs/r
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._add_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir
Example #37
0
def get_index(channel_urls=(),
              prepend=True,
              platform=None,
              use_local=False,
              use_cache=False,
              unknown=None,
              prefix=None,
              repodata_fn="repodata.json"):
    """Get an index?

    Function from @wolfv here:
    https://gist.github.com/wolfv/cd12bd4a448c77ff02368e97ffdf495a.
    """
    real_urls = calculate_channel_urls(channel_urls, prepend, platform,
                                       use_local)
    check_whitelist(real_urls)

    dlist = api.DownloadTargetList()

    index = []
    for idx, url in enumerate(real_urls):
        channel = Channel(url)

        full_url = channel.url(with_credentials=True) + '/' + repodata_fn
        full_path_cache = os.path.join(create_cache_dir(),
                                       cache_fn_url(full_url, repodata_fn))

        sd = api.SubdirData(channel.name + '/' + channel.subdir, full_url,
                            full_path_cache)

        sd.load()
        index.append((sd, channel))
        dlist.add(sd)

    is_downloaded = dlist.download(True)

    if not is_downloaded:
        raise RuntimeError("Error downloading repodata.")

    return index
Example #38
0
    def test_subdirs_env_var(self):
        subdirs = ('linux-highest', 'linux-64', 'noarch')

        def _channel_urls(channels=None):
            for channel in channels or DEFAULT_CHANNELS_UNIX:
                channel = Channel(channel)
                for subdir in subdirs:
                    yield join_url(channel.base_url, subdir)

        with env_var('CONDA_SUBDIRS', ','.join(subdirs), reset_context):
            c = Channel('defaults')
            assert c.urls() == list(_channel_urls())

            c = Channel('conda-forge')
            assert c.urls() == list(_channel_urls(('conda-forge',)))

            channels = ('bioconda', 'conda-forge')
            prioritized = prioritize_channels(channels)
            assert prioritized == OrderedDict((
                ("https://conda.anaconda.org/bioconda/linux-highest", ("bioconda", 0)),
                ("https://conda.anaconda.org/bioconda/linux-64", ("bioconda", 0)),
                ("https://conda.anaconda.org/bioconda/noarch", ("bioconda", 0)),
                ("https://conda.anaconda.org/conda-forge/linux-highest", ("conda-forge", 1)),
                ("https://conda.anaconda.org/conda-forge/linux-64", ("conda-forge", 1)),
                ("https://conda.anaconda.org/conda-forge/noarch", ("conda-forge", 1)),
            ))

            prioritized = prioritize_channels(channels, subdirs=('linux-again', 'noarch'))
            assert prioritized == OrderedDict((
                ("https://conda.anaconda.org/bioconda/linux-again", ("bioconda", 0)),
                ("https://conda.anaconda.org/bioconda/noarch", ("bioconda", 0)),
                ("https://conda.anaconda.org/conda-forge/linux-again", ("conda-forge", 1)),
                ("https://conda.anaconda.org/conda-forge/noarch", ("conda-forge", 1)),
            ))
Example #39
0
    def test_old_channel_alias(self):
        cf_urls = [
            "ftp://new.url:8082/conda-forge/%s" % self.platform,
            "ftp://new.url:8082/conda-forge/noarch"
        ]
        assert Channel('conda-forge').urls() == cf_urls

        url = "https://conda.anaconda.org/conda-forge/osx-64/some-great-package.tar.bz2"
        assert Channel(url).canonical_name == 'conda-forge'
        assert Channel(url).base_url == 'ftp://new.url:8082/conda-forge'
        assert Channel(url).url(
        ) == "ftp://new.url:8082/conda-forge/osx-64/some-great-package.tar.bz2"
        assert Channel(url).urls() == [
            "ftp://new.url:8082/conda-forge/osx-64",
            "ftp://new.url:8082/conda-forge/noarch",
        ]

        channel = Channel(
            "https://conda.anaconda.org/conda-forge/label/dev/linux-64/some-great-package.tar.bz2"
        )
        assert channel.url(
        ) == "ftp://new.url:8082/conda-forge/label/dev/linux-64/some-great-package.tar.bz2"
        assert channel.urls() == [
            "ftp://new.url:8082/conda-forge/label/dev/linux-64",
            "ftp://new.url:8082/conda-forge/label/dev/noarch",
        ]
Example #40
0
    def test_channel_alias_channels(self):
        channel = Channel('binstar/label/dev')
        assert channel.channel_name == "binstar/label/dev"
        assert channel.channel_location == "conda.anaconda.org"
        assert channel.platform is None
        assert channel.package_filename is None
        assert channel.canonical_name == "binstar/label/dev"
        assert channel.urls() == [
            'https://conda.anaconda.org/binstar/label/dev/%s' % context.subdir,
            'https://conda.anaconda.org/binstar/label/dev/noarch',
        ]

        channel = Channel('binstar/label/dev/win-32')
        assert channel.channel_name == "binstar/label/dev"
        assert channel.channel_location == "conda.anaconda.org"
        assert channel.platform == 'win-32'
        assert channel.package_filename is None
        assert channel.canonical_name == "binstar/label/dev"
        assert channel.urls() == [
            'https://conda.anaconda.org/binstar/label/dev/win-32',
            'https://conda.anaconda.org/binstar/label/dev/noarch',
        ]
Example #41
0
def get_env_index(channel_urls):
    threads = []
    result = []
    sddata = [FastSubdirData(Channel(x)) for x in channel_urls]
    for sd in sddata:
        t = threading.Thread(target=load_channel, args=(sd, result))
        threads.append(t)
        t.start()

    for t in threads:
        t.join()

    return result
Example #42
0
    def test_url_channel_wo_platform(self):
        channel = Channel('https://repo.continuum.io/pkgs/free/')
        assert isinstance(channel, UrlChannel)

        assert channel._scheme == "https"
        assert channel._netloc == "repo.continuum.io"
        assert channel._path == "/pkgs/free"
        assert channel._platform is None

        platform = context.subdir
        assert channel.base_url == 'https://repo.continuum.io/pkgs/free'
        assert channel.canonical_name == 'defaults'
        assert channel.urls == DEFAULT_URLS
Example #43
0
def get_index_r_2(subdir=context.subdir):
    with open(join(dirname(__file__), 'data', 'index2.json')) as fi:
        packages = json.load(fi)
        repodata = {
            "info": {
                "subdir": subdir,
                "arch": context.arch_name,
                "platform": context.platform,
            },
            "packages": packages,
        }

    channel = Channel('https://conda.anaconda.org/channel-2/%s' % subdir)
    sd = SubdirData(channel)
    with env_var("CONDA_ADD_PIP_AS_PYTHON_DEPENDENCY", "false", reset_context):
        sd._process_raw_repodata_str(json.dumps(repodata))
    sd._loaded = True
    SubdirData._cache_[channel.url(with_credentials=True)] = sd

    index = {prec: prec for prec in sd._package_records}
    r = Resolve(index, channels=(channel,))
    return index, r
Example #44
0
    def test_local_channel(self):
        channel = Channel('local')
        assert channel._channels[0].name == 'conda-bld'
        assert channel.channel_name == "local"
        assert channel.platform is None
        assert channel.package_filename is None
        assert channel.auth is None
        assert channel.token is None
        assert channel.scheme is None
        assert channel.canonical_name == "local"

        channel = Channel('conda-bld')
        assert channel.channel_name == "conda-bld"
        assert channel.platform is None
        assert channel.package_filename is None
        assert channel.auth is None
        assert channel.token is None
        assert channel.scheme == "file"
        assert channel.canonical_name == "local"

        assert channel.urls() == Channel('local').urls()
        assert channel.urls()[0].startswith('file:///')
Example #45
0
    def test_default_channel(self):
        dc = Channel('defaults')
        assert dc.canonical_name == 'defaults'
        assert dc.urls() == self.DEFAULT_URLS
        assert dc.subdir is None

        dc = Channel('defaults/win-32')
        assert dc.canonical_name == 'defaults'
        assert dc.subdir == 'win-32'
        assert dc.urls()[0] == 'https://repo.continuum.io/pkgs/free/win-32'
        assert dc.urls()[1] == 'https://repo.continuum.io/pkgs/free/noarch'
        assert dc.urls()[2].endswith('/win-32')
Example #46
0
    def test_named_custom_channel_w_subchan(self):
        channel = Channel("chuck/subchan")
        assert channel.canonical_name == "chuck/subchan"
        assert channel.location == "another.url:8080/with/path"
        assert channel.url(
        ) == "http://another.url:8080/with/path/chuck/subchan/%s" % self.platform
        assert channel.url(
            True
        ) == "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/subchan/%s" % self.platform
        assert channel.urls() == [
            "http://another.url:8080/with/path/chuck/subchan/%s" %
            self.platform,
            "http://another.url:8080/with/path/chuck/subchan/noarch",
        ]
        assert channel.urls(True) == [
            "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/subchan/%s"
            % self.platform,
            "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/subchan/noarch",
        ]

        channel = Channel("chuck/subchan/label/main")
        assert channel.canonical_name == "chuck/subchan/label/main"
        assert channel.location == "another.url:8080/with/path"
        assert channel.url(
        ) == "http://another.url:8080/with/path/chuck/subchan/label/main/%s" % self.platform
        assert channel.url(
            True
        ) == "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/subchan/label/main/%s" % self.platform
        assert channel.urls() == [
            "http://another.url:8080/with/path/chuck/subchan/label/main/%s" %
            self.platform,
            "http://another.url:8080/with/path/chuck/subchan/label/main/noarch",
        ]
        assert channel.urls(True) == [
            "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/subchan/label/main/%s"
            % self.platform,
            "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/subchan/label/main/noarch",
        ]
Example #47
0
def to_conda_channel(channel, platform):
    if channel.scheme == "file":
        return CondaChannel.from_value(
            channel.platform_url(platform, with_credentials=False))

    return CondaChannel(
        channel.scheme,
        channel.auth,
        channel.location,
        channel.token,
        channel.name,
        platform,
        channel.package_filename,
    )
Example #48
0
 def test_custom_token_in_channel(self):
     channel = Channel("https://10.2.3.4:8080/conda/t/x1029384756/bioconda")
     assert channel.channel_name == "bioconda"
     assert channel.channel_location == "10.2.3.4:8080/conda"
     assert channel.platform is None
     assert channel.package_filename is None
     assert channel.auth is None
     assert channel.token == "x1029384756"
     assert channel.scheme == "https"
     assert channel.canonical_name == 'bioconda'
     assert channel.urls() == [
         "https://10.2.3.4:8080/conda/bioconda/%s" % self.platform,
         "https://10.2.3.4:8080/conda/bioconda/noarch",
     ]
Example #49
0
 def test_channel_alias_w_conda_path(self):
     channel = Channel('bioconda')
     assert channel.channel_name == "bioconda"
     assert channel.channel_location == "10.2.3.4:8080/conda"
     assert channel.platform is None
     assert channel.package_filename is None
     assert channel.auth is None
     assert channel.scheme == "https"
     assert channel.canonical_name == 'bioconda'
     assert channel.urls() == [
         "https://10.2.3.4:8080/conda/bioconda/%s" % self.platform,
         "https://10.2.3.4:8080/conda/bioconda/noarch",
     ]
     assert channel.token == "tk-123-45"
Example #50
0
def _solve(prefix, specs, args, env, *_, **kwargs):
    # TODO: support all various ways this happens
    # Including 'nodefaults' in the channels list disables the defaults
    channel_urls = [chan for chan in env.channels if chan != 'nodefaults']

    if 'nodefaults' not in env.channels:
        channel_urls.extend(context.channels)
    _channel_priority_map = prioritize_channels(channel_urls)

    channels = IndexedSet(Channel(url) for url in _channel_priority_map)
    subdirs = IndexedSet(basename(url) for url in _channel_priority_map)

    solver = Solver(prefix, channels, subdirs, specs_to_add=specs)
    return solver
Example #51
0
    def test_named_custom_channel(self):
        channel = Channel("chuck")
        assert channel.canonical_name == "chuck"
        assert channel.location == "another.url:8080/with/path"
        assert channel.url(
        ) == "http://another.url:8080/with/path/chuck/%s" % self.platform
        assert channel.url(
            True
        ) == "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/%s" % self.platform
        assert channel.urls() == [
            "http://another.url:8080/with/path/chuck/%s" % self.platform,
            "http://another.url:8080/with/path/chuck/noarch",
        ]
        assert channel.urls(True) == [
            "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/%s"
            % self.platform,
            "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/noarch",
        ]

        channel = Channel("chuck/label/dev")
        assert channel.canonical_name == "chuck/label/dev"
        assert channel.location == "another.url:8080/with/path"
        assert channel.url(
        ) == "http://another.url:8080/with/path/chuck/label/dev/%s" % self.platform
        assert channel.url(
            True
        ) == "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/label/dev/%s" % self.platform
        assert channel.urls() == [
            "http://another.url:8080/with/path/chuck/label/dev/%s" %
            self.platform,
            "http://another.url:8080/with/path/chuck/label/dev/noarch",
        ]
        assert channel.urls(True) == [
            "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/label/dev/%s"
            % self.platform,
            "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/label/dev/noarch",
        ]
Example #52
0
def get_index(
    channel_urls=(),
    prepend=True,
    platform=None,
    use_local=False,
    use_cache=False,
    unknown=None,
    prefix=None,
    repodata_fn="repodata.json",
):
    real_urls = calculate_channel_urls(channel_urls, prepend, platform,
                                       use_local)
    check_whitelist(real_urls)

    dlist = mamba_api.DownloadTargetList()

    index = []
    for idx, url in enumerate(real_urls):
        channel = Channel(url)

        full_url = channel.url(with_credentials=True) + "/" + repodata_fn
        full_path_cache = os.path.join(create_cache_dir(),
                                       cache_fn_url(full_url, repodata_fn))

        sd = mamba_api.SubdirData(channel.name + "/" + channel.subdir,
                                  full_url, full_path_cache)

        sd.load()
        index.append((sd, channel))
        dlist.add(sd)

    is_downloaded = dlist.download(True)

    if not is_downloaded:
        raise RuntimeError("Error downloading repodata.")

    return index
Example #53
0
    def test_default_channel(self):
        dc = Channel('defaults')
        assert dc.canonical_name == 'defaults'
        assert dc.urls() == self.DEFAULT_URLS
        assert dc.subdir is None
        assert text_type(dc) == 'defaults'

        dc = Channel('defaults/win-32')
        assert dc.canonical_name == 'defaults'
        assert dc.subdir == 'win-32'
        assert dc.urls()[0] == 'https://repo.anaconda.com/pkgs/main/win-32'
        assert dc.urls()[1] == 'https://repo.anaconda.com/pkgs/main/noarch'
        assert dc.urls()[2].endswith('/win-32')
Example #54
0
    def test_bare_channel(self):
        url = "http://conda-01"
        channel = Channel(url)
        assert channel.scheme == "http"
        assert channel.location == "conda-01"
        assert channel.platform is None
        assert channel.canonical_name == url
        assert channel.name is None

        assert channel.base_url == url
        assert channel.url() == join_url(url, context.subdir)
        assert channel.urls() == [
            join_url(url, context.subdir),
            join_url(url, 'noarch'),
        ]
Example #55
0
    def test_conda_bld_path(self):
        conda_bld_path = join(gettempdir(), 'conda-bld')
        conda_bld_url = path_to_url(conda_bld_path)
        try:
            mkdir_p(conda_bld_path)
            with env_var('CONDA_BLD_PATH',
                         conda_bld_path,
                         stack_callback=conda_tests_ctxt_mgmt_def_pol):
                assert len(context.conda_build_local_paths) >= 1
                assert context.conda_build_local_paths[0] == conda_bld_path

                channel = Channel('local')
                assert channel.channel_name == "local"
                assert channel.channel_location is None
                assert channel.platform is None
                assert channel.package_filename is None
                assert channel.auth is None
                assert channel.token is None
                assert channel.scheme is None
                assert channel.canonical_name == "local"
                assert channel.url() is None
                urls = list(
                    concat((
                        join_url(url, context.subdir),
                        join_url(url, 'noarch'),
                    ) for url in context.conda_build_local_urls))
                assert channel.urls() == urls

                channel = Channel(conda_bld_url)
                assert channel.canonical_name == "local"
                assert channel.platform is None
                assert channel.package_filename is None
                assert channel.auth is None
                assert channel.token is None
                assert channel.scheme == "file"
                assert channel.urls() == [
                    join_url(conda_bld_url, context.subdir),
                    join_url(conda_bld_url, 'noarch'),
                ]
                assert channel.url() == join_url(conda_bld_url, context.subdir)
                assert channel.channel_name.lower() == win_path_backout(
                    conda_bld_path).lstrip('/').lower()
                assert channel.channel_location == ''  # location really is an empty string; all path information is in channel_name
                assert channel.canonical_name == "local"
        finally:
            rm_rf(conda_bld_path)
Example #56
0
    def test_conda_bld_path_2(self):
        saved_envs_path = os.environ.get('CONDA_BLD_PATH')
        beginning = "C:" + os.sep if on_win else os.sep
        path = beginning + os.sep.join(['random', 'directory'])
        url = path_to_url(path)
        try:
            os.environ['CONDA_BLD_PATH'] = path
            reset_context()

            channel = Channel('local')
            assert channel.channel_name == "local"
            assert channel.channel_location is None
            assert channel.platform is None
            assert channel.package_filename is None
            assert channel.auth is None
            assert channel.token is None
            assert channel.scheme is None
            assert channel.canonical_name == "local"
            assert channel.url() is None
            assert channel.urls() == [
                join_url(url, context.subdir),
                join_url(url, 'noarch'),
            ]

            channel = Channel(url)
            assert channel.canonical_name == "local"
            assert channel.platform is None
            assert channel.package_filename is None
            assert channel.auth is None
            assert channel.token is None
            assert channel.scheme == "file"
            assert channel.urls() == [
                join_url(url, context.subdir),
                join_url(url, 'noarch'),
            ]
            assert channel.url() == join_url(url, context.subdir)
            assert channel.channel_name == basename(path)
            assert channel.channel_location == path_to_url(
                dirname(path)).replace('file://', '', 1)
            assert channel.canonical_name == "local"

        finally:
            if saved_envs_path:
                os.environ['CONDA_BLD_PATH'] = saved_envs_path
            else:
                del os.environ['CONDA_BLD_PATH']
Example #57
0
    def test_url_channel_w_platform(self):
        channel = Channel('https://repo.continuum.io/pkgs/free/osx-64')

        assert channel.scheme == "https"
        assert channel.location == "repo.continuum.io"
        assert channel.platform == 'osx-64'
        assert channel.name == 'pkgs/free'

        assert channel.base_url == 'https://repo.continuum.io/pkgs/free'
        assert channel.canonical_name == 'defaults'
        assert channel.url() == 'https://repo.continuum.io/pkgs/free/osx-64'
        assert channel.urls() == [
            'https://repo.continuum.io/pkgs/free/osx-64',
            'https://repo.continuum.io/pkgs/free/noarch',
        ]
Example #58
0
 def test_url_custom_channel(self):
     # scheme and credentials within url should override what's registered in config
     channel = Channel("https://*****:*****@another.url:8080/with/path/t/new-token/chuck/label/dev")
     assert channel.canonical_name == "chuck/label/dev"
     assert channel.location == "another.url:8080/with/path"
     assert channel.url() == "https://another.url:8080/with/path/chuck/label/dev/%s" % self.platform
     assert channel.url(True) == "https://*****:*****@another.url:8080/with/path/t/new-token/chuck/label/dev/%s" % self.platform
     assert channel.urls() == [
         "https://another.url:8080/with/path/chuck/label/dev/%s" % self.platform,
         "https://another.url:8080/with/path/chuck/label/dev/noarch",
     ]
     assert channel.urls(True) == [
         "https://*****:*****@another.url:8080/with/path/t/new-token/chuck/label/dev/%s" % self.platform,
         "https://*****:*****@another.url:8080/with/path/t/new-token/chuck/label/dev/noarch",
     ]
Example #59
0
    def test_local_channel(self):
        Channel._reset_state()
        channel = Channel('local')
        assert channel._channels[0].name.rsplit('/', 1)[-1] == 'conda-bld'
        assert channel.channel_name == "local"
        assert channel.platform is None
        assert channel.package_filename is None
        assert channel.auth is None
        assert channel.token is None
        assert channel.scheme is None
        assert channel.canonical_name == "local"
        local_channel_first_subchannel = channel._channels[0].name

        channel = Channel(local_channel_first_subchannel)
        assert channel.channel_name == local_channel_first_subchannel
        assert channel.platform is None
        assert channel.package_filename is None
        assert channel.auth is None
        assert channel.token is None
        assert channel.scheme == "file"
        assert channel.canonical_name == "local"

        assert channel.urls() == Channel('local').urls()
        assert channel.urls()[0].startswith('file:///')
Example #60
0
 def test_file_channel(self):
     channel = Channel("file:///var/folders/cp/7r2s_s593j7_cpdtp/T/5d9f5e45/osx-64/flask-0.10.1-py35_2.tar.bz2")
     assert channel.name == '5d9f5e45'
     assert channel.location == '/var/folders/cp/7r2s_s593j7_cpdtp/T'
     assert channel.platform == 'osx-64'
     assert channel.package_filename == "flask-0.10.1-py35_2.tar.bz2"
     assert channel.auth is None
     assert channel.token is None
     assert channel.scheme == "file"
     assert channel.url() == "file:///var/folders/cp/7r2s_s593j7_cpdtp/T/5d9f5e45/osx-64/flask-0.10.1-py35_2.tar.bz2"
     assert channel.urls() == [
         "file:///var/folders/cp/7r2s_s593j7_cpdtp/T/5d9f5e45/osx-64",
         "file:///var/folders/cp/7r2s_s593j7_cpdtp/T/5d9f5e45/noarch"
     ]
     assert channel.canonical_name == 'file:///var/folders/cp/7r2s_s593j7_cpdtp/T/5d9f5e45'