From 2fe9912333c6d125fd0291bc7b0ffab30e8822ae Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 25 Feb 2024 15:04:14 +0100 Subject: [PATCH 1/3] tests: test pip install plugin with no-dependency package This is a simplification to help ensure we don't run into issues like below because requests gets installed via pip. ``` RemoveError: 'requests' is a dependency of conda and cannot be removed from conda's operating environment. ``` --- integration-tests/plugins/simplest/tljh_simplest.py | 2 +- integration-tests/test_simplest_plugin.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/plugins/simplest/tljh_simplest.py b/integration-tests/plugins/simplest/tljh_simplest.py index ff433f8..eda8c1d 100644 --- a/integration-tests/plugins/simplest/tljh_simplest.py +++ b/integration-tests/plugins/simplest/tljh_simplest.py @@ -12,7 +12,7 @@ def tljh_extra_user_conda_packages(): @hookimpl def tljh_extra_user_pip_packages(): - return ["django"] + return ["simplejson"] @hookimpl diff --git a/integration-tests/test_simplest_plugin.py b/integration-tests/test_simplest_plugin.py index 9c2337b..9830c47 100644 --- a/integration-tests/test_simplest_plugin.py +++ b/integration-tests/test_simplest_plugin.py @@ -20,7 +20,7 @@ def test_tljh_extra_user_conda_packages(): def test_tljh_extra_user_pip_packages(): - subprocess.check_call([f"{USER_ENV_PREFIX}/bin/python3", "-c", "import django"]) + subprocess.check_call([f"{USER_ENV_PREFIX}/bin/python3", "-c", "import simplejson"]) def test_tljh_extra_hub_pip_packages(): From 7d8a84860f29f4363ba6839dabf3916ea67a259a Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 25 Feb 2024 17:14:52 +0100 Subject: [PATCH 2/3] tests: show mamba list for the user environment before/after upgrade This can help us check if a package has been installed from PyPI via pip, or from conda-forge or other channel via conda/mamba. --- .github/integration-test.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/integration-test.py b/.github/integration-test.py index fcb8768..73ef8ba 100755 --- a/.github/integration-test.py +++ b/.github/integration-test.py @@ -167,15 +167,23 @@ def run_test( command = f"python3 /srv/src/bootstrap/bootstrap.py --version={upgrade_from}" run_command(container_name, command) + # show user environment + command = "/opt/tljh/user/bin/mamba list" + run_command(container_name, command) + command = f"python3 /srv/src/bootstrap/bootstrap.py {' '.join(installer_args)}" run_command(container_name, command) + # show user environment (again if upgrade) + command = "/opt/tljh/user/bin/mamba list" + run_command(container_name, command) + # Install pkgs from requirements in hub's pip, where # the bootstrap script installed the others command = "/opt/tljh/hub/bin/python3 -m pip install -r /srv/src/integration-tests/requirements.txt" run_command(container_name, command) - # show environment + # show hub environment command = "/opt/tljh/hub/bin/python3 -m pip freeze" run_command(container_name, command) From 4e397bc687b73c68ee96557db2daddcbb13f66c6 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Mon, 26 Feb 2024 09:40:00 +0100 Subject: [PATCH 3/3] Re-install conda/mamba for every tljh upgrade (doesn't imply upgrade) --- tljh/installer.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tljh/installer.py b/tljh/installer.py index aff24fc..5a9d767 100644 --- a/tljh/installer.py +++ b/tljh/installer.py @@ -242,11 +242,10 @@ def ensure_user_environment(user_requirements_txt_file): ) to_upgrade.append(pkg) - # force reinstall conda/mamba to ensure a basically consistent env - # avoids issues with RemoveError: 'requests' is a dependency of conda - # only do this for 'old' conda versions known to have a problem - # we don't know how old, but we know 4.10 is affected and 23.1 is not - if not is_fresh_install and V(package_versions.get("conda", "0")) < V("23.1"): + # force reinstall conda/mamba to ensure conda doesn't raise error + # "RemoveError: 'requests' is a dependency of conda" later on when + # conda/mamba is used to install/upgrade something + if not is_fresh_install: # force-reinstall doesn't upgrade packages # it reinstalls them in-place # only reinstall packages already present