pip icon indicating copy to clipboard operation
pip copied to clipboard

Command - pip reset

Open fakabbir opened this issue 1 year ago • 6 comments

What's the problem this feature will solve?

Problem: Once packages are installed, there is not way to come to the starting point in base environement except creating a new virtual env

Solution: pip reset command would uninstall all the libraries which are not installed as a base package.

Describe the solution you'd like

A pip reset commnand

Alternative Solutions

pip uninstall command can be more powerfull

Additional context

Requires creating venv in case the base python has a lots of packages and is not maintained well

Code of Conduct

fakabbir avatar May 11 '24 06:05 fakabbir

Deleting and recreating a virtual environment is, by design, a fast operation. The proposed pip subcommand would merely be a slower way of doing the same thing. Thanks for the suggestion but I don’t think it’s something we would want to spend our limited bandwidth on.

pfmoore avatar May 11 '24 08:05 pfmoore

https://github.com/pradyunsg/dotfiles/blob/main/src/python/.zsh/8-v.symlink.zsh#L111

This is something that could be done externally to pip today, like I have in the link above.

@pfmoore while I agree with your assessment here, I will say that this issue represents a desire for a lower-effort way of doing things. Specifically, that recreating a virtual environment requires knowing/typing the path or some substitute and it's often nice to not have to think about details like that.

pradyunsg avatar May 12 '24 11:05 pradyunsg

Its more of a way to revert the base environment, which is generally used by default

fakabbir avatar May 12 '24 11:05 fakabbir

When you say the “base environment”, do you mean the system Python, i.e. not a virtual environment? If so, then generally the advice is not to install packages direct into the base environment - in many cases, you should be managing that environment using a system package manager rather than pip anyway.

But if you do need to do that, a script such as the one @pradyunsg linked to, is probably the best way.

pfmoore avatar May 12 '24 11:05 pfmoore

When you say the “base environment”, do you mean the system Python, i.e. not a virtual environment? If so, then generally the advice is not to install packages direct into the base environment - in many cases, you should be managing that environment using a system package manager rather than pip anyway.

But if you do need to do that, a script such as the one @pradyunsg linked to, is probably the best way.

Yes, the script helps.

fakabbir avatar May 12 '24 12:05 fakabbir

I think one thing to note is deleting all (pip-)installed packages does not equal to blanking the environment, especially if the environment is shared (not isolated to one specific use case). If the environment is a virtual environment, a script wiping sys.prefix and recreating a virutal environment in-place is better in every way. If the goal is explicitly uninstalling all pip-installed packages, pip reset mis-describes what is actually done, and something like pip uninstall :all: would be better.

uranusjr avatar May 14 '24 07:05 uranusjr