Skip to main content

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


Download files

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

Source Distribution

install_directives-1.0.0.tar.gz (5.5 kB view hashes)

Uploaded Source

Built Distribution

install_directives-1.0.0-py3-none-any.whl (6.3 kB view hashes)

Uploaded Python 3

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