Metadata-Version: 2.1
Name: wolfsoftware.prereqs
Version: 0.1.1
Summary: Check for the presence of prerequisite commands and returns their paths.
Home-page: https://github.com/DevelopersToolbox/check-prerequisite-package
Author: Wolf Software
Author-email: pypi@wolfsoftware.com
License: MIT
Project-URL:  Source, https://github.com/DevelopersToolbox/check-prerequisite-package
Project-URL:  Tracker, https://github.com/DevelopersToolbox/check-prerequisite-package/issues/
Project-URL:  Documentation, https://github.com/DevelopersToolbox/check-prerequisite-package
Project-URL:  Sponsor, https://github.com/sponsors/WolfSoftware
Keywords: python,prereqs
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: pytest==8.2.1
Requires-Dist: setuptools==70.0.0

<!-- markdownlint-disable -->
<p align="center">
    <a href="https://github.com/DevelopersToolbox/">
        <img src="https://cdn.wolfsoftware.com/assets/images/github/organisations/developerstoolbox/black-and-white-circle-256.png" alt="DevelopersToolbox logo" />
    </a>
    <br />
    <a href="https://github.com/DevelopersToolbox/check-prerequisite/actions/workflows/cicd.yml">
        <img src="https://img.shields.io/github/actions/workflow/status/DevelopersToolbox/check-prerequisite/cicd.yml?branch=master&label=build%20status&style=for-the-badge" alt="Github Build Status" />
    </a>
    <a href="https://github.com/DevelopersToolbox/check-prerequisite/blob/master/LICENSE.md">
        <img src="https://img.shields.io/github/license/DevelopersToolbox/check-prerequisite?color=blue&label=License&style=for-the-badge" alt="License">
    </a>
    <a href="https://github.com/DevelopersToolbox/check-prerequisite">
        <img src="https://img.shields.io/github/created-at/DevelopersToolbox/check-prerequisite?color=blue&label=Created&style=for-the-badge" alt="Created">
    </a>
    <br />
    <a href="https://github.com/DevelopersToolbox/check-prerequisite/releases/latest">
        <img src="https://img.shields.io/github/v/release/DevelopersToolbox/check-prerequisite?color=blue&label=Latest%20Release&style=for-the-badge" alt="Release">
    </a>
    <a href="https://github.com/DevelopersToolbox/check-prerequisite/releases/latest">
        <img src="https://img.shields.io/github/release-date/DevelopersToolbox/check-prerequisite?color=blue&label=Released&style=for-the-badge" alt="Released">
    </a>
    <a href="https://github.com/DevelopersToolbox/check-prerequisite/releases/latest">
        <img src="https://img.shields.io/github/commits-since/DevelopersToolbox/check-prerequisite/latest.svg?color=blue&style=for-the-badge" alt="Commits since release">
    </a>
    <br />
    <a href="https://github.com/DevelopersToolbox/check-prerequisite/blob/master/.github/CODE_OF_CONDUCT.md">
        <img src="https://img.shields.io/badge/Code%20of%20Conduct-blue?style=for-the-badge" />
    </a>
    <a href="https://github.com/DevelopersToolbox/check-prerequisite/blob/master/.github/CONTRIBUTING.md">
        <img src="https://img.shields.io/badge/Contributing-blue?style=for-the-badge" />
    </a>
    <a href="https://github.com/DevelopersToolbox/check-prerequisite/blob/master/.github/SECURITY.md">
        <img src="https://img.shields.io/badge/Report%20Security%20Concern-blue?style=for-the-badge" />
    </a>
    <a href="https://github.com/DevelopersToolbox/check-prerequisite/issues">
        <img src="https://img.shields.io/badge/Get%20Support-blue?style=for-the-badge" />
    </a>
</p>

## Overview

When you write a script or tool which uses subprocess to execute shell commands, you want to know if the commands are installed or not. This is
particularly important if you are running multiple commands which rely on each other.

You can of course catch the exceptions through using `check=True` but if you need to know they all exist before you start your execution run then
this doesn't help you as it only handled the failure it currently has.

This little package assist with that problem by taking a list of commands that must be installed and available and verifies that list at the start to
ensure all of them are available.

## Installation

```shell
pip install wolfsoftware.prereqs
```

## Usage

```python
import sys

from wolfsoftware.prereqs import check_prerequisite, PrerequisiteCheckError

prerequisites: list[str] = ["python", "git"]

try:
    command_paths: dict = check_prerequisite(prerequisites)
except PrerequisiteCheckError as err:
    print("Prerequisite check failed:")
    for error in err.errors:
        print(error)
    sys.exit(0)

print(command_paths['python'])
```

Once the checks have completed, you now have a dict of commands and their associated paths which you can then utilise to ensure you are executing
your subprocesses with the full path.

<br />
<p align="right"><a href="https://wolfsoftware.com/"><img src="https://img.shields.io/badge/Created%20by%20Wolf%20on%20behalf%20of%20Wolf%20Software-blue?style=for-the-badge" /></a></p>
