hbutils.system.os.executable
Executable discovery utilities for system PATH inspection.
This module provides utilities to locate executable files in the system PATH,
similar to the Unix which/where commands and the Windows where command.
It supports both Unix-like systems and Windows, handling platform-specific search
behavior and executable file extensions.
The module contains the following main public components:
where()- Return all matching executable paths inPATHwhich()- Return the first matching executable path (deprecated)
Note
On Windows, the search includes the current directory and checks common
executable extensions (.bat, .cmd, .com, .exe) as defined by
the implementation.
Example:
>>> from hbutils.system.os.executable import where
>>> where('python')
['/usr/bin/python', '/bin/python']
__all__
- hbutils.system.os.executable.__all__ = ['where', 'which']
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
where
- hbutils.system.os.executable.where(execfile: str) List[str][source]
Return all matching file paths for the given executable.
This function searches through all directories in the system
PATHenvironment variable and returns a list of all absolute paths where the executable file can be found. On Windows, it also checks for common executable extensions (.bat,.cmd,.com,.exe) and includes the current directory in the search path.- Parameters:
execfile (str) – Executable file to locate (such as
python).- Returns:
A list of normalized absolute paths to executable files.
- Return type:
List[str]
Example:
>>> from hbutils.system.os.executable import where >>> where('bash') ['/usr/bin/bash', '/bin/bash'] >>> where('not_installed') []
which
- hbutils.system.os.executable.which(execfile: str) str | None[source]
Return the first matching executable path in the system
PATH(deprecated).This function returns the first executable file found in the system
PATH, which is typically the one that would be executed when running the command in a terminal. ReturnsNoneif no matching executable is found.Deprecated since version 0.9: Use the native
shutil.which()instead. This function will be removed in version 1.0.- Parameters:
execfile (str) – Executable file to locate (such as
python).- Returns:
Absolute path of the executable file, or
Noneif not found.- Return type:
Optional[str]
Example:
>>> from hbutils.system.os.executable import which >>> which('bash') '/usr/bin/bash' >>> which('not_installed') is None True
Deprecated since version 0.9: This will be removed in 1.0. Use the native
shutil.which()instead