Loading .gitignore +3 −0 Original line number Diff line number Diff line Loading @@ -36,3 +36,6 @@ miniconda*.exe docs/source/_build **/.vscode conda.tmp/ *.iml *.ipr *.iws CHANGELOG.md +123 −3 Original line number Diff line number Diff line ## 4.8.1 (2019-12-19) ### Enhancements: * improve performance for conda run by avoiding Popen.communicate (#9381) * Put conda keyring in /usr/share/keyrings on Debian (#9424) * refactor common.logic to fix some bugs and prepare for better modularity (#9427) * Support nested configuration (#9449) * Support Object configuration parameters (#9465) * Use freeze_installed to speed up conda env update (#9511) * add networking args to conda env create (#9525) ### Docs: * fix string concatenation running words together regarding CONDA_EXE (#9411) * Fix typo ("list" -> "info") (#9433) * typo in condarc key envs_dirs (#9478) * Clarify channel priority and package sorting (#9492) * improve description of DLL loading verification and activating environments (#9453) * Installing with specific build number (#9534) ### Bug fixes: * Fix calling python api run_command with list and string arguments (#9331) * revert init bash completion (#9421) * set tmp to shortened path that excludes spaces (#9409) * avoid function redefinition upon resourcing conda.fish (#9444) * propagate pip error level when creating envs with conda env (#9460) * fix incorrect chown call (#9464) * Add subdir to PackageRecord dist_str (#9418) * Fix running conda activate in multiple processes on windows (#9477) * Don't check in pkgs for trash (#9472) * remove setuptools from run_constrained in recipe (#9485) * Fix `__conda_activate` function to correctly return exit code (#9532) * fix overly greedy capture done by subprocess for conda run (#9537) ### Contributors: * @AntoinePrv * @brettcannon * @bwildenhain * @cjmartian * @felker * @forrestwaters * @gilescope * @isuruf * @jeremyjliu * @jjhelmus * @jhultman * @marcuscaisey * @mbargull * @mingwandroid * @msarahan * @okhoma * @osamoylenko * @rrigdon * @rulerofthehuns * @soapy1 * @tartansandal ## 4.8.0rc0 (2019-11-04) ### Enhancements: * retry downloads if they fail, controlled by `remote_max_retries` and `remote_backoff_factor` configuration values (#9318) * redact authentication information in some URLs (#9341) * add osx version virtual package , `__osx` (#9349) * add glibc virtual package, `__glibc` (#9358) ### Docs * removeed references to MD5s from docs (#9247) * Add docs on `CONDA_DLL_SEARCH_MODIFICATION_ENABLED` (#9286) * document threads, spec history and configuration (#9327) * more documentation on channels (#9335) * document the .condarc search order (#9369) * various minor documentation fixes (#9238, #9248, #9267, #9334, #9351, #9372, #9378, #9388, #9391, #9393) ### Bug fixes * fix issues with xonsh activation on Windows (#8246) * remove unsupported --lock argument from conda clean (#8310) * do not add `sys_prefix_path` to failed activation or deactivation (#9282) * fix csh setenv command (#9284) * do not memorize `PackageRecord.combined_depends` (#9289) * use `CONDA_INTERNAL_OLDPATH` rather than `OLDPATH` in activation script (#9303) * fixes xonsh activation and tab completion (#9305) * fix what channels are queried when context.offline is True (#9385) ### Contributors * @analog-cbarber * @andreasg123 * @beckermr * @bryant1410 * @colinbrislawn * @felker * @forrestwaters * @gabrielcnr * @isuruf * @jakirkham * @jeremyjliu * @jjhelmus * @jooh * @jpigla * @marcelotrevisani * @melund * @mfansler * @mingwandroid * @msarahan * @rrigdon * @scopatz * @soapy1 * @WillyChen123 * @xhochy ## 4.7.12 (2019-09-12) ### Enhancements: Loading circle.yml +2 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ main_test: &main_test if [[ $(git diff origin/master --name-only | wc -l) == $(git diff origin/master --name-only | grep docs | wc -l) && $(git diff origin/master --name-only | grep docs) ]]; then echo "Only docs changed detected, skipping tests" else echo "local_repodata_ttl: 1800" >> ~/.condarc echo "local_repodata_ttl: 1800" > ~/.condarc eval "$(sudo /opt/conda/bin/python -m conda init --dev bash)" conda info # remove the pkg cache. We can't hardlink from here anyway. Having it around causes log problems. Loading Loading @@ -74,7 +74,7 @@ conda_build_test: &conda_build_test # pre-populating the package cache helps avoid race conditions for testing in parallel command: | eval "$(sudo /opt/conda/bin/python -m conda init --dev bash)" echo "safety_checks: disabled" >> ~/.condarc echo "safety_checks: disabled" > ~/.condarc echo "local_repodata_ttl: 1800" >> ~/.condarc conda create -n blarg -yq --download-only python=2.7 conda create -n blarg -yq -c https://repo.anaconda.com/pkgs/free --download-only python=3.4 Loading conda/activate.py +121 −24 Original line number Diff line number Diff line Loading @@ -10,10 +10,11 @@ from glob import glob from itertools import chain from logging import getLogger import os from os.path import abspath, basename, dirname, expanduser, expandvars, isdir, join from os.path import abspath, basename, dirname, expanduser, expandvars, isdir, join, exists import re import sys from textwrap import dedent import json # Since we have to have configuration context here, anything imported by # conda.base.context is fair game, but nothing more. Loading @@ -23,6 +24,7 @@ from ._vendor.auxlib.compat import Utf8NamedTemporaryFile from .base.context import ROOT_ENV_NAME, context, locate_prefix_by_name from .common.compat import FILESYSTEM_ENCODING, PY2, iteritems, on_win, string_types, text_type from .common.path import paths_equal from .base.constants import PREFIX_STATE_FILE, PACKAGE_ENV_VARS_DIR, CONDA_ENV_VARS_UNSET_VAR log = getLogger(__name__) Loading Loading @@ -244,13 +246,24 @@ class _Activator(object): context.dev = True if command == 'activate': self.stack = context.auto_stack and context.shlvl <= context.auto_stack try: stack_idx = remainder_args.index('--stack') except ValueError: self.stack = False else: del remainder_args[stack_idx] stack_idx = -1 try: no_stack_idx = remainder_args.index('--no-stack') except ValueError: no_stack_idx = -1 if stack_idx >= 0 and no_stack_idx >= 0: from .exceptions import ArgumentError raise ArgumentError('cannot specify both --stack and --no-stack to ' + command) if stack_idx >= 0: self.stack = True del remainder_args[stack_idx] if no_stack_idx >= 0: self.stack = False del remainder_args[no_stack_idx] if len(remainder_args) > 1: from .exceptions import ArgumentError raise ArgumentError(command + ' does not accept more than one argument:\n' Loading Loading @@ -312,17 +325,34 @@ class _Activator(object): activate_scripts = self._get_activate_scripts(prefix) conda_default_env = self._default_env(prefix) conda_prompt_modifier = self._prompt_modifier(prefix, conda_default_env) conda_environment_env_vars = self._get_environment_env_vars(prefix) unset_env_vars = [k for k, v in conda_environment_env_vars.items() if v == CONDA_ENV_VARS_UNSET_VAR] [conda_environment_env_vars.pop(_) for _ in unset_env_vars] clobbering_env_vars = [k for k in conda_environment_env_vars.keys() if k in os.environ.keys()] for cvar in clobbering_env_vars: save_var = "__CONDA_SHLVL_%s_%s" % (old_conda_shlvl, cvar) conda_environment_env_vars[save_var] = os.environ.get(cvar) if clobbering_env_vars: print("WARNING: overwriting environment variables set in the machine", file=sys.stderr) print("overwriting variable %s" % ' '.join(clobbering_env_vars), file=sys.stderr) unset_vars = [] if old_conda_shlvl == 0: new_path = self.pathsep_join(self._add_prefix_to_path(prefix)) export_vars, unset_vars = self.get_export_unset_vars( odargs=OrderedDict(( env_vars_to_export = OrderedDict(( ('path', new_path), ('conda_prefix', prefix), ('conda_shlvl', new_conda_shlvl), ('conda_default_env', conda_default_env), ('conda_prompt_modifier', conda_prompt_modifier)))) ('conda_prompt_modifier', conda_prompt_modifier))) for k, v in conda_environment_env_vars.items(): env_vars_to_export[k] = v export_vars, unset_vars = self.get_export_unset_vars(odargs=env_vars_to_export) deactivate_scripts = () else: if self.environ.get('CONDA_PREFIX_%s' % (old_conda_shlvl - 1)) == prefix: Loading @@ -332,24 +362,30 @@ class _Activator(object): if stack: new_path = self.pathsep_join(self._add_prefix_to_path(prefix)) deactivate_scripts = () export_vars, unset_vars = self.get_export_unset_vars(odargs=OrderedDict(( env_vars_to_export = OrderedDict(( ('path', new_path), ('conda_prefix', prefix), ('conda_shlvl', new_conda_shlvl), ('conda_default_env', conda_default_env), ('conda_prompt_modifier', conda_prompt_modifier)))) ('conda_prompt_modifier', conda_prompt_modifier))) for k, v in conda_environment_env_vars.items(): env_vars_to_export[k] = v export_vars, unset_vars = self.get_export_unset_vars(odargs=env_vars_to_export) export_vars['CONDA_PREFIX_%d' % old_conda_shlvl] = old_conda_prefix export_vars['CONDA_STACKED_%d' % new_conda_shlvl] = 'true' else: new_path = self.pathsep_join( self._replace_prefix_in_path(old_conda_prefix, prefix)) deactivate_scripts = self._get_deactivate_scripts(old_conda_prefix) export_vars, unset_vars = self.get_export_unset_vars(odargs=OrderedDict(( env_vars_to_export = OrderedDict(( ('path', new_path), ('conda_prefix', prefix), ('conda_shlvl', new_conda_shlvl), ('conda_default_env', conda_default_env), ('conda_prompt_modifier', conda_prompt_modifier)))) ('conda_prompt_modifier', conda_prompt_modifier))) for k, v in conda_environment_env_vars.items(): env_vars_to_export[k] = v export_vars, unset_vars = self.get_export_unset_vars(odargs=env_vars_to_export) export_vars['CONDA_PREFIX_%d' % old_conda_shlvl] = old_conda_prefix set_vars = {} Loading Loading @@ -381,6 +417,7 @@ class _Activator(object): 'activate_scripts': (), } deactivate_scripts = self._get_deactivate_scripts(old_conda_prefix) old_conda_environment_env_vars = self._get_environment_env_vars(old_conda_prefix) new_conda_shlvl = old_conda_shlvl - 1 set_vars = {} Loading @@ -406,6 +443,7 @@ class _Activator(object): new_prefix = self.environ.get('CONDA_PREFIX_%d' % new_conda_shlvl) conda_default_env = self._default_env(new_prefix) conda_prompt_modifier = self._prompt_modifier(new_prefix, conda_default_env) new_conda_environment_env_vars = self._get_environment_env_vars(new_prefix) old_prefix_stacked = 'CONDA_STACKED_%d' % old_conda_shlvl in self.environ new_path = '' Loading @@ -419,11 +457,14 @@ class _Activator(object): self._replace_prefix_in_path(old_conda_prefix, new_prefix) ) export_vars, unset_vars2 = self.get_export_unset_vars(odargs=OrderedDict(( env_vars_to_export = OrderedDict(( ('conda_prefix', new_prefix), ('conda_shlvl', new_conda_shlvl), ('conda_default_env', conda_default_env), ('conda_prompt_modifier', conda_prompt_modifier)))) ('conda_prompt_modifier', conda_prompt_modifier))) for k, v in new_conda_environment_env_vars.items(): env_vars_to_export[k] = v export_vars, unset_vars2 = self.get_export_unset_vars(odargs=env_vars_to_export) unset_vars += unset_vars2 export_path = {'PATH': new_path, } activate_scripts = self._get_activate_scripts(new_prefix) Loading @@ -431,6 +472,11 @@ class _Activator(object): if context.changeps1: self._update_prompt(set_vars, conda_prompt_modifier) for env_var in old_conda_environment_env_vars.keys(): unset_vars.append(env_var) save_var = "__CONDA_SHLVL_%s_%s" % (new_conda_shlvl, env_var) if save_var in os.environ.keys(): export_vars[env_var] = os.environ[save_var] return { 'unset_vars': unset_vars, 'set_vars': set_vars, Loading @@ -456,19 +502,27 @@ class _Activator(object): conda_default_env = self.environ.get('CONDA_DEFAULT_ENV', self._default_env(conda_prefix)) new_path = self.pathsep_join(self._replace_prefix_in_path(conda_prefix, conda_prefix)) set_vars = {} conda_prompt_modifier = self._prompt_modifier(conda_prefix, conda_default_env) if context.changeps1: self._update_prompt(set_vars, conda_prompt_modifier) env_vars_to_unset = () env_vars_to_export = OrderedDict([ ('PATH', new_path), ('CONDA_SHLVL', conda_shlvl), ('CONDA_PROMPT_MODIFIER', self._prompt_modifier(conda_prefix, conda_default_env)), ]) conda_environment_env_vars = self._get_environment_env_vars(conda_prefix) for k, v in conda_environment_env_vars.items(): if v == CONDA_ENV_VARS_UNSET_VAR: env_vars_to_unset = env_vars_to_unset + (k,) else: env_vars_to_export[k] = v # environment variables are set only to aid transition from conda 4.3 to conda 4.4 return { 'unset_vars': (), 'unset_vars': env_vars_to_unset, 'set_vars': set_vars, 'export_vars': OrderedDict([('PATH', new_path), ('CONDA_SHLVL', conda_shlvl), ('CONDA_PROMPT_MODIFIER', self._prompt_modifier( conda_prefix, conda_default_env))]), 'export_vars': env_vars_to_export, 'deactivate_scripts': self._get_deactivate_scripts(conda_prefix), 'activate_scripts': self._get_activate_scripts(conda_prefix), } Loading Loading @@ -651,6 +705,31 @@ class _Activator(object): prefix, 'etc', 'conda', 'deactivate.d', '*' + self.script_extension )), reverse=True)) def _get_environment_env_vars(self, prefix): env_vars_file = join(prefix, PREFIX_STATE_FILE) pkg_env_var_dir = join(prefix, PACKAGE_ENV_VARS_DIR) env_vars = OrderedDict() # First get env vars from packages if exists(pkg_env_var_dir): for pkg_env_var_file in sorted(os.listdir(pkg_env_var_dir)): with open(join(pkg_env_var_dir, pkg_env_var_file), 'r') as f: env_vars.update(json.loads(f.read(), object_pairs_hook=OrderedDict)) # Then get env vars from environment specification if exists(env_vars_file): with open(env_vars_file, 'r') as f: prefix_state = json.loads(f.read(), object_pairs_hook=OrderedDict) prefix_state_env_vars = prefix_state.get('env_vars', {}) dup_vars = [ev for ev in env_vars.keys() if ev in prefix_state_env_vars.keys()] for dup in dup_vars: print("WARNING: duplicate env vars detected. Vars from the environment " "will overwrite those from packages", file=sys.stderr) print("variable %s duplicated" % dup, file=sys.stderr) env_vars.update(prefix_state_env_vars) return env_vars def expand(path): return abspath(expanduser(expandvars(path))) Loading Loading @@ -833,25 +912,43 @@ class CshActivator(_Activator): class XonshActivator(_Activator): @staticmethod def path_conversion(paths): if not on_win: return path_identity(paths) elif isinstance(paths, string_types): return paths.replace('\\', '/') elif paths is None: return None else: return tuple([path.replace('\\', '/') for path in paths]) def __init__(self, arguments=None): self.pathsep_join = ':'.join self.pathsep_join = ';'.join if on_win else ':'.join self.sep = '/' self.path_conversion = native_path_to_unix self.script_extension = '.xsh' self.tempfile_extension = None self.command_join = '\n' self.unset_var_tmpl = 'del $%s' self.export_var_tmpl = "$%s = '%s'" self.set_var_tmpl = "$%s = '%s'" # TODO: determine if different than export_var_tmpl self.run_script_tmpl = 'source "%s"' # 'scripts' really refer to de/activation scripts, not scripts in the language per se # xonsh can piggy-back activation scripts from other languages depending on the platform import platform if platform.system() == 'Windows': self.script_extension = '.bat' self.run_script_tmpl = 'source-cmd "%s"' else: self.script_extension = '.sh' self.run_script_tmpl = 'source-bash "%s"' self.hook_source_path = join(CONDA_PACKAGE_ROOT, 'shell', 'conda.xsh') super(XonshActivator, self).__init__(arguments) def _hook_preamble(self): return '$CONDA_EXE = "%s"' % context.conda_exe return '$CONDA_EXE = "%s"' % self.path_conversion(context.conda_exe) class CmdExeActivator(_Activator): Loading conda/base/constants.py +4 −0 Original line number Diff line number Diff line Loading @@ -228,6 +228,10 @@ class SatSolverChoice(Enum): PACKAGE_CACHE_MAGIC_FILE = 'urls.txt' PREFIX_MAGIC_FILE = join('conda-meta', 'history') PREFIX_STATE_FILE = join('conda-meta', 'state') PACKAGE_ENV_VARS_DIR = join('etc', 'conda', 'env_vars.d') CONDA_ENV_VARS_UNSET_VAR = "***unset***" # TODO: should be frozendict(), but I don't want to import frozendict from auxlib here. NAMESPACES_MAP = { # base package name, namespace Loading Loading
.gitignore +3 −0 Original line number Diff line number Diff line Loading @@ -36,3 +36,6 @@ miniconda*.exe docs/source/_build **/.vscode conda.tmp/ *.iml *.ipr *.iws
CHANGELOG.md +123 −3 Original line number Diff line number Diff line ## 4.8.1 (2019-12-19) ### Enhancements: * improve performance for conda run by avoiding Popen.communicate (#9381) * Put conda keyring in /usr/share/keyrings on Debian (#9424) * refactor common.logic to fix some bugs and prepare for better modularity (#9427) * Support nested configuration (#9449) * Support Object configuration parameters (#9465) * Use freeze_installed to speed up conda env update (#9511) * add networking args to conda env create (#9525) ### Docs: * fix string concatenation running words together regarding CONDA_EXE (#9411) * Fix typo ("list" -> "info") (#9433) * typo in condarc key envs_dirs (#9478) * Clarify channel priority and package sorting (#9492) * improve description of DLL loading verification and activating environments (#9453) * Installing with specific build number (#9534) ### Bug fixes: * Fix calling python api run_command with list and string arguments (#9331) * revert init bash completion (#9421) * set tmp to shortened path that excludes spaces (#9409) * avoid function redefinition upon resourcing conda.fish (#9444) * propagate pip error level when creating envs with conda env (#9460) * fix incorrect chown call (#9464) * Add subdir to PackageRecord dist_str (#9418) * Fix running conda activate in multiple processes on windows (#9477) * Don't check in pkgs for trash (#9472) * remove setuptools from run_constrained in recipe (#9485) * Fix `__conda_activate` function to correctly return exit code (#9532) * fix overly greedy capture done by subprocess for conda run (#9537) ### Contributors: * @AntoinePrv * @brettcannon * @bwildenhain * @cjmartian * @felker * @forrestwaters * @gilescope * @isuruf * @jeremyjliu * @jjhelmus * @jhultman * @marcuscaisey * @mbargull * @mingwandroid * @msarahan * @okhoma * @osamoylenko * @rrigdon * @rulerofthehuns * @soapy1 * @tartansandal ## 4.8.0rc0 (2019-11-04) ### Enhancements: * retry downloads if they fail, controlled by `remote_max_retries` and `remote_backoff_factor` configuration values (#9318) * redact authentication information in some URLs (#9341) * add osx version virtual package , `__osx` (#9349) * add glibc virtual package, `__glibc` (#9358) ### Docs * removeed references to MD5s from docs (#9247) * Add docs on `CONDA_DLL_SEARCH_MODIFICATION_ENABLED` (#9286) * document threads, spec history and configuration (#9327) * more documentation on channels (#9335) * document the .condarc search order (#9369) * various minor documentation fixes (#9238, #9248, #9267, #9334, #9351, #9372, #9378, #9388, #9391, #9393) ### Bug fixes * fix issues with xonsh activation on Windows (#8246) * remove unsupported --lock argument from conda clean (#8310) * do not add `sys_prefix_path` to failed activation or deactivation (#9282) * fix csh setenv command (#9284) * do not memorize `PackageRecord.combined_depends` (#9289) * use `CONDA_INTERNAL_OLDPATH` rather than `OLDPATH` in activation script (#9303) * fixes xonsh activation and tab completion (#9305) * fix what channels are queried when context.offline is True (#9385) ### Contributors * @analog-cbarber * @andreasg123 * @beckermr * @bryant1410 * @colinbrislawn * @felker * @forrestwaters * @gabrielcnr * @isuruf * @jakirkham * @jeremyjliu * @jjhelmus * @jooh * @jpigla * @marcelotrevisani * @melund * @mfansler * @mingwandroid * @msarahan * @rrigdon * @scopatz * @soapy1 * @WillyChen123 * @xhochy ## 4.7.12 (2019-09-12) ### Enhancements: Loading
circle.yml +2 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ main_test: &main_test if [[ $(git diff origin/master --name-only | wc -l) == $(git diff origin/master --name-only | grep docs | wc -l) && $(git diff origin/master --name-only | grep docs) ]]; then echo "Only docs changed detected, skipping tests" else echo "local_repodata_ttl: 1800" >> ~/.condarc echo "local_repodata_ttl: 1800" > ~/.condarc eval "$(sudo /opt/conda/bin/python -m conda init --dev bash)" conda info # remove the pkg cache. We can't hardlink from here anyway. Having it around causes log problems. Loading Loading @@ -74,7 +74,7 @@ conda_build_test: &conda_build_test # pre-populating the package cache helps avoid race conditions for testing in parallel command: | eval "$(sudo /opt/conda/bin/python -m conda init --dev bash)" echo "safety_checks: disabled" >> ~/.condarc echo "safety_checks: disabled" > ~/.condarc echo "local_repodata_ttl: 1800" >> ~/.condarc conda create -n blarg -yq --download-only python=2.7 conda create -n blarg -yq -c https://repo.anaconda.com/pkgs/free --download-only python=3.4 Loading
conda/activate.py +121 −24 Original line number Diff line number Diff line Loading @@ -10,10 +10,11 @@ from glob import glob from itertools import chain from logging import getLogger import os from os.path import abspath, basename, dirname, expanduser, expandvars, isdir, join from os.path import abspath, basename, dirname, expanduser, expandvars, isdir, join, exists import re import sys from textwrap import dedent import json # Since we have to have configuration context here, anything imported by # conda.base.context is fair game, but nothing more. Loading @@ -23,6 +24,7 @@ from ._vendor.auxlib.compat import Utf8NamedTemporaryFile from .base.context import ROOT_ENV_NAME, context, locate_prefix_by_name from .common.compat import FILESYSTEM_ENCODING, PY2, iteritems, on_win, string_types, text_type from .common.path import paths_equal from .base.constants import PREFIX_STATE_FILE, PACKAGE_ENV_VARS_DIR, CONDA_ENV_VARS_UNSET_VAR log = getLogger(__name__) Loading Loading @@ -244,13 +246,24 @@ class _Activator(object): context.dev = True if command == 'activate': self.stack = context.auto_stack and context.shlvl <= context.auto_stack try: stack_idx = remainder_args.index('--stack') except ValueError: self.stack = False else: del remainder_args[stack_idx] stack_idx = -1 try: no_stack_idx = remainder_args.index('--no-stack') except ValueError: no_stack_idx = -1 if stack_idx >= 0 and no_stack_idx >= 0: from .exceptions import ArgumentError raise ArgumentError('cannot specify both --stack and --no-stack to ' + command) if stack_idx >= 0: self.stack = True del remainder_args[stack_idx] if no_stack_idx >= 0: self.stack = False del remainder_args[no_stack_idx] if len(remainder_args) > 1: from .exceptions import ArgumentError raise ArgumentError(command + ' does not accept more than one argument:\n' Loading Loading @@ -312,17 +325,34 @@ class _Activator(object): activate_scripts = self._get_activate_scripts(prefix) conda_default_env = self._default_env(prefix) conda_prompt_modifier = self._prompt_modifier(prefix, conda_default_env) conda_environment_env_vars = self._get_environment_env_vars(prefix) unset_env_vars = [k for k, v in conda_environment_env_vars.items() if v == CONDA_ENV_VARS_UNSET_VAR] [conda_environment_env_vars.pop(_) for _ in unset_env_vars] clobbering_env_vars = [k for k in conda_environment_env_vars.keys() if k in os.environ.keys()] for cvar in clobbering_env_vars: save_var = "__CONDA_SHLVL_%s_%s" % (old_conda_shlvl, cvar) conda_environment_env_vars[save_var] = os.environ.get(cvar) if clobbering_env_vars: print("WARNING: overwriting environment variables set in the machine", file=sys.stderr) print("overwriting variable %s" % ' '.join(clobbering_env_vars), file=sys.stderr) unset_vars = [] if old_conda_shlvl == 0: new_path = self.pathsep_join(self._add_prefix_to_path(prefix)) export_vars, unset_vars = self.get_export_unset_vars( odargs=OrderedDict(( env_vars_to_export = OrderedDict(( ('path', new_path), ('conda_prefix', prefix), ('conda_shlvl', new_conda_shlvl), ('conda_default_env', conda_default_env), ('conda_prompt_modifier', conda_prompt_modifier)))) ('conda_prompt_modifier', conda_prompt_modifier))) for k, v in conda_environment_env_vars.items(): env_vars_to_export[k] = v export_vars, unset_vars = self.get_export_unset_vars(odargs=env_vars_to_export) deactivate_scripts = () else: if self.environ.get('CONDA_PREFIX_%s' % (old_conda_shlvl - 1)) == prefix: Loading @@ -332,24 +362,30 @@ class _Activator(object): if stack: new_path = self.pathsep_join(self._add_prefix_to_path(prefix)) deactivate_scripts = () export_vars, unset_vars = self.get_export_unset_vars(odargs=OrderedDict(( env_vars_to_export = OrderedDict(( ('path', new_path), ('conda_prefix', prefix), ('conda_shlvl', new_conda_shlvl), ('conda_default_env', conda_default_env), ('conda_prompt_modifier', conda_prompt_modifier)))) ('conda_prompt_modifier', conda_prompt_modifier))) for k, v in conda_environment_env_vars.items(): env_vars_to_export[k] = v export_vars, unset_vars = self.get_export_unset_vars(odargs=env_vars_to_export) export_vars['CONDA_PREFIX_%d' % old_conda_shlvl] = old_conda_prefix export_vars['CONDA_STACKED_%d' % new_conda_shlvl] = 'true' else: new_path = self.pathsep_join( self._replace_prefix_in_path(old_conda_prefix, prefix)) deactivate_scripts = self._get_deactivate_scripts(old_conda_prefix) export_vars, unset_vars = self.get_export_unset_vars(odargs=OrderedDict(( env_vars_to_export = OrderedDict(( ('path', new_path), ('conda_prefix', prefix), ('conda_shlvl', new_conda_shlvl), ('conda_default_env', conda_default_env), ('conda_prompt_modifier', conda_prompt_modifier)))) ('conda_prompt_modifier', conda_prompt_modifier))) for k, v in conda_environment_env_vars.items(): env_vars_to_export[k] = v export_vars, unset_vars = self.get_export_unset_vars(odargs=env_vars_to_export) export_vars['CONDA_PREFIX_%d' % old_conda_shlvl] = old_conda_prefix set_vars = {} Loading Loading @@ -381,6 +417,7 @@ class _Activator(object): 'activate_scripts': (), } deactivate_scripts = self._get_deactivate_scripts(old_conda_prefix) old_conda_environment_env_vars = self._get_environment_env_vars(old_conda_prefix) new_conda_shlvl = old_conda_shlvl - 1 set_vars = {} Loading @@ -406,6 +443,7 @@ class _Activator(object): new_prefix = self.environ.get('CONDA_PREFIX_%d' % new_conda_shlvl) conda_default_env = self._default_env(new_prefix) conda_prompt_modifier = self._prompt_modifier(new_prefix, conda_default_env) new_conda_environment_env_vars = self._get_environment_env_vars(new_prefix) old_prefix_stacked = 'CONDA_STACKED_%d' % old_conda_shlvl in self.environ new_path = '' Loading @@ -419,11 +457,14 @@ class _Activator(object): self._replace_prefix_in_path(old_conda_prefix, new_prefix) ) export_vars, unset_vars2 = self.get_export_unset_vars(odargs=OrderedDict(( env_vars_to_export = OrderedDict(( ('conda_prefix', new_prefix), ('conda_shlvl', new_conda_shlvl), ('conda_default_env', conda_default_env), ('conda_prompt_modifier', conda_prompt_modifier)))) ('conda_prompt_modifier', conda_prompt_modifier))) for k, v in new_conda_environment_env_vars.items(): env_vars_to_export[k] = v export_vars, unset_vars2 = self.get_export_unset_vars(odargs=env_vars_to_export) unset_vars += unset_vars2 export_path = {'PATH': new_path, } activate_scripts = self._get_activate_scripts(new_prefix) Loading @@ -431,6 +472,11 @@ class _Activator(object): if context.changeps1: self._update_prompt(set_vars, conda_prompt_modifier) for env_var in old_conda_environment_env_vars.keys(): unset_vars.append(env_var) save_var = "__CONDA_SHLVL_%s_%s" % (new_conda_shlvl, env_var) if save_var in os.environ.keys(): export_vars[env_var] = os.environ[save_var] return { 'unset_vars': unset_vars, 'set_vars': set_vars, Loading @@ -456,19 +502,27 @@ class _Activator(object): conda_default_env = self.environ.get('CONDA_DEFAULT_ENV', self._default_env(conda_prefix)) new_path = self.pathsep_join(self._replace_prefix_in_path(conda_prefix, conda_prefix)) set_vars = {} conda_prompt_modifier = self._prompt_modifier(conda_prefix, conda_default_env) if context.changeps1: self._update_prompt(set_vars, conda_prompt_modifier) env_vars_to_unset = () env_vars_to_export = OrderedDict([ ('PATH', new_path), ('CONDA_SHLVL', conda_shlvl), ('CONDA_PROMPT_MODIFIER', self._prompt_modifier(conda_prefix, conda_default_env)), ]) conda_environment_env_vars = self._get_environment_env_vars(conda_prefix) for k, v in conda_environment_env_vars.items(): if v == CONDA_ENV_VARS_UNSET_VAR: env_vars_to_unset = env_vars_to_unset + (k,) else: env_vars_to_export[k] = v # environment variables are set only to aid transition from conda 4.3 to conda 4.4 return { 'unset_vars': (), 'unset_vars': env_vars_to_unset, 'set_vars': set_vars, 'export_vars': OrderedDict([('PATH', new_path), ('CONDA_SHLVL', conda_shlvl), ('CONDA_PROMPT_MODIFIER', self._prompt_modifier( conda_prefix, conda_default_env))]), 'export_vars': env_vars_to_export, 'deactivate_scripts': self._get_deactivate_scripts(conda_prefix), 'activate_scripts': self._get_activate_scripts(conda_prefix), } Loading Loading @@ -651,6 +705,31 @@ class _Activator(object): prefix, 'etc', 'conda', 'deactivate.d', '*' + self.script_extension )), reverse=True)) def _get_environment_env_vars(self, prefix): env_vars_file = join(prefix, PREFIX_STATE_FILE) pkg_env_var_dir = join(prefix, PACKAGE_ENV_VARS_DIR) env_vars = OrderedDict() # First get env vars from packages if exists(pkg_env_var_dir): for pkg_env_var_file in sorted(os.listdir(pkg_env_var_dir)): with open(join(pkg_env_var_dir, pkg_env_var_file), 'r') as f: env_vars.update(json.loads(f.read(), object_pairs_hook=OrderedDict)) # Then get env vars from environment specification if exists(env_vars_file): with open(env_vars_file, 'r') as f: prefix_state = json.loads(f.read(), object_pairs_hook=OrderedDict) prefix_state_env_vars = prefix_state.get('env_vars', {}) dup_vars = [ev for ev in env_vars.keys() if ev in prefix_state_env_vars.keys()] for dup in dup_vars: print("WARNING: duplicate env vars detected. Vars from the environment " "will overwrite those from packages", file=sys.stderr) print("variable %s duplicated" % dup, file=sys.stderr) env_vars.update(prefix_state_env_vars) return env_vars def expand(path): return abspath(expanduser(expandvars(path))) Loading Loading @@ -833,25 +912,43 @@ class CshActivator(_Activator): class XonshActivator(_Activator): @staticmethod def path_conversion(paths): if not on_win: return path_identity(paths) elif isinstance(paths, string_types): return paths.replace('\\', '/') elif paths is None: return None else: return tuple([path.replace('\\', '/') for path in paths]) def __init__(self, arguments=None): self.pathsep_join = ':'.join self.pathsep_join = ';'.join if on_win else ':'.join self.sep = '/' self.path_conversion = native_path_to_unix self.script_extension = '.xsh' self.tempfile_extension = None self.command_join = '\n' self.unset_var_tmpl = 'del $%s' self.export_var_tmpl = "$%s = '%s'" self.set_var_tmpl = "$%s = '%s'" # TODO: determine if different than export_var_tmpl self.run_script_tmpl = 'source "%s"' # 'scripts' really refer to de/activation scripts, not scripts in the language per se # xonsh can piggy-back activation scripts from other languages depending on the platform import platform if platform.system() == 'Windows': self.script_extension = '.bat' self.run_script_tmpl = 'source-cmd "%s"' else: self.script_extension = '.sh' self.run_script_tmpl = 'source-bash "%s"' self.hook_source_path = join(CONDA_PACKAGE_ROOT, 'shell', 'conda.xsh') super(XonshActivator, self).__init__(arguments) def _hook_preamble(self): return '$CONDA_EXE = "%s"' % context.conda_exe return '$CONDA_EXE = "%s"' % self.path_conversion(context.conda_exe) class CmdExeActivator(_Activator): Loading
conda/base/constants.py +4 −0 Original line number Diff line number Diff line Loading @@ -228,6 +228,10 @@ class SatSolverChoice(Enum): PACKAGE_CACHE_MAGIC_FILE = 'urls.txt' PREFIX_MAGIC_FILE = join('conda-meta', 'history') PREFIX_STATE_FILE = join('conda-meta', 'state') PACKAGE_ENV_VARS_DIR = join('etc', 'conda', 'env_vars.d') CONDA_ENV_VARS_UNSET_VAR = "***unset***" # TODO: should be frozendict(), but I don't want to import frozendict from auxlib here. NAMESPACES_MAP = { # base package name, namespace Loading