Skip to content
This repository was archived by the owner on Jan 30, 2019. It is now read-only.

conda env export has no-builds as default #119

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conda_env/cli/main_attach.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from argparse import RawDescriptionHelpFormatter
from ..utils.notebooks import current_env, Notebook
from ..utils.notebooks import Notebook
from conda.cli import common
from ..env import from_environment

Expand Down
7 changes: 3 additions & 4 deletions conda_env/cli/main_export.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import absolute_import, print_function
from argparse import RawDescriptionHelpFormatter
import os
import sys
import textwrap

from conda.cli import common
Expand Down Expand Up @@ -43,11 +42,11 @@ def configure_parser(sub_parsers):
)

p.add_argument(
'--no-builds',
'--with-builds',
default=False,
action='store_true',
required=False,
help='Remove build specification from dependencies'
help='Add build specification from dependencies'
)

p.set_defaults(func=execute)
Expand All @@ -72,7 +71,7 @@ def execute(args, parser):
else:
name = args.name
prefix = common.get_prefix(args)
env = from_environment(name, prefix, no_builds=args.no_builds)
env = from_environment(name, prefix, with_builds=args.with_builds)

if args.file is None:
print(env.to_yaml())
Expand Down
9 changes: 5 additions & 4 deletions conda_env/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@ def load_from_directory(directory):

# TODO This should lean more on conda instead of divining it from the outside
# TODO tests!!!
def from_environment(name, prefix, no_builds=False):
def from_environment(name, prefix, with_builds=False):
installed = install.linked(prefix)
conda_pkgs = copy(installed)
# json=True hides the output, data is added to installed
main_list.add_pip_installed(prefix, installed, json=True)

pip_pkgs = sorted(installed - conda_pkgs)

if no_builds:
dependencies = ['='.join(a.rsplit('-', 2)[0:2]) for a in sorted(conda_pkgs)]
else:
if with_builds:
dependencies = ['='.join(a.rsplit('-', 2)) for a in sorted(conda_pkgs)]
else:
dependencies = ['='.join(a.rsplit('-', 2)[0:2]) for a in sorted(conda_pkgs)]

if len(pip_pkgs) > 0:
dependencies.append({'pip': ['=='.join(a.rsplit('-', 2)[:2]) for a in pip_pkgs]})

Expand Down