def execute(args, parser): spec = MatchSpec(args.match_spec) if spec.get_exact_value('subdir'): subdirs = spec.get_exact_value('subdir'), elif args.platform: subdirs = args.platform, else: subdirs = context.subdirs with Spinner("Loading channels", not context.verbosity and not context.quiet, context.json): spec_channel = spec.get_exact_value('channel') channel_urls = (spec_channel, ) if spec_channel else context.channels matches = sorted(SubdirData.query_all(spec, channel_urls, subdirs), key=lambda rec: (rec.name, VersionOrder(rec.version), rec.build)) if not matches: channels_urls = tuple( calculate_channel_urls( channel_urls=context.channels, prepend=not args.override_channels, platform=subdirs[0], use_local=args.use_local, )) from ..exceptions import PackagesNotFoundError raise PackagesNotFoundError((text_type(spec), ), channels_urls) else: return matches
def test_key_value_features_match(self): dst = Dist('defaults::foo-1.2.3-4.tar.bz2') a = MatchSpec(features='test') assert text_type(a) == "*[provides_features='test=true']" assert not a.match(DPkg(dst)) assert not a.match(DPkg(dst, track_features='')) assert a.match(DPkg(dst, track_features='test')) assert not a.match(DPkg(dst, track_features='test2')) assert a.match(DPkg(dst, track_features='test me')) assert a.match(DPkg(dst, track_features='you test')) assert a.match(DPkg(dst, track_features='you test me')) assert a.get_exact_value('provides_features') == frozendict({'test': 'true'}) b = MatchSpec(features='mkl') assert not b.match(DPkg(dst)) assert b.match(DPkg(dst, track_features='mkl')) assert b.match(DPkg(dst, track_features='blas=mkl')) assert b.match(DPkg(dst, track_features='blas=mkl debug')) assert not b.match(DPkg(dst, track_features='debug')) c = MatchSpec(features='nomkl') assert not c.match(DPkg(dst)) assert not c.match(DPkg(dst, track_features='mkl')) assert c.match(DPkg(dst, track_features='nomkl')) assert c.match(DPkg(dst, track_features='blas=nomkl debug'))
def test_features(self): dst = Dist('defaults::foo-1.2.3-4.tar.bz2') a = MatchSpec(features='test') assert a.match(DPkg(dst, features='test')) assert not a.match(DPkg(dst, features='test2')) assert a.match(DPkg(dst, features='test me')) assert a.match(DPkg(dst, features='you test')) assert a.match(DPkg(dst, features='you test me')) assert a.get_exact_value('features') == {'test'}
def test_track_features_match(self): dst = Dist('defaults::foo-1.2.3-4.tar.bz2') a = MatchSpec(features='test') assert text_type(a) == "*[features=test]" assert not a.match(DPkg(dst)) assert not a.match(DPkg(dst, track_features='')) a = MatchSpec(track_features='test') assert a.match(DPkg(dst, track_features='test')) assert not a.match(DPkg(dst, track_features='test2')) assert not a.match(DPkg(dst, track_features='test me')) assert not a.match(DPkg(dst, track_features='you test')) assert not a.match(DPkg(dst, track_features='you test me')) assert a.get_exact_value('track_features') == frozenset(('test', )) b = MatchSpec(track_features='mkl') assert not b.match(DPkg(dst)) assert b.match(DPkg(dst, track_features='mkl')) assert b.match(DPkg(dst, track_features='mkl')) assert not b.match(DPkg(dst, track_features='mkl debug')) assert not b.match(DPkg(dst, track_features='debug')) c = MatchSpec(track_features='nomkl') assert not c.match(DPkg(dst)) assert not c.match(DPkg(dst, track_features='mkl')) assert c.match(DPkg(dst, track_features='nomkl')) assert not c.match(DPkg(dst, track_features='nomkl debug')) # regression test for #6860 d = MatchSpec(track_features='') assert d.get_exact_value('track_features') == frozenset() d = MatchSpec(track_features=' ') assert d.get_exact_value('track_features') == frozenset() d = MatchSpec(track_features=('', '')) assert d.get_exact_value('track_features') == frozenset() d = MatchSpec(track_features=('', '', 'test')) assert d.get_exact_value('track_features') == frozenset(('test', ))
def test_track_features_match(self): dst = Dist('defaults::foo-1.2.3-4.tar.bz2') a = MatchSpec(features='test') assert text_type(a) == "*[features=test]" assert not a.match(DPkg(dst)) assert not a.match(DPkg(dst, track_features='')) a = MatchSpec(track_features='test') assert a.match(DPkg(dst, track_features='test')) assert not a.match(DPkg(dst, track_features='test2')) assert not a.match(DPkg(dst, track_features='test me')) assert not a.match(DPkg(dst, track_features='you test')) assert not a.match(DPkg(dst, track_features='you test me')) assert a.get_exact_value('track_features') == frozenset(('test',)) b = MatchSpec(track_features='mkl') assert not b.match(DPkg(dst)) assert b.match(DPkg(dst, track_features='mkl')) assert b.match(DPkg(dst, track_features='mkl')) assert not b.match(DPkg(dst, track_features='mkl debug')) assert not b.match(DPkg(dst, track_features='debug')) c = MatchSpec(track_features='nomkl') assert not c.match(DPkg(dst)) assert not c.match(DPkg(dst, track_features='mkl')) assert c.match(DPkg(dst, track_features='nomkl')) assert not c.match(DPkg(dst, track_features='nomkl debug')) # regression test for #6860 d = MatchSpec(track_features='') assert d.get_exact_value('track_features') == frozenset() d = MatchSpec(track_features=' ') assert d.get_exact_value('track_features') == frozenset() d = MatchSpec(track_features=('', '')) assert d.get_exact_value('track_features') == frozenset() d = MatchSpec(track_features=('', '', 'test')) assert d.get_exact_value('track_features') == frozenset(('test',))
def _norm_spec(myspec): m = MatchSpec(myspec) # this code looks like MatchSpec.conda_build_form() but munges stars in the # middle parts = [m.get_exact_value("name")] version = m.get_raw_value("version") build = m.get_raw_value("build") if build and not version: raise RuntimeError("spec '%s' has build but not version!" % myspec) if version: parts.append(_munge_req_star(m.version.spec_str)) if build: parts.append(build) return " ".join(parts)
def test_build_number_and_filename(self): ms = MatchSpec('zlib 1.2.7 0') assert ms.get_exact_value('name') == 'zlib' assert ms.get_exact_value('version') == '1.2.7' assert ms.get_exact_value('build') == '0' assert ms._to_filename_do_not_use() == 'zlib-1.2.7-0.tar.bz2'
def test_build_number_and_filename(self): ms = MatchSpec('zlib 1.2.7 0') assert ms.get_exact_value('name') == 'zlib' assert ms.get_exact_value('version') == '1.2.7' assert ms.get_exact_value('build') == '0' assert ms._to_filename_do_not_use() == 'zlib-1.2.7-0.tar.bz2'