Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/conda/conda into expand_e…
Browse files Browse the repository at this point in the history
…nv_vars
  • Loading branch information
teake committed Oct 5, 2018
2 parents d44532b + 5e1629e commit 557e16e
Show file tree
Hide file tree
Showing 19 changed files with 681 additions and 74 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Bruno Oliveira <[email protected]> Bruno Oliveira <[email protected]>
Bryan Van de Ven <[email protected]> Bryan Van de Ven <bryan@ubuntu.(none)>
Bryan Van de Ven <[email protected]> [email protected] <[email protected]>
Bryan Van de Ven <[email protected]> [email protected] <[email protected]>
Christopher Granade <[email protected]> Christopher Granade <[email protected]>
David Froger <[email protected]> David Froger <[email protected]>
David Hirschfeld <[email protected]> dhirschfeld <[email protected]>
Derek Ludwig <[email protected]> Derek Ludwig <[email protected]>
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
config (#7195, #7226, #7233)
* resolve #7087 add non-conda-installed python packages into PrefixData (#7067, #7370)
* resolve #2682 add 'conda run' preview support (#7320, #7625)
* resolve #626 conda wrapper for PowerShell (#7794)

### Deprecations/Breaking Changes
* resolve #6915 remove 'conda env attach' and 'conda env upload' (#6916)
Expand Down Expand Up @@ -51,6 +52,8 @@
* resolve #7336 'conda search' tries "fuzzy match" before showing PackagesNotFound (#7722)
* resolve #7656 strict channel priority via 'channel_priority' config option or --strict-channel-priority CLI flag (#7729)
* performance improvement to cache __hash__ value on PackageRecord (#7715)
* resolve #7764 change name of 'condacmd' dir to 'condabin'; use on all platforms (#7773)
* resolve #7782 implement PEP-440 '~=' compatible release operator (#7783)

### Bug Fixes
* fix #7107 verify hangs when a package is corrupted (#7131)
Expand All @@ -71,6 +74,8 @@
* fix conda env compatibility with pip 18 (#7612)
* fix #7184 remove conflicting specs to find solution to user's active request (#7719)
* fix #7706 add condacmd dir to cmd.exe path on first activation (#7735)
* fix #7761 spec handling errors in 4.6.0b0 (#7780)
* fix #7770 'conda list regex' only applies regex to package name (#7784)

### Non-User-Facing Changes
* resolve #6595 use OO inheritance in activate.py (#7049)
Expand All @@ -83,13 +88,17 @@
* test building conda using conda-build (#7251)
* solver test metadata updates (#7664)
* explicitly add Mapping, Sequence to common.compat (#7677)
* add debug messages to communicate solver stages (#7803)
* add undocumented sat_solver config parameter (#7811)

### Preview Releases

* 4.6.0a1 at d5bec21d1f64c3bc66c2999cfc690681e9c46177 on 2018-04-20
* 4.6.0a2 at c467517ca652371ebc4224f0d49315b7ec225108 on 2018-05-01
* 4.6.0b0 at 21a24f02b2687d0895de04664a4ec23ccc75c33a on 2018-09-07

### Contributors
* @cgranade
* @fabioz
* @goanpeca
* @jesse-
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ install:
# conda install -y -c defaults -c conda-forge pytest pytest-cov pytest-timeout mock responses pexpect xonsh
# TODO: add xonsh for PY3 builds
- "%PYTHON_ROOT%\\Scripts\\pip install codecov==2.0.5"
- "%PYTHON_ROOT%\\python -m conda init --dev"
- "%PYTHON_ROOT%\\python -m conda init cmd.exe --dev"

build: false

Expand Down
45 changes: 34 additions & 11 deletions conda/activate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import re
import sys
from tempfile import NamedTemporaryFile
from textwrap import dedent

# Since we have to have configuration context here, anything imported by
# conda.base.context is fair game, but nothing more.
Expand Down Expand Up @@ -113,6 +114,22 @@ def execute(self):
self._parse_and_set_args(self._raw_arguments)
return getattr(self, self.command)()

def commands(self):
"""
Returns a list of possible subcommands that are valid
immediately following `conda` at the command line.
This method is generally only used by tab-completion.
"""
# Import locally to reduce impact on initialization time.
from .cli.find_commands import find_commands
from .cli.conda_argparse import generate_parser, find_builtin_commands
# return value meant to be written to stdout
# Hidden commands to provide metadata to shells.
return "\n".join(sorted(
find_builtin_commands(generate_parser()) +
tuple(find_commands(True))
))

def _hook_preamble(self):
# must be implemented in subclass
raise NotImplementedError()
Expand All @@ -132,18 +149,20 @@ def _parse_and_set_args(self, arguments):

if not command:
from .exceptions import ArgumentError
raise ArgumentError("'activate', 'deactivate', 'hook', or 'reactivate' "
raise ArgumentError("'activate', 'deactivate', 'hook', "
"'commands', or 'reactivate' "
"command must be given")
elif help_requested:
from .exceptions import ActivateHelp, DeactivateHelp, GenericHelp
help_classes = {
'activate': ActivateHelp(),
'deactivate': DeactivateHelp(),
'hook': GenericHelp('hook'),
'commands': GenericHelp('commands'),
'reactivate': GenericHelp('reactivate'),
}
raise help_classes[command]
elif command not in ('activate', 'deactivate', 'reactivate', 'hook'):
elif command not in ('activate', 'deactivate', 'reactivate', 'hook', 'commands'):
from .exceptions import ArgumentError
raise ArgumentError("invalid command '%s'" % command)

Expand Down Expand Up @@ -757,27 +776,31 @@ def _hook_preamble(self):
% (context.conda_exe, context.conda_prefix, context.conda_exe))


class PowershellActivator(_Activator):
class PowerShellActivator(_Activator):

def __init__(self, arguments=None):
self.pathsep_join = ';'.join
self.sep = '\\'
self.pathsep_join = ';'.join if on_win else ':'.join
self.sep = '/' # Even on Windows, PowerShell can handle Unix-style separators.
self.path_conversion = path_identity
self.script_extension = '.ps1'
self.tempfile_extension = None # write instructions to stdout rather than a temp file
self.command_join = '\n'

self.unset_var_tmpl = 'Remove-Variable %s'
self.unset_var_tmpl = 'Remove-Item Env:/%s'
self.export_var_tmpl = '$env:%s = "%s"'
self.set_var_tmpl = '$env:%s = "%s"' # TODO: determine if different than export_var_tmpl
self.set_var_tmpl = '$env:%s = "%s"'
self.run_script_tmpl = '. "%s"'

self.hook_source_path = None # TODO: doesn't yet exist
self.hook_source_path = join(CONDA_PACKAGE_ROOT, 'shell', 'condabin', 'conda-hook.ps1')

super(PowershellActivator, self).__init__(arguments)
super(PowerShellActivator, self).__init__(arguments)

def _hook_preamble(self):
raise NotImplementedError()
return dedent("""\
$Env:CONDA_EXE = "{context.conda_exe}"
$Env:_CONDA_ROOT = "{context.conda_prefix}"
$Env:_CONDA_EXE = "{context.conda_exe}"
""".format(context=context))


activator_map = {
Expand All @@ -791,7 +814,7 @@ def _hook_preamble(self):
'xonsh': XonshActivator,
'cmd.exe': CmdExeActivator,
'fish': FishActivator,
'powershell': PowershellActivator,
'powershell': PowerShellActivator,
}


Expand Down
2 changes: 2 additions & 0 deletions conda/base/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
'tcsh',
'xonsh',
'zsh',
'powershell',
)
else:
COMPATIBLE_SHELLS = (
Expand All @@ -118,6 +119,7 @@
'tcsh',
'xonsh',
'zsh',
'powershell',
)


Expand Down
2 changes: 2 additions & 0 deletions conda/base/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class Context(Configuration):
# ######################################################
deps_modifier = PrimitiveParameter(DepsModifier.NOT_SET)
update_modifier = PrimitiveParameter(UpdateModifier.UPDATE_SPECS)
sat_solver = PrimitiveParameter(None, element_type=string_types + (NoneType,))

# no_deps = PrimitiveParameter(NULL, element_type=(type(NULL), bool)) # CLI-only
# only_deps = PrimitiveParameter(NULL, element_type=(type(NULL), bool)) # CLI-only
Expand Down Expand Up @@ -750,6 +751,7 @@ def category_map(self):
'force_32bit',
'pip_interop_enabled', # temporary feature flag
'root_prefix',
'sat_solver',
'subdir',
'subdirs',
# https://conda.io/docs/config.html#disable-updating-of-dependencies-update-dependencies # NOQA
Expand Down
6 changes: 6 additions & 0 deletions conda/cli/conda_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ def do_call(args, parser):
return exit_code


def find_builtin_commands(parser):
# ArgumentParser doesn't have an API for getting back what subparsers
# exist, so we need to use internal properties to do so.
return tuple(parser._subparsers._group_actions[0].choices.keys())


class ArgumentParser(ArgumentParserBase):
def __init__(self, *args, **kwargs):
if not kwargs.get('formatter_class'):
Expand Down
2 changes: 1 addition & 1 deletion conda/cli/main_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def execute(args, parser):
selected_shells = tuple(args.shells)

if not selected_shells:
selected_shells = ('cmd.exe' if on_win else 'bash',)
selected_shells = ('cmd.exe', 'powershell') if on_win else ('bash',)

if args.dev:
assert len(selected_shells) == 1, "--dev can only handle one shell at a time right now"
Expand Down
Loading

0 comments on commit 557e16e

Please sign in to comment.