diff --git a/libmamba/src/core/prefix_data.cpp b/libmamba/src/core/prefix_data.cpp index 64cb1aa2d..89a917265 100644 --- a/libmamba/src/core/prefix_data.cpp +++ b/libmamba/src/core/prefix_data.cpp @@ -303,9 +303,8 @@ namespace mamba { for (const auto& package : j["installed"]) { - // Get the package metadata, if requested and installed with `pip` - if (package.contains("requested") && package.contains("installer") - && package["requested"] == true && package["installer"] == "pip") + // Get the package metadata, if installed with `pip` + if (package.contains("installer") && package["installer"] == "pip") { if (package.contains("metadata")) { diff --git a/micromamba/tests/test_env.py b/micromamba/tests/test_env.py index 42bee1ac9..9c7ca2a3a 100644 --- a/micromamba/tests/test_env.py +++ b/micromamba/tests/test_env.py @@ -520,4 +520,8 @@ def test_env_export_with_pip(tmp_path, json_flag): pip_section = next( dep for dep in ret["dependencies"] if isinstance(dep, dict) and ["pip"] == [*dep] ) - assert pip_section["pip"] == ["requests==2.32.3"] + pip_section_vals = pip_section["pip"] + + # Check that `requests` and `urllib3` (pulled dependency) are exported + assert "requests==2.32.3" in pip_section_vals + assert any(pkg.startswith("urllib3==") for pkg in pip_section_vals) diff --git a/micromamba/tests/test_list.py b/micromamba/tests/test_list.py index 8accb86b6..546dc372e 100644 --- a/micromamba/tests/test_list.py +++ b/micromamba/tests/test_list.py @@ -160,7 +160,7 @@ channels: dependencies: - pip - pip: - - numpy==1.26.4 + - pandas==2.2.3 """ @@ -178,9 +178,18 @@ def test_list_with_pip(tmp_home, tmp_root_prefix, tmp_path, no_pip_flag): res = helpers.umamba_list("-n", env_name, "--json", no_pip_flag) if no_pip_flag == "": + assert any( + package["name"] == "pandas" + and package["version"] == "2.2.3" + and package["base_url"] == "https://pypi.org/" + and package["build_string"] == "pypi_0" + and package["channel"] == "pypi" + and package["platform"] == sys.platform + "-" + platform.machine() + for package in res + ) + # Check that dependencies are listed assert any( package["name"] == "numpy" - and package["version"] == "1.26.4" and package["base_url"] == "https://pypi.org/" and package["build_string"] == "pypi_0" and package["channel"] == "pypi" @@ -188,7 +197,9 @@ def test_list_with_pip(tmp_home, tmp_root_prefix, tmp_path, no_pip_flag): for package in res ) else: # --no-pip - # Check that numpy installed with pip is not listed + # Check that pandas installed with pip is not listed + assert all(package["name"] != "pandas" for package in res) + # Check that dependencies are not there either assert all(package["name"] != "numpy" for package in res)