diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ab542c0..b5273f7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -109,14 +109,17 @@ jobs: - name: Test the package run: | source $CONDA_ROOT/etc/profile.d/conda.sh - solver=${{ matrix.solver }} - export CONDA_EXE=$(echo $CONDA_EXE | sed -E "s@/conda(.exe)?@/${solver}\1@") [ "$RUNNER_OS" = "Windows" ] && export PYTHONIOENCODING=UTF-8 export PYTHONUNBUFFERED=1 export NBVER=6 [ 3.12 = ${{ matrix.pyver }} ] && export NBVER=7 conda create -n testbase -c ./conda-bld nb_conda_kernels python=${{ matrix.pyver }} notebook=$NBVER pytest pytest-cov mock requests conda activate testbase + solver=${{ matrix.solver }} + export CONDA_EXE=$(echo $CONDA_EXE | sed -E "s@^(.*/)conda(.*)@\\1${solver}\\2@") + [ $solver = micromamba ] && MAMBA_EXE=$CONDA_EXE + [ $solver = micromamba ] && MAMBA_ROOT_PREFIX=$CONDA_PREFIX + $CONDA_EXE env list python -m nb_conda_kernels list python -m pytest -v --cov=nb_conda_kernels tests 2>&1 | tee build.log # Because Windows refuses to preserve the error code diff --git a/nb_conda_kernels/manager.py b/nb_conda_kernels/manager.py index fb1df21..fa53c76 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): @@ -228,7 +234,7 @@ def run(self): # subprocess just finished elif t and not t.is_alive(): t.join() - conda_info, msg = t.out + conda_info, msg = t.out, t.err if msg: level = "info" if conda_info else "error" else: @@ -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/testbed/build.sh b/testbed/build.sh index a2bcaa7..e7b2410 100755 --- a/testbed/build.sh +++ b/testbed/build.sh @@ -32,6 +32,7 @@ fi full_deactivate source $CONDA_ROOT/etc/profile.d/conda.sh conda activate base +conda list if [ ! -f $CONDA_ROOT/.created ]; then conda config --prepend channels conda-forge --system diff --git a/testbed/croot.yml b/testbed/croot.yml index abcf0cc..467c3fa 100644 --- a/testbed/croot.yml +++ b/testbed/croot.yml @@ -1,13 +1,10 @@ name: conda channels: - - defaults - conda-forge dependencies: - - conda + - conda >24.9 - mamba - micromamba - - conda-build - - conda-verify - notebook - jupyter_client - ipykernel 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))