rgpycrumbs._aux¶
Attributes¶
Classes¶
Proxy that defers |
Functions¶
|
Warn when a PEP 723 script module is imported directly. |
|
Default AUTO_DEPS for library plot APIs (match CLI dispatch). |
|
Return True when a usable NVIDIA GPU is present. |
|
Return the per-user dependency cache directory. |
|
Return the pip install spec for module_name, respecting CUDA and SBOM pins. |
|
Install package_spec into target using uv (falling back to pip). |
|
Import module_name through a 5-step priority chain. |
|
Return a lazy proxy for module_name. |
|
Return the absolute path as a string. |
Return the root of the current git repository as a Path. |
|
|
Context manager that temporarily changes the working directory. |
|
Import a module from parent interpreter's site-packages as a fallback. |
Module Contents¶
- rgpycrumbs._aux.warn_on_direct_script_import(module_name: str, cli_hint: str, *, auto_env: str = 'RGPYCRUMBS_AUTO_DEPS', parent_env: str = 'RGPYCRUMBS_PARENT_SITE_PACKAGES', suppress_env: str = 'RGPYCRUMBS_SUPPRESS_SCRIPT_IMPORT_WARNING') None[source]¶
Warn when a PEP 723 script module is imported directly.
The warning is suppressed for normal script execution (
__main__), when the dependency-resolution environment contract is already present, or when the caller opts out explicitly.
- rgpycrumbs._aux.enable_library_auto_deps() None[source]¶
Default AUTO_DEPS for library plot APIs (match CLI dispatch).
CLI sets
RGPYCRUMBS_AUTO_DEPSfrom config (default on) before running scripts. Directfrom rgpycrumbs.eon import plot_nebnever did, soensure_import("jax")/adjustTextfailed unless the host pinned them. Call this at library plot entry before heavy imports.
- rgpycrumbs._aux._has_cuda() bool[source]¶
Return True when a usable NVIDIA GPU is present.
Checks for
nvidia-smion PATH and verifies it exits cleanly. The result is cached for the lifetime of the process.
- rgpycrumbs._aux._get_dep_cache_dir() pathlib.Path[source]¶
Return the per-user dependency cache directory.
Defaults to
$XDG_CACHE_HOME/rgpycrumbs/deps/(typically~/.cache/rgpycrumbs/deps/).
- rgpycrumbs._aux._resolve_pip_spec(module_name: str) str[source]¶
Return the pip install spec for module_name, respecting CUDA and SBOM pins.
If the host lacks a CUDA device and a CPU-only override exists, the override is returned instead of the default spec. When
RGPYCRUMBS_LOCK_PINS/RGPYCRUMBS_SBOM_PINSis set (dispatch after uv.lock / pylock / CycloneDX), matching packages becomename==version.
- rgpycrumbs._aux._uv_install(package_spec: str, target: pathlib.Path) None[source]¶
Install package_spec into target using uv (falling back to pip).
Raises
RuntimeErrorif both installers fail.
- rgpycrumbs._aux.ensure_import(module_name: str)[source]¶
Import module_name through a 5-step priority chain.
Current environment (importlib)
Parent environment (RGPYCRUMBS_PARENT_SITE_PACKAGES)
uv cache directory on sys.path
uv/pip install into cache (opt-in via RGPYCRUMBS_AUTO_DEPS=1)
Raise ImportError with an actionable message
Returns the imported module object.
Added in version 1.3.0.
- class rgpycrumbs._aux._LazyModule(module_name: str)[source]¶
Proxy that defers
ensure_importuntil first attribute access.After resolution the proxy replaces its own
__dict__with the real module’s attributes so subsequent access carries zero overhead.Added in version 1.3.0.
- rgpycrumbs._aux.lazy_import(module_name: str) _LazyModule[source]¶
Return a lazy proxy for module_name.
The actual import (via
ensure_import()) is deferred until the first attribute access on the returned object.Added in version 1.3.0.
- rgpycrumbs._aux.getstrform(pathobj)[source]¶
Return the absolute path as a string.
Added in version 0.0.1.
- rgpycrumbs._aux.get_gitroot()[source]¶
Return the root of the current git repository as a Path.
Added in version 0.0.1.