question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding pipdeptree's functionality to pip code base

See original GitHub issue

What’s the problem this feature will solve?

Hi.

I am the author and current maintainer of pipdeptree and I wanted to check if pypa org / pip’s maintainers would be open to the idea of adding pipdeptree’s functionality to pip itself.

The current use case of pipdeptree is to render a graph of dependencies, and for that it uses pip’s code (yes, import pip, I know).

The current state of pipdeptree borders on “unmaintained” because, (1) I am not finding time for open source work lately due to personal commitments and (2) python is not my primary language at work any more, so I am not up-to-date with the recent developments in the python/pip ecosystem.

The original use case of pipdeptree was to make tracking down of conflicting dependencies easy. I believe conflicting dependencies is no longer a problem on newer environments thanks to the new dependency resolver. But people seem to be still using it, either for older envs or for it’s graph output.

One problem with pipdeptree since the beginning has been it’s dependence on the internal functions of pip. So every time there’s an internal refactor in pip, a “stable” version of pipdeptree can potentially break. I was fully aware of this right from the start but the script did solve a problem for me and others at that time (2015). As the project became more popular, I (with the help of contributors) continued to keep the code up-to-date with latest pip versions, and even backward compatible with older pip versions.

Describe the solution you’d like

If pip is interested in the graph output functionality of pipdeptree, I propose the code (under MIT license) can be moved inside pip and provided as a subcommand. This will ensure that,

  1. There are no breakages due to internal refactor (considering that pipdeptree would also be “internal” to the repo)
  2. The community can maintain it in a more timely manner

As I mentioned above, pipdeptree uses import pip under the hood and the core functionality of constructing the dependency tree is decoupled from the CLI. So I believe it should be straightforward to move the code without many changes.

If this proposal gets approved, I can help with moving the code to pip in whatever way possible.

Alternative Solutions

Another option for me is to find a maintainer and transfer the ownership of the repo on github and pypi.org. However, the possibility of having to fix pipdeptree after pip releases remains.

Additional context

Something similar was proposed earlier (long ago)

Code of Conduct

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:16 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
sbidoulcommented, Aug 10, 2022

@stonebig the packaging library has everything to parse requires_dist correctly. Each item is a Requirement, then you can use requirement.marker to evaluate if it is applicable to the environment and extras.

0reactions
pfmoorecommented, Aug 15, 2022

They’re still visible as regular Python packages, with dist-info or egg-info, last I checked, so it should “just work”.

In this context, I think the problem is that any new library would need to duplicate pip’s logic for reading the “old-style” files to get the location of the project (as there’s no direct-url.json file). But as I said, that’s just a bit of extra work.

Is there anything actionable here, on pip’s end?

Nope.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dependency tree of a Python Module - GeeksforGeeks
One easy way of doing so is to use the pipdeptree utility. The pipdeptree works on the command line and shows the installed...
Read more >
Python Dependencies - Everything You Need to Know
Add, remove and update dependencies; Resolve dependency conflicts ... Pipdeptree is a tool for displaying installed Python packages in more ...
Read more >
Consider replacing pipdeptree in gemnasium-python - GitLab
The Gemnasium analyzer already detects and parses pipdeptree.json ... (so I'd have to code around that - I'd have to pip install pipdeptree...
Read more >
Better Python dependency while packaging your project
Today the most used Python package manager is pip, used to install and manage ... in every application, threats can come from anywhere...
Read more >
python - Is there a way to list pip dependencies/requirements?
setuptools>=18.5 Easily download, build, install, upgrade, and uninstall Python packages ├── simplegeneric>0.8 Simple generic functions (similar to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found