pypa / pip

The Python package installer
https://pip.pypa.io/
MIT License
9.52k stars 3.03k forks source link

Change pip --force-reinstall behaviour #8238

Open ei8fdb opened 4 years ago

ei8fdb commented 4 years ago

What is this?

This is a proposal to make pip how pip --force-reinstall works.

The difficulty here is this is current behaviour, and this would modify how pip works.

What is the problem?

Currently, when pip install [package-name] --force-reinstall is executed, instead of reinstalling the package at the version previously installed, pip installs the package at the newest version available.

i.e. pip install [package name] --force-reinstall acts as pip [package name] --upgrade

Using the Nielsen Norman good usability heuristics, this behaviour goes against #2: Match between system and the real world. This behaviour would be confusing to a new pip user.

What does pip user guide say?

About --force-reinstall the pip user guide says:

Reinstall all packages even if they are already up-to-date.

Replicate

See below: testbox@testbox:~/code/reinstall-test$ pip install click==5.0.0 Collecting click==5.0.0 Downloading https://files.pythonhosted.org/packages/af/55/056901e9f504a7cda9e955592360ce2c516b2b92f3da9318ba074be5d280/click-5.0-py2.py3-none-any.whl (65kB) 100% |████████████████████████████████| 71kB 441kB/s Installing collected packages: click Successfully installed click-5.0 osboxes@osboxes:~/code/reinstall-test$ pip install --force-reinstall click Collecting click Downloading https://files.pythonhosted.org/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl (82kB) 100% |████████████████████████████████| 92kB 303kB/s Installing collected packages: click Found existing installation: click 5.0 Uninstalling click-5.0: Successfully uninstalled click-5.0 Successfully installed click-7.1.2

Possible solutions

Best solution

When the user issues:

pip install [package name] --force-reinstall

they are prompted: You had [package name] version [a.b.c] installed. Would you like to update to version [a.b.f]? Y/N

This solution would:

  1. make --force-reinstall behave as expected
  2. maintain previous behaviour if the user requested it

Minimum solution

When a user issues:

pip install [package name] --force-reinstall

[package name] is reinstalled at the version it was previously installed at.

Other solutions

Next steps

Carry out a survey of pip users to get their understanding of what pip --force-reinstall does and should do, and what their opinions would be if the change to behaviour was made.

Based on a Zulip thread about about confusing current pip behaviour, we should audit the current pip commands to see they match the executed commands.

https://www.notion.so/simplysecure/Improve-the-CLI-structure-8238-d13ed2b1d0b64449b532cddd6df90a0e

Additional context**

Link to the discussion in Zulip.

nlhkabu commented 4 years ago

Adding this to the functionality research epic.

brainwane commented 4 years ago

As of right now, Pradyun, Georgia and I think that this doesn't need to happen in time for 20.3. But @ei8fdb and @nlhkabu please speak up if you think there is a strong chance that #8516 will lead us to need to change functionality by pip 20.3 in October, and we'll reprioritize.