Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mcg1969 committed Nov 6, 2024
1 parent b2729d1 commit 289ed87
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
16 changes: 11 additions & 5 deletions nb_conda_kernels/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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')
Expand Down
5 changes: 3 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 289ed87

Please sign in to comment.