From 289ed8799483bbfff005dd8bffa9ab246aa27a7c Mon Sep 17 00:00:00 2001 From: "Michael C. Grant" Date: Tue, 5 Nov 2024 18:07:02 -0600 Subject: [PATCH] fix tests --- nb_conda_kernels/manager.py | 16 +++++++++++----- tests/test_config.py | 5 +++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/nb_conda_kernels/manager.py b/nb_conda_kernels/manager.py index fb1df21..f304ea7 100644 --- a/nb_conda_kernels/manager.py +++ b/nb_conda_kernels/manager.py @@ -201,11 +201,17 @@ def get_conda_info_data(): # differences in one place envs = list(map(_canonicalize, conda_info.get('envs') or ())) base_prefix = _canonicalize(conda_info.get('conda_prefix') or conda_info.get('base environment')) + version = conda_info.get('conda_version') or conda_info.get('micromamba version') if base_prefix not in envs: # Older versions of conda do not include base_prefix in the env list envs.insert(0, base_prefix) - return (base_prefix, envs), msg + return { + "conda_exe": conda_exe, + "conda_version": version, + "conda_prefix": base_prefix, + "envs": envs, + }, msg class CondaInfoThread(threading.Thread): def run(self): @@ -255,9 +261,9 @@ def _all_envs(self): environments in the conda-bld directory. Returns a dict with canonical environment names as keys, and full paths as values. """ - base_prefix, envs = self._conda_info - if not envs: - return {} + conda_info = self._conda_info + envs = conda_info['envs'] + base_prefix = conda_info['conda_prefix'] envs_prefix = join(base_prefix, 'envs') build_prefix = join(base_prefix, 'conda-bld', '') all_envs = {} @@ -302,7 +308,7 @@ def _all_specs(self): all_specs = {} # We need to be able to find conda-run in the base conda environment # even if this package is not running there - conda_prefix, _ = self._conda_info + conda_prefix = self._conda_info['conda_prefix'] all_envs = self._all_envs() for env_name, env_path in all_envs.items(): kspec_base = join(env_path, 'share', 'jupyter', 'kernels') diff --git a/tests/test_config.py b/tests/test_config.py index bee27f7..9e6fd6b 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -37,8 +37,9 @@ def test_configuration(): print('ERROR: Could not find conda find conda.') exit(-1) print(u'Current prefix: {}'.format(sys.prefix)) - print(u'Root prefix: {}'.format(conda_info['root_prefix'])) - print(u'Conda version: {}'.format(conda_info['conda_version'])) + print(u'Conda prefix: {}'.format(conda_info['conda_prefix'])) + conda_exe = os.path.basename(conda_info['conda_exe']).replace('.exe', '') + print(u'Conda version: {} {}'.format(conda_exe, conda_info['conda_version'])) print(u'Environments:') for env in conda_info['envs']: print(u' - {}'.format(env))