-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Remove a package with its dependencies that are not required by other packages #5823
Comments
One thing that might make implementing this functionality problematic: there's no record of the extras used when a package was installed (which is also a problem with |
Another piece missing is what packages are “top-level”. Say I install Django, and then “wrongly” install django-debug-toolbar, I wouldn’t want the hypothetical |
This is something that we might want to do moving forward but we would need to first fix the issues with installed package metadata that @benoit-pierre and @uranusjr point out. IMO The best path forward here would be to resolve those issues and then proceed with the discussion on this feature. |
I'm not a professional or a well experienced developer, But I guess each package has a requirements.txt file or something like that, is that right? If so, can't we just use them to lookup the dependencies and check them against other installed packages? |
A Metadata file, can has a key like |
I read through the relevent PEPs and realised that, although pip does not implement it, there is already a mechanism to record whether a package is “user-installed” (and should not be removed even if no-one depends on it)—namely, the
|
Yep. I can confirm that I had the same findings earlier. I'd started a discussion about storing the extras on distutils-sig a while back but haven't had the time to follow through on it. |
To reiterate, IMO until we store the missing bits information on the filesystem or in an internal database, this feature can't be meaningfully discussed. |
Amazing how this languishes for 2 years because of bikeshedding. Despite protestations otherwise, it can indeed be meaningfully "discussed" and easily done. This issue is not "out of scope," nor the job of another tool. pip has all the information to uninstall dependencies. This issue is about uninstalling leaves created by an |
I see something related to this is already implemented: ▶ pip show flask
Name: Flask
Version: 1.1.2
Summary: A simple framework for building complex web applications.
Home-page: https://palletsprojects.com/p/flask/
Author: Armin Ronacher
Author-email: [email protected]
License: BSD-3-Clause
Location: /usr/lib/python3.8/site-packages
Requires: Werkzeug, Jinja2, itsdangerous, click
Required-by: Flask-WTF, Flask-SQLAlchemy, Flask-Security-Too, Flask-Script, Flask-Principal, Flask-Paranoid, Flask-Migrate, Flask-Mail, Flask-Login, Flask-Gravatar, Flask-Compress, Flask-BabelEx Can't we use this "Requires" and "Required-by" to implement "Dependency Removal"? |
@DarkSuniuM I was thinking in your example if you install only I think the easiest solution for this is having a global pyproject file so you can keep track of which libraries you installed/added in the system so when you uninstall something pip should resolve which dependencies should keep and delete the orphans |
In the |
If anyone genuinely feels that this is a relatively easy problem to solve, and that the pip developers are simply blocking it over details, then I suggest they provide a PR that implements the solution. If it is indeed as simple as people are suggesting, then having a PR that makes it obvious that this is the case would be a very compelling argument for moving forward. On the other hand, if (as I personally believe) there are complexities that make this harder than it looks at first glance, then trying to write a PR would help whoever does so to better understand why this problem is hard. Simply claiming that someone else "should" be able to implement this without much effort, on the other hand, isn't particularly productive. The current discussion about ways of storing the required information is reasonable - but please realise that any new metadata that needs to be stored must be agreed as a standard - pip is not the only tool that uses or creates this data, and the standards are how we ensure that tools can work together. By all means design a proposal before proposing a standard, but pip won't accept a PR that changes metadata unless it's backed by an approved standard. |
Hey, was curious about this, so my understanding is that simply copying https://github.com/enjoysoftware/pip3-autoremove in as a function under a flag is considered out of scope for |
At first glance pip-autoremove is incorrect for anything but trivial cases |
I have a slightly different idea for how we can cover this usecase; where users want to ensure their environment matches a certain set of requirements and nothing else. There's a standard lock file format being discussed at https://discuss.python.org/t/11736), which enables a different avenue -- synchronising the environment with the lock file's contents, with the ability to generate that lock file from a requirements file. |
Hello @RonnyPfannschmidt. Can you please explain in what circumstances pip-autoremove is broken, other than issues like the missing extras information and other issues outside of its control? |
It lacks the concept of "user-installed" packages, separate from dependencies. Take this scenario, for example:
That's all fine. But in this scenario:
That last step is wrong. RedHat/Fedora's
This avoids yanking out every package the user installed explicitly, which also happens to be a dependency of some package that's being removed. ( |
What's the problem this feature will solve?
Uninstall a package with its dependencies that are not required by any other package
Describe the solution you'd like
A flag like
--remove-dependencies
that user can use withpip uninstall <package_name>
For example, I wrongly installed a package (Virtualenv or SystemGlobal) and then I realized I don't need that, Only footage I can see is the log of installation that says which packages are installed after I ran
pip install jupyter
, There is no way to remove the package and its dependencies!The text was updated successfully, but these errors were encountered: