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

feat(): Add logs for pip environment when installing #8266

Merged
merged 3 commits into from
Jul 10, 2020
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/3166.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Log debugging information about pip, in ``pip install --verbose``.
2 changes: 2 additions & 0 deletions src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from pip._internal.utils.misc import (
ensure_dir,
get_installed_version,
get_pip_version,
protect_pip_from_modification_on_windows,
write_output,
)
Expand Down Expand Up @@ -239,6 +240,7 @@ def run(self, options, args):

install_options = options.install_options or []

logger.debug("Using {}".format(get_pip_version()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a test can be added to verify that the logger contains this string when install in called with -v, something along the lines of tests.lib.test_lib:https://github.com/pypa/pip/blob/master/tests/lib/test_lib.py#L40, maybe a smaller version of it.

options.use_user_site = decide_user_install(
options.use_user_site,
prefix_path=options.prefix_path,
Expand Down
7 changes: 7 additions & 0 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -1902,3 +1902,10 @@ def test_install_verify_package_name_normalization(script, package_name):
result = script.pip('install', package_name)
assert 'Requirement already satisfied: {}'.format(
package_name) in result.stdout


def test_install_logs_pip_version_in_debug(script, shared_data):
fake_package = shared_data.packages / 'simple-2.0.tar.gz'
result = script.pip('install', '-v', fake_package)
pattern = "Using pip .* from .*"
assert_re_match(pattern, result.stdout)