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

pip debug: Add versions of vendored libraries to output #7887

Merged
merged 5 commits into from
Apr 13, 2020

Conversation

NoahGorny
Copy link
Contributor

Resolves #7794

@pradyunsg you can take a look :)

@NoahGorny NoahGorny force-pushed the pip-debug-print-vendored-versions branch from 8376078 to 3ffbe69 Compare March 23, 2020 17:55
@xavfernandez
Copy link
Member

@NoahGorny thanks for taking a look.

The goal is however not to print the values of vendor.txt but in the case of an unbundled pip to quickly find faulty versions (so including vendor.txt to compare the expected version vs installed version is still useful).

I think you should start by printing

DEBUNDLED = False

And something like:

+    print('Pip dependencies versions')
+    for module_name in (
+        "appdirs",
+        "cachecontrol",
+        "colorama",
+        "contextlib2",
+        "distlib",
+        "distro",
+        "html5lib",
+        "six",
+        "packaging",
+        "pep517",
+        "pkg_resources",
+        "progress",
+        "pytoml",
+        "retrying",
+        "requests",
+        "urllib3",
+    ):
+        __import__('pip._vendor.{}'.format(module_name), globals(), locals(), level=0)
+        module = getattr(_vendor, module_name)
+        print('   ', module_name, getattr(module, '__version__', 'undefined'))

(and devise a way to deal with libraries that do not include their versions)

Is it more clear ?

@NoahGorny
Copy link
Contributor Author

I see, I'll work on it in the following days :)
Not sure what to do with unknown versions, but sure

@NoahGorny NoahGorny force-pushed the pip-debug-print-vendored-versions branch from 3ffbe69 to 40b0718 Compare March 24, 2020 00:21
@NoahGorny
Copy link
Contributor Author

NoahGorny commented Mar 24, 2020

@xavfernandez I make some work, tell me what you think

  • still need to add new tests for all cases (version mismatch, no version, etc...)
  • currently if there is no version the command just cries (Unable to import actual module version, using vendor.txt specified version), not sure this is what you expect me to do in this situation

anyway, thanks alot for the feedback 😄

Copy link
Member

@xavfernandez xavfernandez left a comment

Choose a reason for hiding this comment

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

not sure this is what you expect me to do in this situation

For debundled modules without __version__ attribute, I'd be tempted to check their module.__file__ attribute to find there location and their metadata:
Something like:

>>> pip._vendor.retrying.__file__
'/usr/lib/python3.8/site-packages/retrying.py'
>>> pkg_resources.WorkingSet([os.path.dirname(pip._vendor.retrying.__file__)]).find(pkg_resources.Requirement('retrying')).version
'1.3.3'

src/pip/_internal/commands/debug.py Outdated Show resolved Hide resolved
src/pip/_internal/commands/debug.py Outdated Show resolved Hide resolved
@NoahGorny NoahGorny force-pushed the pip-debug-print-vendored-versions branch from 40b0718 to ae0a446 Compare March 25, 2020 15:48
@NoahGorny
Copy link
Contributor Author

what do think about this now @xavfernandez? I also added a simple test

@NoahGorny
Copy link
Contributor Author

seems like os.path.dirname(getattr(module, '__file__')) is failing windows tests for some reason
I have no idea why though @xavfernandez

src/pip/_internal/commands/debug.py Outdated Show resolved Hide resolved
src/pip/_internal/commands/debug.py Outdated Show resolved Hide resolved
@NoahGorny NoahGorny force-pushed the pip-debug-print-vendored-versions branch from ae0a446 to 986e1bd Compare March 28, 2020 12:33
@pradyunsg pradyunsg changed the title Pip debug print vendored versions pip debug: Add versions of vendored libraries to output Apr 1, 2020
@NoahGorny
Copy link
Contributor Author

@xavfernandez any updates? I think its pretty ready

Copy link
Member

@xavfernandez xavfernandez left a comment

Choose a reason for hiding this comment

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

This is not far from ready and this would be nice to have in 20.1 :) cc @pradyunsg

src/pip/_internal/commands/debug.py Outdated Show resolved Hide resolved
src/pip/_internal/commands/debug.py Outdated Show resolved Hide resolved
src/pip/_internal/commands/debug.py Outdated Show resolved Hide resolved
@NoahGorny NoahGorny force-pushed the pip-debug-print-vendored-versions branch from 986e1bd to 1246673 Compare April 8, 2020 23:48
@pradyunsg pradyunsg added this to the 20.1 milestone Apr 10, 2020
@pradyunsg pradyunsg added C: debug The debug command type: enhancement Improvements to functionality labels Apr 10, 2020
logger.info('vendored library versions:')

vendor_txt_versions = create_vendor_txt_map()
show_actual_vendor_versions(vendor_txt_versions)
Copy link
Member

Choose a reason for hiding this comment

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

A with indent_log(): would be prettier IMHO:

vendored library versions:
  appdirs==1.4.3
  CacheControl==0.12.6
 ...

vs

vendored library versions:
appdirs==1.4.3
CacheControl==0.12.6

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, updated the code to include it- nice idea!

@NoahGorny NoahGorny force-pushed the pip-debug-print-vendored-versions branch from 1246673 to e6f109b Compare April 10, 2020 19:36
Copy link
Member

@xavfernandez xavfernandez left a comment

Choose a reason for hiding this comment

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

One final nit, otherwise it looks ready 👍

src/pip/_internal/commands/debug.py Outdated Show resolved Hide resolved
@NoahGorny NoahGorny force-pushed the pip-debug-print-vendored-versions branch from e6f109b to bfd17cb Compare April 10, 2020 23:05
Copy link
Member

@xavfernandez xavfernandez left a comment

Choose a reason for hiding this comment

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

Thanks for your work @NoahGorny 👍

@NoahGorny
Copy link
Contributor Author

Happy to help 😄
Thank you so much for your valuable feedback (s)!

@pradyunsg pradyunsg merged commit 15f8a35 into pypa:master Apr 13, 2020
@pradyunsg
Copy link
Member

Thanks for the PR @NoahGorny! ^>^

@NoahGorny NoahGorny deleted the pip-debug-print-vendored-versions branch April 27, 2020 12:48
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: debug The debug command type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include vendored library versions in pip debug
3 participants