Skip to content

Commit

Permalink
Remove conda.cli.common.ensure_name_or_prefix (conda#11490)
Browse files Browse the repository at this point in the history
Co-authored-by: Jannis Leidel <[email protected]>
  • Loading branch information
kenodegard and jezdez authored May 31, 2022
1 parent 9c3c978 commit f072c34
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
5 changes: 5 additions & 0 deletions conda/cli/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from os.path import basename, dirname, isdir, isfile, join
import re
import sys
from warnings import warn

from ..auxlib.ish import dals
from ..base.constants import ROOT_ENV_NAME
Expand Down Expand Up @@ -67,6 +68,10 @@ def confirm_yn(message="Proceed", default='yes', dry_run=NULL):


def ensure_name_or_prefix(args, command):
warn(
"conda.cli.common.ensure_name_or_prefix is pending deprecation in a future release.",
PendingDeprecationWarning,
)
if not (args.name or args.prefix):
from ..exceptions import CondaValueError
raise CondaValueError('either -n NAME or -p PREFIX option required,\n'
Expand Down
12 changes: 7 additions & 5 deletions conda/cli/conda_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,9 @@ def configure_parser_create(sub_parsers):
help='Path to (or name of) existing local environment.',
metavar='ENV',
)
solver_mode_options, package_install_options = add_parser_create_install_update(p)
solver_mode_options, package_install_options = add_parser_create_install_update(
p, prefix_required=True
)
add_parser_default_packages(solver_mode_options)
add_parser_experimental_solver(solver_mode_options)
p.add_argument(
Expand Down Expand Up @@ -1303,8 +1305,8 @@ def configure_parser_update(sub_parsers, name='update'):
#
# #############################################################################################

def add_parser_create_install_update(p):
add_parser_prefix(p)
def add_parser_create_install_update(p, prefix_required=False):
add_parser_prefix(p, prefix_required)
add_parser_channels(p)
solver_mode_options = add_parser_solver_mode(p)
package_install_options = add_parser_package_install_options(p)
Expand Down Expand Up @@ -1382,9 +1384,9 @@ def add_parser_help(p):
)


def add_parser_prefix(p):
def add_parser_prefix(p, prefix_required=False):
target_environment_group = p.add_argument_group("Target Environment Specification")
npgroup = target_environment_group.add_mutually_exclusive_group()
npgroup = target_environment_group.add_mutually_exclusive_group(required=prefix_required)
npgroup.add_argument(
'-n', "--name",
action="store",
Expand Down
2 changes: 0 additions & 2 deletions conda/cli/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ def install(args, parser, command='install'):
isupdate = bool(command == 'update')
isinstall = bool(command == 'install')
isremove = bool(command == 'remove')
if newenv:
common.ensure_name_or_prefix(args, command)
prefix = context.target_prefix
if newenv:
check_prefix(prefix, json=context.json)
Expand Down
19 changes: 19 additions & 0 deletions news/11490-deprecate-conda.cli.common.ensure_name_or_prefix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* <news item>

### Deprecations

* `conda.cli.common.ensure_name_or_prefix` is pending deprecation in a future release. (#11490)

### Docs

* <news item>

### Other

* <news item>

0 comments on commit f072c34

Please sign in to comment.