Skip to main content

Run some python before your pip commands.

Project description

pre-pip

Run some python code just before your pip commands.

pytest zsh pytest bash Package version


Use cases

  • Before installing a package, check it against a list of known malicious packages.
  • Upgrade pip automatically before installing a package.
  • Inject pip proxy settings into the environment before installing a package.

You can use it to run any custom python code before a pip command is executed.

Supported shells

The following shells are currently supported:

  • zsh
  • bash

I'm currently working on adding support for powershell and will thereafter look at fish.

Contributions for any other shells are welcome.

Installation

pip install pre-pip

There is potential to make this pipx installable.

Usage

Install pre-pip into your .*rc file using:

pre-pip install

Register a custom demo hook

Create a new file called hook.py in your current directory with the following content:

# hook.py
from rich import print as rprint


def main(args):
    rprint(
        f"This [italic green]pre-pip[/italic green] hook received: [italic cyan]{args}[/italic cyan]",
    )

Register the hook using:

pre-pip add hook.py

You can view the list of registered hooks using:

pre-pip list

Uninstall

Uninstall pre-pip using:

pre-pip uninstall

This will remove the pre-pip hook from your .*rc file as well as all registered hooks.

To remove the pre-pip package, use:

pip uninstall pre-pip

License

MIT

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

pre_pip-0.1.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

pre_pip-0.1.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file pre_pip-0.1.2.tar.gz.

File metadata

  • Download URL: pre_pip-0.1.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.15

File hashes

Hashes for pre_pip-0.1.2.tar.gz
Algorithm Hash digest
SHA256 18778ac2ebf55d4398dd62a00082b2a1ace24c3a518258a2950de78be3282967
MD5 feac25f15efd86ff9a75f5bc62b3a856
BLAKE2b-256 96579a01ebcbe912150b48841cb70a01fea6fc2926f161acfc22e8839f25ff13

See more details on using hashes here.

File details

Details for the file pre_pip-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pre_pip-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.15

File hashes

Hashes for pre_pip-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e7f77689d705624a932410d58bd9a35800c304f5f2fd4b13cfbf4195bae68226
MD5 b178cfba4d75ae24ff5e512781d43e3e
BLAKE2b-256 7664f4ee7e5bf550a42ca7d91799ec8511f19834c594b207f8e414633fea7b2d

See more details on using hashes here.

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