Skip to main content

pip-manage lets you smoothly manage your installed packages.

Project description

pip-manage

pre-commit.ci status pylint status tests status CodeQL PyPI - Version Python versions Licens semantic-release PyPI - Format Ruff Style: black Imports: isort

pip-manage lets you smoothly manage your installed packages.

Installation

To install, simply use pip:

pip install pip-manage

Alternatively:

pip install git+https://github.com/realshouzy/pip-manage

Decide for yourself whether you want to install the tool system-wide, or inside a virtual env. Both are supported.

Documentation

pip-manage includes two tools pip-review and pip-purge.

pip-review

pip-review is a convenience wrapper around pip. It can list available updates by deferring to pip list --outdated. It can also automatically or interactively install available updates for you by deferring to pip install.

Example, report-only:

$ pip-review
requests==0.13.4 is available (you have 0.13.2)
redis==2.4.13 is available (you have 2.4.9)
rq==0.3.2 is available (you have 0.3.0)

You can also print raw lines:

$ pip-review --raw
requests==0.13.4
redis==2.4.13
rq==0.3.2

Example, actually install everything:

$ pip-review --auto
... <pip install output>

Example, run interactively, ask to upgrade for each package:

$ pip-review --interactive
requests==0.14.0 is available (you have 0.13.2)
Upgrade now? [Y]es, [N]o, [A]ll, [Q]uit y
...
redis==2.6.2 is available (you have 2.4.9)
Upgrade now? [Y]es, [N]o, [A]ll, [Q]uit n
rq==0.3.2 is available (you have 0.3.0)
Upgrade now? [Y]es, [N]o, [A]ll, [Q]uit y
...

Example, preview for update target list by pip list --outdated format, with run interactively or install everything:

$ pip-review --interactive --preview
Package  Version Latest Type
-----------------------------
redis    2.4.9   2.6.2  wheel
requests 0.13.2  0.14.0 wheel
rq       0.3.0   0.3.4  wheel
-----------------------------
... < --interactive processing >

You can also freeze the packages that will be upgraded to a file before actually upgrading them.

$ pip-review --auto --freeze-outdated-packages
... <pip install output>

By default it will safe them to backup.txt in the current directory, but you can specify the file path using the --freeze-file option.

Run pip-review -h for a complete overview of the options.

Note: If you want to pin specific packages to prevent them from automatically being upgraded, you can use a constraint file (similar to requirements.txt):

$ export PIP_CONSTRAINT="${HOME}/constraints.txt"
$ cat $PIP_CONSTRAINT
pyarrow==0.14.1
pandas<0.24.0

$ pip-review --auto
...

Set this variable in .bashrc or .zshenv to make it persistent.

  • Linux:
$ cat ~/.config/pip/pip.conf
[global]
constraint = /home/username/constraints.txt
  • Windows:
$ cat $HOME\AppData\Roaming\pip\pip.ini
[global]
constraint = '$HOME\Roaming\pip\constraints.txt'

The conf file are dependent of the user, so If you use multiple users you must define config file for each of them. https://pip.pypa.io/en/stable/user_guide/#constraints-files

Alternatively, since arguments that are also options for pip install or pip list --outdated will be forwarded, you can pass the constraint files directly as an argument using the --constraint option of pip install.

Like pip, pip-review updates all upgradeable packages, including pip and pip-manage.

pip-purge

pip-purge enables you to uninstall a package along with all its dependencies that are not required by any other packages. Simply specify the packages you want to purge, and pip-purge will handle the dependency resolution for you, ensuring that no other packages are broken in the process. It uses the importlib.metadata module to resolve the dependencies and then deferres to pip uninstall.

Example:

$ pip-purge requests
The following packages will be uninstalled: certifi, charset-normalizer, idna, requests, urllib3
Running: ...

You can also read from a requirements file. The read packages will be purged:

$ pip-purge --requirement requirements.txt
...

If you want to exclude certain packages, you can do that as follows:

$ pip-purge requests --exclude urllib3
The following packages will be uninstalled: certifi, charset-normalizer, idna, requests
Running: ...

Sometimes packages have extra / optional dependencies. These are considered by default, but can be ignored:

$ pip-purge requests --ignore-extra
...

It's recommended to do a dry run first, which performs all operations normally but doesn't defer to pip uninstall:

$ pip-purge requests --dry-run
The following packages will be uninstalled: certifi, charset-normalizer, idna, requests, urllib3
Would run: ...

You can also freeze the packages that will be uninstalled to a file before actually purging them.

$ pip-review requests --freeze-purged-packages
...

By default it will safe them to backup.txt in the current directory, but you can specify the file path using the --freeze-file option.

Run pip-purge -h for a complete overview of the options.

Contributing

If you are interested in contributing to this project, please refer here for more information.

Origins and credit

pip-review is derived from the original project of the same name created by Julian Gonggrijp. This fork is a refactored and enhanced version of the original.

Included from the original project: pip-review was originally part of pip-tools but has been discontinued as such. See Pin Your Packages by Vincent Driessen for the original introduction. Since there are still use cases, the tool now lives on as a separate package.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pip_manage-1.0.1.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

pip_manage-1.0.1-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file pip_manage-1.0.1.tar.gz.

File metadata

  • Download URL: pip_manage-1.0.1.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for pip_manage-1.0.1.tar.gz
Algorithm Hash digest
SHA256 2972762831b98f897c6a3614ef63272fa62894265e5f6a1cc1a1829cd9370949
MD5 d916c027a79a276358a807d5be3275a8
BLAKE2b-256 dd0c7e3378ca6d372b94b11d59735b8b9faead15bb3e42d8fbe65ce1ebe92870

See more details on using hashes here.

Provenance

File details

Details for the file pip_manage-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pip_manage-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for pip_manage-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f226d9fc70e5e6556c8cc4ffcb53a01ffe18532d8f7c39b884fc5fd7b961a27c
MD5 ab58d076d7d9271ecf0f441109082023
BLAKE2b-256 dd1b622562d9cec384b8de9d82956cdb2475680d7ee7ad410e26183e5a923a46

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page