diff --git a/.github/workflows/test-files.yml b/.github/workflows/test-files.yml index 313fd10a4e7..2e14bebf9b9 100644 --- a/.github/workflows/test-files.yml +++ b/.github/workflows/test-files.yml @@ -43,6 +43,8 @@ concurrency: jobs: build: + # Use this to disable the workflow + # if: false name: Linux - Py${{ matrix.PYTHON_VERSION }} runs-on: ubuntu-latest env: diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index cd7d97edd98..974ffd672b5 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -43,6 +43,8 @@ concurrency: jobs: build: + # Use this to disable the workflow + # if: false name: Linux - Py${{ matrix.PYTHON_VERSION }}, ${{ matrix.INSTALL_TYPE }}, ${{ matrix.TEST_TYPE }} runs-on: ubuntu-20.04 env: diff --git a/.github/workflows/test-mac.yml b/.github/workflows/test-mac.yml index 99eef6e2cb2..d7d292139b8 100644 --- a/.github/workflows/test-mac.yml +++ b/.github/workflows/test-mac.yml @@ -43,6 +43,8 @@ concurrency: jobs: build: + # Use this to disable the workflow + # if: false name: Mac - Py${{ matrix.PYTHON_VERSION }}, ${{ matrix.INSTALL_TYPE }}, ${{ matrix.TEST_TYPE }} runs-on: macos-12 env: diff --git a/.github/workflows/test-win.yml b/.github/workflows/test-win.yml index f7caceae6be..95e4f0fcb85 100644 --- a/.github/workflows/test-win.yml +++ b/.github/workflows/test-win.yml @@ -43,6 +43,8 @@ concurrency: jobs: build: + # Use this to disable the workflow + # if: false name: Windows - Py${{ matrix.PYTHON_VERSION }}, ${{ matrix.INSTALL_TYPE }}, ${{ matrix.TEST_TYPE }} runs-on: windows-latest env: diff --git a/spyder/utils/conda.py b/spyder/utils/conda.py index 49dfbb1d5b4..b34f2ff1f6a 100644 --- a/spyder/utils/conda.py +++ b/spyder/utils/conda.py @@ -20,6 +20,24 @@ CONDA_ENV_LIST_CACHE = {} +def _env_for_conda(): + """ + Required environment variables for Conda to work as expected. + + Notes + ----- + This is needed on Windows since Conda 23.9.0 + """ + env = {} + if os.name == 'nt': + env_vars = [("HOMEDRIVE", "C:"), ("HOMEPATH", "\\Users\\xxxxx")] + for var, default in env_vars: + value = os.environ.get(var, default) + env[var] = value + + return env + + def add_quotes(path): """Return quotes if needed for spaces on path.""" quotes = '"' if ' ' in path and '"' not in path else '' @@ -114,8 +132,9 @@ def get_list_conda_envs(): return env_list cmdstr = ' '.join([conda, 'env', 'list', '--json']) + try: - out, __ = run_shell_command(cmdstr, env={}).communicate() + out, __ = run_shell_command(cmdstr, env=_env_for_conda()).communicate() out = out.decode() out = json.loads(out) except Exception: @@ -126,6 +145,10 @@ def get_list_conda_envs(): path = osp.join(env, 'python.exe') if WINDOWS else osp.join( env, 'bin', 'python') + # In case the environment doesn't have Python + if not osp.isfile(path): + continue + try: version, __ = run_program(path, ['--version']).communicate() version = version.decode() @@ -167,7 +190,7 @@ def get_spyder_conda_channel(): cmdstr = ' '.join([conda, 'list', 'spyder', '--json', '--prefix', env]) try: - out, __ = run_shell_command(cmdstr, env={}).communicate() + out, __ = run_shell_command(cmdstr, env=_env_for_conda()).communicate() out = out.decode() out = json.loads(out) except Exception: diff --git a/spyder/utils/tests/test_conda.py b/spyder/utils/tests/test_conda.py index c7cc1881f88..6e006a1ea22 100644 --- a/spyder/utils/tests/test_conda.py +++ b/spyder/utils/tests/test_conda.py @@ -65,9 +65,10 @@ def test_find_conda(): @pytest.mark.skipif(not running_in_ci(), reason="Only meant for CIs") def test_get_list_conda_envs(): output = get_list_conda_envs() - expected_envs = ['base', 'test', 'jedi-test-env', 'spytest-ž'] + expected_envs = ['base', 'jedi-test-env', 'spytest-ž', 'test'] expected_envs = ['conda: ' + env for env in expected_envs] + assert set(expected_envs) == set(output.keys())