Esempio n. 1
0
    def test_dist_str(self):
        for ext in (CONDA_PACKAGE_EXTENSION_V1, CONDA_PACKAGE_EXTENSION_V2):
            m1 = MatchSpec.from_dist_str("anaconda/{0}::python-3.6.6-0{1}".format(context.subdir, ext))
            m2 = MatchSpec.from_dist_str("anaconda/{0}::python-3.6.6-0".format(context.subdir))
            m3 = MatchSpec.from_dist_str("https://someurl.org/anaconda/{0}::python-3.6.6-0{1}".format(context.subdir, ext))
            m4 = MatchSpec.from_dist_str("python-3.6.6-0{0}".format(ext))
            m5 = MatchSpec.from_dist_str("https://someurl.org/anaconda::python-3.6.6-0{0}".format(ext))

            pref = DPkg("anaconda::python-3.6.6-0{0}".format(ext))
            pref.url = "https://someurl.org/anaconda/{0}".format(context.subdir)

            assert m1.match(pref)
            assert m2.match(pref)
            assert m3.match(pref)
            assert m4.match(pref)
            pref.url = "https://someurl.org/anaconda"

            pref_dict = {
                'name': 'python',
                'version': '3.6.6',
                'build': '0',
                'build_number': 0,
                'channel': Channel("anaconda"),
                'fn': 'python-3.6.6-0{0}'.format(ext),
                'md5': '012345789',
                'url': 'https://someurl.org/anaconda'
            }
            assert m5.match(pref_dict)
Esempio n. 2
0
def output_file_to_string(output_file):
    '''
    Given a package file name,
    returns a string that can be used within a conda environment file to reference the package specifically.
    '''
    match_spec = MatchSpec.from_dist_str(os.path.basename(output_file))
    return "{} {} {}".format(match_spec.get("name", ""), match_spec.get("version", ""), match_spec.get("build", "")).strip()
Esempio n. 3
0
def output_file_exists(output_file, channels):
    '''
    Returns whether a given package name exists within a list of conda channels.
    '''
    match_spec = MatchSpec.from_dist_str(os.path.basename(output_file))
    subdir = os.path.dirname(output_file)
    return bool(
        SubdirData.query_all(match_spec, channels=channels, subdirs=[subdir]))