meta_package_manager.managers.pip

class meta_package_manager.managers.pip.Pip[source]

Bases: meta_package_manager.base.PackageManager

We will use system’s default Python to call out pip as a module.

This is a more robust way of managing packages: “if you’re on Windows there is an added benefit to using python -m pip as it lets pip update itself.” Source: https://snarky.ca/why-you-should-use-python-m-pip/

platforms = frozenset({'linux', 'macos', 'windows'})
requirement = '10.0.0'
cli_name = 'python'
global_args = ['-m', 'pip', '--no-color']
get_version()[source]

Fetch version.

► python -m pip --no-color --version
pip 2.0.2 from /usr/local/lib/python/site-packages/pip (python 3.7)
property installed

Fetch installed packages.

► python -m pip list --no-color --format=json --verbose --quiet             > | jq
[
 {
    "version": "1.3",
    "name": "backports.functools-lru-cache",
    "location": "/usr/local/lib/python3.7/site-packages",
    "installer": "pip"
  },
  {
    "version": "0.9999999",
    "name": "html5lib",
    "location": "/usr/local/lib/python3.7/site-packages",
    "installer": "pip"
  },
  {
    "name": "setuptools",
    "version": "46.0.0",
    "location": "/usr/local/lib/python3.7/site-packages",
    "installer": ""
  },
  {
    "version": "2.8",
    "name": "Jinja2",
    "location": "/usr/local/lib/python3.7/site-packages",
    "installer": ""
  },
  (...)
]
search(query, extended, exact)[source]

Fetch matching packages.

► python -m pip --no-color search abc
ABC (0.0.0)                 - UNKNOWN
micropython-abc (0.0.1)     - Dummy abc module for MicroPython
abc1 (1.2.0)                - a list about my think
abcd (0.3.0)                - AeroGear Build Cli for Digger
abcyui (1.0.0)              - Sorry ,This is practice!
astroabc (1.4.2)            - A Python implementation of an
                              Approximate Bayesian Computation
                              Sequential Monte Carlo (ABC SMC)
                              sampler for parameter estimation.
collective.js.abcjs (1.10)  - UNKNOWN
cosmo (1.0.5)               - Python ABC sampler
property outdated

Fetch outdated packages.

► python -m pip --no-color list --format=json --outdated             > --verbose --quiet | jq
[
  {
    "latest_filetype": "wheel",
    "version": "0.7.9",
    "name": "alabaster",
    "latest_version": "0.7.10",
    "location": "/usr/local/lib/python3.7/site-packages",
    "installer": "pip"
  },
  {
    "latest_filetype": "wheel",
    "version": "0.9999999",
    "name": "html5lib",
    "latest_version": "0.999999999",
    "location": "/usr/local/lib/python3.7/site-packages",
    "installer": "pip"
   },
  {
    "latest_filetype": "wheel",
    "version": "2.8",
    "name": "Jinja2",
    "latest_version": "2.9.5",
    "location": "/usr/local/lib/python3.7/site-packages",
    "installer": "pip"
   },
  {
    "latest_filetype": "wheel",
    "version": "0.5.3",
    "name": "mccabe",
    "latest_version": "0.6.1",
    "location": "/usr/local/lib/python3.7/site-packages",
    "installer": "pip"
   },
  {
    "latest_filetype": "wheel",
    "version": "2.2.0",
    "name": "pycodestyle",
    "latest_version": "2.3.1",
    "location": "/usr/local/lib/python3.7/site-packages",
    "installer": "pip"
   },
  {
    "latest_filetype": "wheel",
    "version": "2.1.3",
    "name": "Pygments",
    "latest_version": "2.2.0",
    "location": "/usr/local/lib/python3.7/site-packages",
    "installer": ""
   }
]
upgrade_cli(package_id)[source]

Build-up package upgrade CLI.

► python -m pip --no-color install --user --upgrade six
Collecting six
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Installing collected packages: six
  Attempting uninstall: six
    Found existing installation: six 1.14.0
    Uninstalling six-1.14.0:
      Successfully uninstalled six-1.14.0
Successfully installed six-1.15.0
upgrade_all_cli()[source]

Pip lacks support of a proper full upgrade command. Raising an error let the parent class upgrade packages one by one.

See: https://github.com/pypa/pip/issues/59