Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do (s)witch, (i)gnore, (w)ipe, (b)ackup options mean when installing a package from repository using pip?

Tags:

git

python

pip

When installing a package using pip, I get the following message:

Obtaining some-package from git+git://github.com/some-user/some-package.git@commit-hash#egg=some_package-dev (from -r requirements.txt  (line 3))   git clone in /Users/me/Development/some-env/src/some-package exists with  URL https://github.com/some-user/some-package.git   The plan is to install the git repository git://github.com/some-user/some-package.git What to do?  (s)witch, (i)gnore, (w)ipe, (b)ackup 

I see that this particular case is probably caused by a change of protocol in URL (new requirement uses git://, while the one already installed uses https://).

However, I wonder what exactly happens if I choose either of the choices (switch, ignore, wipe, backup). I'm unable to find an explanation in pip documentation.

like image 744
Anton Strogonoff Avatar asked Oct 09 '13 15:10

Anton Strogonoff


People also ask

What is pip install option?

pip is a standard package manager used to install and maintain packages for Python. The Python standard library comes with a collection of built-in functions and built-in packages.

What is the flag for pip install?

The --user flag to pip install tells Pip to install packages in some specific directories within your home directory. This is a good way to have your own default Python environment that adds to the packages within your system directories, and therefore, does not affect the system Python installation.

What does Python pip stand for?

The name pip is [an] acronym and declaration: pip installs packages. ( Source) Package management is so important that Python's installers have included pip since versions 3.4 and 2.7. 9, for Python 3 and Python 2, respectively. Many Python projects use pip , which makes it an essential tool for every Pythonista.

Why do we use pip?

pip is a package management system used to install and manage software packages written in Python. Many packages can be found in the default source for packages and their dependencies — Python Package Index (PyPI).


1 Answers

A patch explaining this option was merged into the PIP documentation, but it was not released until Pip 6.0 (2014-12-22). (https://github.com/pypa/pip/commit/b5e54fc61c06268c131f1fad3bb4471e8c37bb25). Here is what that patch says:

--exists-action option

This option specifies default behavior when path already exists. Possible cases: downloading files or checking out repositories for installation, creating archives. If --exists-action is not defined, pip will prompt when decision is needed.

  • (s)witch

    Only relevant to VCS checkout. Attempt to switch the checkout to the appropriate url and/or revision.

  • (i)gnore

    Abort current operation (e.g. don't copy file, don't create archive, don't modify a checkout).

  • (w)ipe

    Delete the file or VCS checkout before trying to create, download, or checkout a new one.

  • (b)ackup

    Rename the file or checkout to {name}{'.bak' * n}, where n is some number of .bak extensions, such that the file didn't exist at some point. So the most recent backup will be the one with the largest number after .bak.

And here is a link to description of that option in the now-updated documentation: https://pip.pypa.io/en/stable/cli/pip/#exists-action-option.

like image 116
Daniel Harding Avatar answered Sep 28 '22 12:09

Daniel Harding