whichcraft

0.6.1 · maintenance · verified Thu Apr 16

whichcraft is a Python package that provides cross-platform and cross-Python `shutil.which` functionality. It serves as a shim for the `shutil.which` function, designed to work consistently across Python 2.7 and various Python 3 versions, including environments like Windows where system commands might behave differently. Its primary goal is to offer a reliable way to locate executables on the system PATH, similar to the Unix `which` command.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the `which` function and use it to find the path to various executables. It shows successful discovery, a non-existent command returning `None`, and highlights the cross-platform behavior for common commands like 'date'.

from whichcraft import which

# Find the path to a common executable
python_path = which('python')
print(f"Python executable found at: {python_path}")

# Try to find a command that might not exist
non_existent_command = which('nonexistent_command_123')
print(f"Non-existent command found at: {non_existent_command}")

# Example of a command that might behave differently across OS (e.g., 'date')
date_command = which('date')
print(f"'date' command found at: {date_command}")

view raw JSON →