Skip to content

Commit

Permalink
override -e by --explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoTian committed Aug 18, 2016
1 parent 96c82a8 commit bf0a312
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
2 changes: 1 addition & 1 deletion conda/cli/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def specs_from_args(args, json=False):
(?P<name>[^=<>!\s]+) # package name
\s* # ignore spaces
(
(?P<cc>=[^=]+(=[^=]+)?(=[^=]+)?) # conda constraint
(?P<cc>=[^=]+(=[^=]+)?) # conda constraint
|
(?P<pc>(?:[=!]=|[><]=?).+) # new (pip-style) constraint(s)
)?
Expand Down
12 changes: 1 addition & 11 deletions conda/cli/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,7 @@ def install(args, parser, command='install'):
specs = []
if args.file:
for fpath in args.file:
file_spec=common.specs_from_url(fpath, json=args.json)
for s in file_spec:
part = s.split()
if len(part) < 4:
specs.append(s)
else:
specs.append(" ".join(part[:3]))
ch = part[3].strip()
index_args["channel_urls"] = list(index_args["channel_urls"])
if ch not in ("defaults", "local"):
index_args["channel_urls"].append(ch)
specs.extend(common.specs_from_url(fpath, json=args.json))
if '@EXPLICIT' in specs:
explicit(specs, prefix, verbose=not args.quiet, index_args=index_args)
return
Expand Down
3 changes: 2 additions & 1 deletion conda/cli/main_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ def execute(args, parser):
if args.canonical:
format = 'canonical'
elif args.export:
format = 'export'
print_explicit(prefix, args.md5)
return
else:
format = 'human'

Expand Down
30 changes: 29 additions & 1 deletion tests/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_basic(self):
output2, error= run_command(Commands.LIST, prefix2, "-e")
self.assertEqual(output, output2)

def test_multi_channel(self):
def test_multi_channel_export(self):
"""
When try to import from txt
every package should come from same channel
Expand All @@ -54,3 +54,31 @@ def test_multi_channel(self):

output2, _ = run_command(Commands.LIST, prefix2, "-e")
self.assertEqual(output, output2)

def test_multi_channel_explicit(self):
"""
When try to import from txt
every package should come from same channel
"""
with make_temp_env("python=3") as prefix:
assert exists(join(prefix, PYTHON_BINARY))
assert_package_is_installed(prefix, 'python-3')

run_command(Commands.INSTALL, prefix, "six", "-c", "conda-forge")
assert_package_is_installed(prefix, "six")

output, error = run_command(Commands.LIST, prefix, "--explicit")
self.assertIn("conda-forge", output)

with tempfile.NamedTemporaryFile(mode="w", suffix="txt", delete=False) as env_txt:
env_txt.write(output)
env_txt.flush()
env_txt.close()
prefix2 = make_temp_prefix()
run_command(Commands.CREATE, prefix2, "--file " + env_txt.name)

assert_package_is_installed(prefix2, "python")
assert_package_is_installed(prefix2, "six")

output2, _ = run_command(Commands.LIST, prefix2, "--explicit")
self.assertEqual(output, output2)

0 comments on commit bf0a312

Please sign in to comment.