Useful for doing pip post-install/uninstall things
Project description
install-directives
install-directives
contains a command line tool, install-directives
, used to aid in post-install and post-uninstall steps for packages installed with pip
. It also includes a class to represent packages installed with pip
.
Usage
The idea is to write a custom class that inherts from InstallDirectives
, overriding its package_name
and module_name
attributes and its _install
and _uninstall
functions. This should be placed in a package called install_directives
in your module.
For example, if your package is called "mypackage", you could set up InstallDirectives
for it to run a script on install and another script on uninstall as such.
# mypackage/install_directives/__init__.py
from python_install_directives import InstallDirectives as InstallDirectives_
class InstallDirectives(InstallDirectives_):
def __init__(self) -> None:
super().__init__("mypackage")
def _install(old_version: str, new_version: str) -> None:
run_script()
def _uninstall(version: str) -> None:
run_another_script()
These overridden functions will be called upon running the command line tool as such. You can utilize the current and incoming versions of the package to perform different actions on install, as they come in as parameters. Similarly, you can utilize the current version during uninstall.
# Do a pip install of myproject first
install-directives myproject install # Calls `run_script`
install-directives myproject uninstall # Calls `run_another_script`
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file install_directives-1.0.0.tar.gz
.
File metadata
- Download URL: install_directives-1.0.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73f52521cd5b2dd0524e1c4a128c113b43af0ae766fa5978aa2ae67ed26bea6d |
|
MD5 | 9eae2dcc26e2f1712f337eb799683e62 |
|
BLAKE2b-256 | e0196b91eff18b871bd1904ddedee9695804fedc2514bdef6c9249aad00b5258 |
File details
Details for the file install_directives-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: install_directives-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bb0c3f3599b8e9233dbfbef7aa328caf18333fefb8ff3669a3649be7345195c |
|
MD5 | 98e761fa53c53892c59c48c9e83a9b47 |
|
BLAKE2b-256 | 7081dda09462b587c45db0b6b6545c0a43c53a1cbf19db5d6e159ea39650d4c8 |