Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress "not on PATH" warning when --prefix is given #9931

Merged
merged 1 commit into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/9931.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Suppress "not on PATH" warning when ``--prefix`` is given.
4 changes: 2 additions & 2 deletions src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ def run(self, options, args):
conflicts = self._determine_conflicts(to_install)

# Don't warn about script install locations if
# --target has been specified
# --target or --prefix has been specified
warn_script_location = options.warn_script_location
if options.target_dir:
if options.target_dir or options.prefix_path:
warn_script_location = False

installed = install_given_reqs(
Expand Down
8 changes: 6 additions & 2 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,8 @@ def test_install_nonlocal_compatible_wheel_path(
assert result.returncode == ERROR


def test_install_with_target_and_scripts_no_warning(script, with_wheel):
@pytest.mark.parametrize('opt', ('--target', '--prefix'))
def test_install_with_target_or_prefix_and_scripts_no_warning(opt, script, with_wheel):
"""
Test that installing with --target does not trigger the "script not
in PATH" warning (issue #5201)
Expand All @@ -981,7 +982,7 @@ def test_install_with_target_and_scripts_no_warning(script, with_wheel):
pkga_path.joinpath("pkga.py").write_text(textwrap.dedent("""
def main(): pass
"""))
result = script.pip('install', '--target', target_dir, pkga_path)
result = script.pip('install', opt, target_dir, pkga_path)
# This assertion isn't actually needed, if we get the script warning
# the script.pip() call will fail with "stderr not expected". But we
# leave the assertion to make the intention of the code clearer.
Expand Down Expand Up @@ -1666,6 +1667,9 @@ def test_install_from_test_pypi_with_ext_url_dep_is_blocked(script, index):
assert error_cause in res.stderr, str(res)


@pytest.mark.xfail(
reason="No longer possible to trigger the warning with either --prefix or --target"
)
def test_installing_scripts_outside_path_prints_warning(script):
pradyunsg marked this conversation as resolved.
Show resolved Hide resolved
result = script.pip_install_local(
"--prefix", script.scratch_path, "script_wheel1"
Expand Down