From b7f5167add11b5b545fc6c1f09dd6c4f4ffba9b4 Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Thu, 27 Feb 2025 16:17:39 +0100 Subject: [PATCH 01/15] Add offending test --- .github/workflows/windows_impl.yml | 2 +- micromamba/tests/test_menuinst.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows_impl.yml b/.github/workflows/windows_impl.yml index 31c4287f92..6cf1c986f7 100644 --- a/.github/workflows/windows_impl.yml +++ b/.github/workflows/windows_impl.yml @@ -153,6 +153,6 @@ jobs: $env:MAMBA_TEST_SHELL_TYPE='powershell' Remove-Item -Path "env:CONDARC" # Only rerun flaky tests on the `main` branch - python -m pytest micromamba/tests/ ` + python -m pytest micromamba/tests/test_menuinst.py ` ${{ runner.debug == 'true' && '-v --capture=tee-sys' || '--exitfirst' }} ` ${{ github.ref == 'refs/heads/main' && '--reruns 3' || '' }} diff --git a/micromamba/tests/test_menuinst.py b/micromamba/tests/test_menuinst.py index a7ee0ab980..77c2a4768e 100644 --- a/micromamba/tests/test_menuinst.py +++ b/micromamba/tests/test_menuinst.py @@ -98,3 +98,13 @@ def test_shortcut_weird_env(self): shutil.rmtree(root_prefix) os.environ["MAMBA_ROOT_PREFIX"] = self.root_prefix + + @pytest.mark.skipif( + not sys.platform.startswith("win"), + reason="skipping windows-only tests", + ) + def test_spyder_shortcut(self): + env_name = random_string() + create("python=3.12", "spyder=6.0.3", "-n", env_name, no_dry_run=True) + print("menuinst.win32.dirs_src: ", menuinst.win32.dirs_src) + assert False From 63191daa6b074600de13d2ba5350af81873648bc Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Thu, 27 Feb 2025 16:33:58 +0100 Subject: [PATCH 02/15] Add ls --- micromamba/tests/test_menuinst.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/micromamba/tests/test_menuinst.py b/micromamba/tests/test_menuinst.py index 77c2a4768e..cdc9546389 100644 --- a/micromamba/tests/test_menuinst.py +++ b/micromamba/tests/test_menuinst.py @@ -107,4 +107,6 @@ def test_spyder_shortcut(self): env_name = random_string() create("python=3.12", "spyder=6.0.3", "-n", env_name, no_dry_run=True) print("menuinst.win32.dirs_src: ", menuinst.win32.dirs_src) + d = menuinst.win32.dirs_src["user"]["start"][0] + print("ls: ", os.listdir(d)) assert False From f699f54f397ab3b91b2c294f732041a96fca7f4a Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Thu, 27 Feb 2025 16:50:29 +0100 Subject: [PATCH 03/15] Add spyder path --- micromamba/tests/test_menuinst.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/micromamba/tests/test_menuinst.py b/micromamba/tests/test_menuinst.py index cdc9546389..c27016e473 100644 --- a/micromamba/tests/test_menuinst.py +++ b/micromamba/tests/test_menuinst.py @@ -109,4 +109,7 @@ def test_spyder_shortcut(self): print("menuinst.win32.dirs_src: ", menuinst.win32.dirs_src) d = menuinst.win32.dirs_src["user"]["start"][0] print("ls: ", os.listdir(d)) + distribution_name = os.getenv("DISTRIBUTION_NAME") + spyder_path = os.path.join(d, f"{distribution_name} spyder") + print("ls spyder path: ", os.listdir(spyder_path)) assert False From f8dcc0bcae3f5bbccb0e5962ce0f5de2721805d8 Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Thu, 27 Feb 2025 17:21:56 +0100 Subject: [PATCH 04/15] Remove env --- micromamba/tests/test_menuinst.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/micromamba/tests/test_menuinst.py b/micromamba/tests/test_menuinst.py index c27016e473..6278d68f39 100644 --- a/micromamba/tests/test_menuinst.py +++ b/micromamba/tests/test_menuinst.py @@ -109,7 +109,7 @@ def test_spyder_shortcut(self): print("menuinst.win32.dirs_src: ", menuinst.win32.dirs_src) d = menuinst.win32.dirs_src["user"]["start"][0] print("ls: ", os.listdir(d)) - distribution_name = os.getenv("DISTRIBUTION_NAME") - spyder_path = os.path.join(d, f"{distribution_name} spyder") + # distribution_name = os.getenv("DISTRIBUTION_NAME") + spyder_path = os.path.join(d, "spyder") print("ls spyder path: ", os.listdir(spyder_path)) assert False From 2539b7c44726e6be84a3c1ea7d3a9cae9e6be400 Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Fri, 28 Feb 2025 10:53:23 +0100 Subject: [PATCH 05/15] List all paths --- micromamba/tests/test_menuinst.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/micromamba/tests/test_menuinst.py b/micromamba/tests/test_menuinst.py index 6278d68f39..0dff5339c4 100644 --- a/micromamba/tests/test_menuinst.py +++ b/micromamba/tests/test_menuinst.py @@ -108,8 +108,12 @@ def test_spyder_shortcut(self): create("python=3.12", "spyder=6.0.3", "-n", env_name, no_dry_run=True) print("menuinst.win32.dirs_src: ", menuinst.win32.dirs_src) d = menuinst.win32.dirs_src["user"]["start"][0] - print("ls: ", os.listdir(d)) + list_start_dirs = os.listdir(d) + print("ls: ", list_start_dirs) # distribution_name = os.getenv("DISTRIBUTION_NAME") - spyder_path = os.path.join(d, "spyder") - print("ls spyder path: ", os.listdir(spyder_path)) + for el in list_start_dirs: + el_path = os.path.join(d, el) + print("ls ", el_path, ": ", os.listdir(el_path)) + # spyder_path = os.path.join(d, "spyder") + # print("ls spyder path: ", os.listdir(spyder_path)) assert False From c8767b55e65c96d03397260ed292385d157d7f03 Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Fri, 28 Feb 2025 11:03:50 +0100 Subject: [PATCH 06/15] Check if dir --- micromamba/tests/test_menuinst.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/micromamba/tests/test_menuinst.py b/micromamba/tests/test_menuinst.py index 0dff5339c4..bc3aa14972 100644 --- a/micromamba/tests/test_menuinst.py +++ b/micromamba/tests/test_menuinst.py @@ -112,8 +112,9 @@ def test_spyder_shortcut(self): print("ls: ", list_start_dirs) # distribution_name = os.getenv("DISTRIBUTION_NAME") for el in list_start_dirs: - el_path = os.path.join(d, el) - print("ls ", el_path, ": ", os.listdir(el_path)) + if os.path.isdir(el): + el_path = os.path.join(d, el) + print("ls ", el_path, ": ", os.listdir(el_path)) # spyder_path = os.path.join(d, "spyder") # print("ls spyder path: ", os.listdir(spyder_path)) assert False From eb2836702eb3f76469e3c4baa68fc92a5a959701 Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Fri, 28 Feb 2025 11:16:52 +0100 Subject: [PATCH 07/15] Change conditions --- micromamba/tests/test_menuinst.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/micromamba/tests/test_menuinst.py b/micromamba/tests/test_menuinst.py index bc3aa14972..d956096684 100644 --- a/micromamba/tests/test_menuinst.py +++ b/micromamba/tests/test_menuinst.py @@ -112,8 +112,8 @@ def test_spyder_shortcut(self): print("ls: ", list_start_dirs) # distribution_name = os.getenv("DISTRIBUTION_NAME") for el in list_start_dirs: - if os.path.isdir(el): - el_path = os.path.join(d, el) + el_path = os.path.join(d, el) + if os.path.isdir(el_path): print("ls ", el_path, ": ", os.listdir(el_path)) # spyder_path = os.path.join(d, "spyder") # print("ls spyder path: ", os.listdir(spyder_path)) From bcc80881992c9f94a2cc1a460cb46a412621771f Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Fri, 28 Feb 2025 11:39:11 +0100 Subject: [PATCH 08/15] Add logs --- libmamba/src/core/menuinst.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libmamba/src/core/menuinst.cpp b/libmamba/src/core/menuinst.cpp index 162669933e..f8aaa24b9b 100644 --- a/libmamba/src/core/menuinst.cpp +++ b/libmamba/src/core/menuinst.cpp @@ -4,6 +4,7 @@ // // The full license is in the file LICENSE, distributed with this software. +#include #include #include "mamba/util/path_manip.hpp" @@ -260,6 +261,7 @@ namespace mamba [[maybe_unused]] bool remove ) { + std::cout << "IN create_remove_shortcut_impl" << std::endl; std::string json_content = mamba::read_contents(json_file); replace_variables(ctx, json_content, transaction_context); auto j = nlohmann::json::parse(json_content); @@ -388,6 +390,7 @@ namespace mamba fs::u8path iconpath = item.value("icon", ""); if (remove == false) { + std::cout << "false case" << std::endl; std::string argstring; std::string lscript = util::to_lower(script.string()); @@ -429,6 +432,7 @@ namespace mamba } mamba::win::create_shortcut(script, full_name, dst, argstring, workdir, iconpath, 0); + std::cout << "END false case" << std::endl; } else { From cedd6bd86a0a510fa5028c016b4072ca5482d2f8 Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Fri, 28 Feb 2025 14:30:16 +0100 Subject: [PATCH 09/15] Add more logs --- libmamba/src/core/link.cpp | 4 ++++ micromamba/tests/test_menuinst.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libmamba/src/core/link.cpp b/libmamba/src/core/link.cpp index b036c31e13..7512034336 100644 --- a/libmamba/src/core/link.cpp +++ b/libmamba/src/core/link.cpp @@ -848,6 +848,7 @@ namespace mamba bool LinkPackage::execute() { + std::cout << "IN LinkPackage::execute()" << std::endl; const auto& context = m_context->context(); nlohmann::json index_json, out_json; @@ -1074,13 +1075,16 @@ namespace mamba } // Create all start menu shortcuts if prefix name doesn't start with underscore + std::cout << "Creating all start menu shortcuts" << std::endl; if (util::on_win && context.shortcuts && m_context->target_prefix.filename().string()[0] != '_') { for (auto& path : paths_data) { + std::cout << "path.path is: " << path.path << std::endl; if (std::regex_match(path.path, MENU_PATH_REGEX)) { + std::cout << "yes matching regex " << std::endl; create_menu_from_json(context, m_context->target_prefix / path.path, m_context); } } diff --git a/micromamba/tests/test_menuinst.py b/micromamba/tests/test_menuinst.py index d956096684..f0e62675d0 100644 --- a/micromamba/tests/test_menuinst.py +++ b/micromamba/tests/test_menuinst.py @@ -105,7 +105,7 @@ def test_shortcut_weird_env(self): ) def test_spyder_shortcut(self): env_name = random_string() - create("python=3.12", "spyder=6.0.3", "-n", env_name, no_dry_run=True) + create("python=3.12", "spyder=6.0.3", "-n", env_name, "-v", no_dry_run=True) print("menuinst.win32.dirs_src: ", menuinst.win32.dirs_src) d = menuinst.win32.dirs_src["user"]["start"][0] list_start_dirs = os.listdir(d) From 63d3cd49c5718beec9bafa55df3f1b56ee8820cb Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Fri, 28 Feb 2025 15:04:49 +0100 Subject: [PATCH 10/15] Logs again --- libmamba/src/core/transaction.cpp | 1 + micromamba/tests/helpers.py | 1 + 2 files changed, 2 insertions(+) diff --git a/libmamba/src/core/transaction.cpp b/libmamba/src/core/transaction.cpp index 2fb104b40b..6810371d21 100644 --- a/libmamba/src/core/transaction.cpp +++ b/libmamba/src/core/transaction.cpp @@ -391,6 +391,7 @@ namespace mamba bool MTransaction::execute(const Context& ctx, ChannelContext& channel_context, PrefixData& prefix) { + std::cout << "EXECUTING TRANSACTION " << std::endl; // JSON output // back to the top level if any action was required if (!empty()) diff --git a/micromamba/tests/helpers.py b/micromamba/tests/helpers.py index 9c0003f818..d59928e1a0 100644 --- a/micromamba/tests/helpers.py +++ b/micromamba/tests/helpers.py @@ -182,6 +182,7 @@ def create( cmd += ["--dry-run"] try: + print(f"Executing cmd: '{' '.join(cmd)}'") res = subprocess_run(*cmd, **kwargs) if "--json" in args: j = json.loads(res) From b6e2edda7a6f01475ae909ef924b107d713496cd Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Fri, 28 Feb 2025 15:36:59 +0100 Subject: [PATCH 11/15] Allowing logs --- micromamba/tests/helpers.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/micromamba/tests/helpers.py b/micromamba/tests/helpers.py index d59928e1a0..e84112e0cb 100644 --- a/micromamba/tests/helpers.py +++ b/micromamba/tests/helpers.py @@ -183,13 +183,17 @@ def create( try: print(f"Executing cmd: '{' '.join(cmd)}'") - res = subprocess_run(*cmd, **kwargs) + # res = subprocess_run(*cmd, **kwargs) + res = subprocess.run(cmd, capture_output=True, **kwargs) + print(res.stdout.decode()) + print(res.stderr.decode()) if "--json" in args: j = json.loads(res) return j if "--print-config-only" in args: return yaml.load(res, Loader=yaml.FullLoader) - return res.decode() + # return res.decode() + return res.stdout.decode() except subprocess.CalledProcessError as e: print(f"Error when executing '{' '.join(cmd)}'") raise (e) From 2212690ed8018b98ea965f9171cd512dc082983b Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Fri, 28 Feb 2025 16:21:47 +0100 Subject: [PATCH 12/15] Add logs... --- libmamba/src/core/link.cpp | 8 ++++---- libmamba/src/core/menuinst.cpp | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libmamba/src/core/link.cpp b/libmamba/src/core/link.cpp index 7512034336..caca7cf256 100644 --- a/libmamba/src/core/link.cpp +++ b/libmamba/src/core/link.cpp @@ -848,7 +848,7 @@ namespace mamba bool LinkPackage::execute() { - std::cout << "IN LinkPackage::execute()" << std::endl; + // std::cout << "IN LinkPackage::execute()" << std::endl; const auto& context = m_context->context(); nlohmann::json index_json, out_json; @@ -1075,16 +1075,16 @@ namespace mamba } // Create all start menu shortcuts if prefix name doesn't start with underscore - std::cout << "Creating all start menu shortcuts" << std::endl; + // std::cout << "Creating all start menu shortcuts" << std::endl; if (util::on_win && context.shortcuts && m_context->target_prefix.filename().string()[0] != '_') { for (auto& path : paths_data) { - std::cout << "path.path is: " << path.path << std::endl; + // std::cout << "path.path is: " << path.path << std::endl; if (std::regex_match(path.path, MENU_PATH_REGEX)) { - std::cout << "yes matching regex " << std::endl; + std::cout << "yes matching regex: " << path.path << std::endl; create_menu_from_json(context, m_context->target_prefix / path.path, m_context); } } diff --git a/libmamba/src/core/menuinst.cpp b/libmamba/src/core/menuinst.cpp index f8aaa24b9b..4394bb122f 100644 --- a/libmamba/src/core/menuinst.cpp +++ b/libmamba/src/core/menuinst.cpp @@ -277,6 +277,7 @@ namespace mamba } #ifdef _WIN32 + std::cout << "#ifdef _WIN32 CASE" << std::endl; // { // "menu_name": "Miniforge${PY_VER}", @@ -335,8 +336,10 @@ namespace mamba } }; + std::cout << "Before for loop " << std::endl; for (auto& item : j["menu_items"]) { + std::cout << "IN for loop " << std::endl; std::string name = item["name"]; std::string full_name = util::concat(name, name_suffix); From ca31d4f551a7b4b04080f7b987940e00dbefc9ab Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Fri, 28 Feb 2025 16:54:39 +0100 Subject: [PATCH 13/15] Remove -v --- micromamba/tests/test_menuinst.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/micromamba/tests/test_menuinst.py b/micromamba/tests/test_menuinst.py index f0e62675d0..d956096684 100644 --- a/micromamba/tests/test_menuinst.py +++ b/micromamba/tests/test_menuinst.py @@ -105,7 +105,7 @@ def test_shortcut_weird_env(self): ) def test_spyder_shortcut(self): env_name = random_string() - create("python=3.12", "spyder=6.0.3", "-n", env_name, "-v", no_dry_run=True) + create("python=3.12", "spyder=6.0.3", "-n", env_name, no_dry_run=True) print("menuinst.win32.dirs_src: ", menuinst.win32.dirs_src) d = menuinst.win32.dirs_src["user"]["start"][0] list_start_dirs = os.listdir(d) From 98f3156e992bac072f8f6fc13c4e7a4e17114b0b Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Fri, 28 Feb 2025 17:09:33 +0100 Subject: [PATCH 14/15] more and more --- libmamba/src/core/menuinst.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libmamba/src/core/menuinst.cpp b/libmamba/src/core/menuinst.cpp index 4394bb122f..f50e95d686 100644 --- a/libmamba/src/core/menuinst.cpp +++ b/libmamba/src/core/menuinst.cpp @@ -345,6 +345,10 @@ namespace mamba std::vector arguments; fs::u8path script; + for (auto& el : item.items()) + { + std::cout << "Key: " << el.key() << ", Value: " << el.value() << std::endl; + } if (item.contains("pywscript")) { script = root_pyw; @@ -391,6 +395,7 @@ namespace mamba fs::u8path dst = target_dir / (full_name + ".lnk"); fs::u8path workdir = item.value("workdir", ""); fs::u8path iconpath = item.value("icon", ""); + std::cout << "Before checking false case" << std::endl; if (remove == false) { std::cout << "false case" << std::endl; From 18e5ffa333d45951c2b24a4425f3acfb447eb957 Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Fri, 28 Feb 2025 17:34:45 +0100 Subject: [PATCH 15/15] more --- libmamba/src/core/menuinst.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libmamba/src/core/menuinst.cpp b/libmamba/src/core/menuinst.cpp index f50e95d686..434f0ccdb9 100644 --- a/libmamba/src/core/menuinst.cpp +++ b/libmamba/src/core/menuinst.cpp @@ -341,7 +341,9 @@ namespace mamba { std::cout << "IN for loop " << std::endl; std::string name = item["name"]; + std::cout << "Item name: " << name << std::endl; std::string full_name = util::concat(name, name_suffix); + std::cout << "full name: " << full_name << std::endl; std::vector arguments; fs::u8path script; @@ -349,6 +351,7 @@ namespace mamba { std::cout << "Key: " << el.key() << ", Value: " << el.value() << std::endl; } + std::cout << "BEFORE checking content " << std::endl; if (item.contains("pywscript")) { script = root_pyw;