Module psdi_data_conversion.dist
@file psdi_data_conversion/dist.py
Created 2025-02-25 by Bryan Gillis.
Functions and utilities related to handling multiple user OSes and distributions
Functions
def bin_exists(bin_name: str) ‑> bool
-
Expand source code
def bin_exists(bin_name: str) -> bool: """Gets whether or not a binary of the given name exists for the user's platform """ return get_bin_path(bin_name) is not None
Gets whether or not a binary of the given name exists for the user's platform
def get_bin_path(bin_name: str) ‑> str | None
-
Expand source code
def get_bin_path(bin_name: str) -> str | None: """Gets the path to an appropriate binary for the user's platform, if one exists. Will first search in this package, then in the user's $PATH Parameters ---------- bin_name : str The unqualified name of the binary Returns ------- str | None If an appropriate binary exists for the user's platform, a fully-qualified path to it. Otherwise, None """ # If DIST is None, then the user's OS/distribution is unsupported dist = get_dist() if not dist: return _get_local_bin(bin_name) bin_path = os.path.join(BIN_DIR, dist, bin_name) # Check if the binary exists in the path for the user's OS/distribution if not os.path.isfile(bin_path): return _get_local_bin(bin_name) return bin_path
Gets the path to an appropriate binary for the user's platform, if one exists. Will first search in this package, then in the user's $PATH
Parameters
bin_name
:str
- The unqualified name of the binary
Returns
str | None
- If an appropriate binary exists for the user's platform, a fully-qualified path to it. Otherwise, None
def get_dist()
-
Expand source code
def get_dist(): """Determine the current platform """ dist: str | None = None for label, name_head in D_DIST_NAME_HEADS.items(): if sys.platform.startswith(name_head): dist = label break return dist
Determine the current platform