Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ratulmaharaj/pre-pip
Run some python before your pip commands.
https://github.com/ratulmaharaj/pre-pip
click hooks pip python rich
Last synced: 1 day ago
JSON representation
Run some python before your pip commands.
- Host: GitHub
- URL: https://github.com/ratulmaharaj/pre-pip
- Owner: RatulMaharaj
- License: mit
- Created: 2022-11-29T02:10:08.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-05T00:44:19.000Z (about 2 years ago)
- Last Synced: 2025-01-29T07:28:29.944Z (6 days ago)
- Topics: click, hooks, pip, python, rich
- Language: Python
- Homepage: https://pypi.org/project/pre-pip/
- Size: 55.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Run some python code just before your pip commands.
### 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
The recommended way to install `pre-pip` would be using `pipx`. This will enable you to use `pre-pip` with multiple python versions or across virtual environments.
```sh
pipx install pre-pip
```Alternatively, you can install it with `pip`:
```sh
pip install pre-pip
```### Usage
Install `pre-pip` into your `.*rc` file using:
```sh
pre-pip install
```### Register a custom demo hook
Create a new file called `hook.py` in your current directory with the following content:
```python
# hook.py
from rich import print as rprintdef main(args):
rprint(
f"This [italic green]pre-pip[/italic green] hook received: [italic cyan]{args}[/italic cyan]",
)```
Register the hook using:
```sh
pre-pip add hook.py
```You can view the list of registered hooks using:
```sh
pre-pip list
```### Uninstall
Uninstall `pre-pip` using:
```sh
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:
```sh
pip uninstall pre-pip
```### License
[MIT](LICENSE)