Skip to content

Commit 4eacf4c

Browse files
committed
fix: Show pip and uv output by default
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
1 parent 6c1383a commit 4eacf4c

File tree

2 files changed

+81
-5
lines changed

2 files changed

+81
-5
lines changed

libmamba/src/api/utils.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ namespace mamba
2929
const std::string& name,
3030
const std::string& target_prefix,
3131
const fs::u8path& spec_file,
32-
pip::Update update
32+
pip::Update update,
33+
const Context::OutputParams& output_params
3334
)
3435
{
3536
const auto get_python_path = [&]
@@ -51,7 +52,13 @@ namespace mamba
5152
}();
5253

5354
cmd.insert(cmd.end(), { "pip", "install" });
54-
command_args cmd_extension = { "-r", spec_file, "--quiet" };
55+
command_args cmd_extension = { "-r", spec_file };
56+
57+
// Only use --quiet when --json or --quiet is used to avoid interfering with output
58+
if (output_params.json || output_params.quiet)
59+
{
60+
cmd_extension.push_back("--quiet");
61+
}
5562

5663
if (name != "uv")
5764
{
@@ -165,7 +172,8 @@ namespace mamba
165172
pkg_mgr,
166173
ctx.prefix_params.target_prefix.string(),
167174
specs.path(),
168-
update
175+
update,
176+
ctx.output_params
169177
);
170178
if (maybe_command)
171179
{

micromamba/tests/test_create.py

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,8 +1979,76 @@ def test_create_python_site_packages_path(tmp_home, tmp_root_prefix):
19791979
@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
19801980
@pytest.mark.parametrize("env_file", env_files)
19811981
def test_requires_pip_install(tmp_home, tmp_root_prefix, env_file):
1982-
cmd = ["-p", "myenv", "-f", env_file]
1983-
helpers.create(*cmd)
1982+
umamba = helpers.get_umamba()
1983+
1984+
# Test 1: By default, pip output should be visible (no --quiet flag)
1985+
env_prefix_1 = tmp_root_prefix / "envs" / "myenv1"
1986+
cmd1 = [
1987+
umamba,
1988+
"create",
1989+
"-p",
1990+
str(env_prefix_1),
1991+
"-f",
1992+
str(env_file),
1993+
"-y",
1994+
"--no-rc",
1995+
] + helpers.channel
1996+
result1 = subprocess.run(cmd1, capture_output=True, text=True, check=True)
1997+
# pip typically outputs to stderr, so check for common pip output patterns
1998+
# Look for pip installation messages like "Collecting", "Installing", "Successfully installed"
1999+
pip_output_present = (
2000+
"Collecting" in result1.stderr
2001+
or "Installing" in result1.stderr
2002+
or "Successfully installed" in result1.stderr
2003+
or "Downloading" in result1.stderr
2004+
)
2005+
assert pip_output_present, "pip output should be visible by default (no --quiet flag)"
2006+
2007+
# Test 2: With --json, pip output should be suppressed (--quiet flag used)
2008+
env_prefix_2 = tmp_root_prefix / "envs" / "myenv2"
2009+
cmd2 = [
2010+
umamba,
2011+
"create",
2012+
"-p",
2013+
str(env_prefix_2),
2014+
"-f",
2015+
str(env_file),
2016+
"-y",
2017+
"--no-rc",
2018+
"--json",
2019+
] + helpers.channel
2020+
result2 = subprocess.run(cmd2, capture_output=True, text=True, check=True)
2021+
# With --quiet, pip should not output installation messages
2022+
pip_output_suppressed_json = not (
2023+
"Collecting" in result2.stderr
2024+
or "Installing" in result2.stderr
2025+
or "Successfully installed" in result2.stderr
2026+
or "Downloading" in result2.stderr
2027+
)
2028+
assert pip_output_suppressed_json, "pip output should be suppressed when --json is used"
2029+
2030+
# Test 3: With --quiet, pip output should be suppressed (--quiet flag used)
2031+
env_prefix_3 = tmp_root_prefix / "envs" / "myenv3"
2032+
cmd3 = [
2033+
umamba,
2034+
"create",
2035+
"-p",
2036+
str(env_prefix_3),
2037+
"-f",
2038+
str(env_file),
2039+
"-y",
2040+
"--no-rc",
2041+
"--quiet",
2042+
] + helpers.channel
2043+
result3 = subprocess.run(cmd3, capture_output=True, text=True, check=True)
2044+
# With --quiet, pip should not output installation messages
2045+
pip_output_suppressed_quiet = not (
2046+
"Collecting" in result3.stderr
2047+
or "Installing" in result3.stderr
2048+
or "Successfully installed" in result3.stderr
2049+
or "Downloading" in result3.stderr
2050+
)
2051+
assert pip_output_suppressed_quiet, "pip output should be suppressed when --quiet is used"
19842052

19852053

19862054
@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)

0 commit comments

Comments
 (0)