From d66769baed97923f1f81b2c1ddfee5c43c8fa70b Mon Sep 17 00:00:00 2001 From: Yusuke Watanabe Date: Mon, 27 Apr 2026 05:49:31 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20convert=2012=20explicit=20re-export=20?= =?UTF-8?q?shims=20=E2=86=92=20sys.modules-alias=20bridges?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For every scitex.X where scitex-X is already a separate published package and the umbrella's __init__.py only re-exports symbols, replace the explicit re-export list with the same sys.modules alias pattern used by all other extracted modules. Modules touched: audio, audit, etc, parallel, path, dict, types, gists, browser, repro, compat, str. Why this matters: - Explicit re-export lists silently drift whenever the standalone package adds a new public name — the umbrella has to re-publish to expose it. - sys.modules aliasing makes `scitex.X is scitex_X`, so every new symbol is automatically visible without scitex-python republishing. Verified for all 12: `scitex. is scitex_`. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/scitex/audio/__init__.py | 56 ++++++---------- src/scitex/audit/__init__.py | 23 +++++-- src/scitex/browser/__init__.py | 97 ++++++---------------------- src/scitex/compat/__init__.py | 27 +++++--- src/scitex/dict/__init__.py | 39 ++++++----- src/scitex/etc/__init__.py | 23 +++++-- src/scitex/gists/__init__.py | 33 +++++----- src/scitex/parallel/__init__.py | 25 +++++-- src/scitex/path/__init__.py | 67 ++++++------------- src/scitex/repro/__init__.py | 77 +++++----------------- src/scitex/str/__init__.py | 111 ++++++-------------------------- src/scitex/types/__init__.py | 35 +++++----- 12 files changed, 214 insertions(+), 399 deletions(-) diff --git a/src/scitex/audio/__init__.py b/src/scitex/audio/__init__.py index 57d05271e..f73e685f3 100755 --- a/src/scitex/audio/__init__.py +++ b/src/scitex/audio/__init__.py @@ -1,41 +1,21 @@ -#!/usr/bin/env python3 -"""SciTeX Audio — thin wrapper delegating to scitex-audio package.""" +"""SciTeX audio — thin compatibility shim for scitex-audio. -from scitex_audio import * # noqa: F401,F403 -from scitex_audio import ( - FALLBACK_ORDER, - TTS, - ElevenLabsTTS, - GoogleTTS, - LuxTTS, - SystemTTS, - available_backends, - available_models, - check_local_audio_available, - check_wsl_audio, - find_whisper_cli, - find_whisper_model, - generate_bytes, - get_tts, - speak, - stop_speech, - transcribe, -) +Aliases ``scitex.audio`` to the standalone ``scitex_audio`` package via +``sys.modules`` so ``scitex.audio is scitex_audio`` and any new public name +added to scitex_audio is automatically visible. -__all__ = [ - "speak", - "generate_bytes", - "stop_speech", - "check_wsl_audio", - "check_local_audio_available", - "TTS", - "GoogleTTS", - "ElevenLabsTTS", - "SystemTTS", - "LuxTTS", - "get_tts", - "available_backends", - "FALLBACK_ORDER", -] +Install: ``pip install scitex-audio``. +See: https://github.com/ywatanabe1989/scitex-audio +""" -# EOF +import sys as _sys + +try: + import scitex_audio as _real +except ImportError as _e: # pragma: no cover + raise ImportError( + "scitex.audio requires the 'scitex-audio' package. " + "Install with: pip install scitex-audio" + ) from _e + +_sys.modules[__name__] = _real diff --git a/src/scitex/audit/__init__.py b/src/scitex/audit/__init__.py index 913b7d26f..dd8553d35 100755 --- a/src/scitex/audit/__init__.py +++ b/src/scitex/audit/__init__.py @@ -1,8 +1,21 @@ -#!/usr/bin/env python3 -"""SciTeX audit module — delegates to scitex-audit.""" +"""SciTeX audit — thin compatibility shim for scitex-audit. -from scitex_audit import audit +Aliases ``scitex.audit`` to the standalone ``scitex_audit`` package via +``sys.modules`` so ``scitex.audit is scitex_audit`` and any new public name +added to scitex_audit is automatically visible. -__all__ = ["audit"] +Install: ``pip install scitex-audit``. +See: https://github.com/ywatanabe1989/scitex-audit +""" -# EOF +import sys as _sys + +try: + import scitex_audit as _real +except ImportError as _e: # pragma: no cover + raise ImportError( + "scitex.audit requires the 'scitex-audit' package. " + "Install with: pip install scitex-audit" + ) from _e + +_sys.modules[__name__] = _real diff --git a/src/scitex/browser/__init__.py b/src/scitex/browser/__init__.py index be137dae0..7cb87454a 100755 --- a/src/scitex/browser/__init__.py +++ b/src/scitex/browser/__init__.py @@ -1,82 +1,21 @@ -#!/usr/bin/env python3 -"""SciTeX browser — delegates to scitex-browser.""" +"""SciTeX browser — thin compatibility shim for scitex-browser. -from scitex_browser import ( - PopupHandler, - SyncBrowserSession, - TestMonitor, - browser_logger, - click_center_async, - click_download_for_chrome_pdf_viewer_async, - click_with_fallbacks_async, - close_popups_async, - collect_console_logs, - collect_console_logs_detailed, - create_browser_session_fixture, - create_failure_capture_fixture, - create_test_monitor_fixture, - detect_chrome_pdf_viewer_async, - ensure_no_popups_async, - fill_with_fallbacks_async, - format_logs_devtools_style, - highlight_element_async, - inject_visual_effects, - inject_visual_effects_async, - is_playwright_cli_available, - monitor_test, - save_as_pdf, - save_as_pdf_async, - save_failure_artifacts, - setup_console_interceptor, - show_click_effect, - show_click_effect_async, - show_cursor_at, - show_cursor_at_async, - show_grid_async, - show_step, - show_step_async, - show_test_result, - show_test_result_async, - sync_browser_session, -) +Aliases ``scitex.browser`` to the standalone ``scitex_browser`` package via +``sys.modules`` so ``scitex.browser is scitex_browser`` and any new public name +added to scitex_browser is automatically visible. -__all__ = [ - "is_playwright_cli_available", - "browser_logger", - "show_grid_async", - "highlight_element_async", - "inject_visual_effects", - "show_cursor_at", - "show_click_effect", - "show_step", - "show_test_result", - "inject_visual_effects_async", - "show_cursor_at_async", - "show_click_effect_async", - "show_step_async", - "show_test_result_async", - "setup_console_interceptor", - "collect_console_logs", - "collect_console_logs_detailed", - "format_logs_devtools_style", - "save_failure_artifacts", - "create_failure_capture_fixture", - "TestMonitor", - "create_test_monitor_fixture", - "monitor_test", - "SyncBrowserSession", - "sync_browser_session", - "create_browser_session_fixture", - "save_as_pdf", - "save_as_pdf_async", - "detect_chrome_pdf_viewer_async", - "click_download_for_chrome_pdf_viewer_async", - "click_center_async", - "click_with_fallbacks_async", - "fill_with_fallbacks_async", - "PopupHandler", - "close_popups_async", - "ensure_no_popups_async", -] +Install: ``pip install scitex-browser``. +See: https://github.com/ywatanabe1989/scitex-browser +""" -# EOF +import sys as _sys + +try: + import scitex_browser as _real +except ImportError as _e: # pragma: no cover + raise ImportError( + "scitex.browser requires the 'scitex-browser' package. " + "Install with: pip install scitex-browser" + ) from _e + +_sys.modules[__name__] = _real diff --git a/src/scitex/compat/__init__.py b/src/scitex/compat/__init__.py index 93ffbfe72..052f527f7 100755 --- a/src/scitex/compat/__init__.py +++ b/src/scitex/compat/__init__.py @@ -1,12 +1,21 @@ -#!/usr/bin/env python3 -"""SciTeX compat module — delegates to scitex-compat.""" +"""SciTeX compat — thin compatibility shim for scitex-compat. -from scitex_compat import deprecated, notify, notify_async +Aliases ``scitex.compat`` to the standalone ``scitex_compat`` package via +``sys.modules`` so ``scitex.compat is scitex_compat`` and any new public name +added to scitex_compat is automatically visible. -__all__ = [ - "deprecated", - "notify", - "notify_async", -] +Install: ``pip install scitex-compat``. +See: https://github.com/ywatanabe1989/scitex-compat +""" -# EOF +import sys as _sys + +try: + import scitex_compat as _real +except ImportError as _e: # pragma: no cover + raise ImportError( + "scitex.compat requires the 'scitex-compat' package. " + "Install with: pip install scitex-compat" + ) from _e + +_sys.modules[__name__] = _real diff --git a/src/scitex/dict/__init__.py b/src/scitex/dict/__init__.py index 6d9767d51..4c646a152 100755 --- a/src/scitex/dict/__init__.py +++ b/src/scitex/dict/__init__.py @@ -1,24 +1,21 @@ -#!/usr/bin/env python3 -"""SciTeX dict — delegates to scitex-dict.""" +"""SciTeX dict — thin compatibility shim for scitex-dict. -from scitex_dict import ( - DotDict, - flatten, - listed_dict, - pop_keys, - replace, - safe_merge, - to_str, -) +Aliases ``scitex.dict`` to the standalone ``scitex_dict`` package via +``sys.modules`` so ``scitex.dict is scitex_dict`` and any new public name +added to scitex_dict is automatically visible. -__all__ = [ - "DotDict", - "flatten", - "listed_dict", - "pop_keys", - "replace", - "safe_merge", - "to_str", -] +Install: ``pip install scitex-dict``. +See: https://github.com/ywatanabe1989/scitex-dict +""" -# EOF +import sys as _sys + +try: + import scitex_dict as _real +except ImportError as _e: # pragma: no cover + raise ImportError( + "scitex.dict requires the 'scitex-dict' package. " + "Install with: pip install scitex-dict" + ) from _e + +_sys.modules[__name__] = _real diff --git a/src/scitex/etc/__init__.py b/src/scitex/etc/__init__.py index 3ae04aab0..4a4718e94 100755 --- a/src/scitex/etc/__init__.py +++ b/src/scitex/etc/__init__.py @@ -1,8 +1,21 @@ -#!/usr/bin/env python3 -"""SciTeX etc module — delegates to scitex-etc.""" +"""SciTeX etc — thin compatibility shim for scitex-etc. -from scitex_etc import count, wait_key +Aliases ``scitex.etc`` to the standalone ``scitex_etc`` package via +``sys.modules`` so ``scitex.etc is scitex_etc`` and any new public name +added to scitex_etc is automatically visible. -__all__ = ["wait_key", "count"] +Install: ``pip install scitex-etc``. +See: https://github.com/ywatanabe1989/scitex-etc +""" -# EOF +import sys as _sys + +try: + import scitex_etc as _real +except ImportError as _e: # pragma: no cover + raise ImportError( + "scitex.etc requires the 'scitex-etc' package. " + "Install with: pip install scitex-etc" + ) from _e + +_sys.modules[__name__] = _real diff --git a/src/scitex/gists/__init__.py b/src/scitex/gists/__init__.py index bf18e65a7..912deab11 100755 --- a/src/scitex/gists/__init__.py +++ b/src/scitex/gists/__init__.py @@ -1,18 +1,21 @@ -#!/usr/bin/env python3 -"""SciTeX gists module — delegates to scitex-gists.""" +"""SciTeX gists — thin compatibility shim for scitex-gists. -from scitex_gists import ( - SigMacro_processFigure_S, - SigMacro_toBlue, - sigmacro_process_figure_s, - sigmacro_to_blue, -) +Aliases ``scitex.gists`` to the standalone ``scitex_gists`` package via +``sys.modules`` so ``scitex.gists is scitex_gists`` and any new public name +added to scitex_gists is automatically visible. -__all__ = [ - "SigMacro_processFigure_S", - "SigMacro_toBlue", - "sigmacro_process_figure_s", - "sigmacro_to_blue", -] +Install: ``pip install scitex-gists``. +See: https://github.com/ywatanabe1989/scitex-gists +""" -# EOF +import sys as _sys + +try: + import scitex_gists as _real +except ImportError as _e: # pragma: no cover + raise ImportError( + "scitex.gists requires the 'scitex-gists' package. " + "Install with: pip install scitex-gists" + ) from _e + +_sys.modules[__name__] = _real diff --git a/src/scitex/parallel/__init__.py b/src/scitex/parallel/__init__.py index 458c520d1..f572610bd 100755 --- a/src/scitex/parallel/__init__.py +++ b/src/scitex/parallel/__init__.py @@ -1,10 +1,21 @@ -#!/usr/bin/env python3 -"""SciTeX parallel module — delegates to scitex-parallel.""" +"""SciTeX parallel — thin compatibility shim for scitex-parallel. -from scitex_parallel import run +Aliases ``scitex.parallel`` to the standalone ``scitex_parallel`` package via +``sys.modules`` so ``scitex.parallel is scitex_parallel`` and any new public name +added to scitex_parallel is automatically visible. -__all__ = [ - "run", -] +Install: ``pip install scitex-parallel``. +See: https://github.com/ywatanabe1989/scitex-parallel +""" -# EOF +import sys as _sys + +try: + import scitex_parallel as _real +except ImportError as _e: # pragma: no cover + raise ImportError( + "scitex.parallel requires the 'scitex-parallel' package. " + "Install with: pip install scitex-parallel" + ) from _e + +_sys.modules[__name__] = _real diff --git a/src/scitex/path/__init__.py b/src/scitex/path/__init__.py index 0a16680e9..c482aa9d8 100755 --- a/src/scitex/path/__init__.py +++ b/src/scitex/path/__init__.py @@ -1,52 +1,21 @@ -#!/usr/bin/env python3 -"""SciTeX path module — delegates to scitex-path.""" +"""SciTeX path — thin compatibility shim for scitex-path. -from scitex_path import ( - clean, - create_relative_symlink, - find_dir, - find_file, - find_git_root, - find_latest, - fix_broken_symlinks, - get_data_path_from_a_package, - get_spath, - get_this_path, - getsize, - increment_version, - is_symlink, - list_symlinks, - mk_spath, - readlink, - resolve_symlinks, - split, - symlink, - this_path, - unlink_symlink, -) +Aliases ``scitex.path`` to the standalone ``scitex_path`` package via +``sys.modules`` so ``scitex.path is scitex_path`` and any new public name +added to scitex_path is automatically visible. -__all__ = [ - "clean", - "create_relative_symlink", - "find_dir", - "find_file", - "find_git_root", - "find_latest", - "fix_broken_symlinks", - "get_data_path_from_a_package", - "get_spath", - "get_this_path", - "getsize", - "increment_version", - "is_symlink", - "list_symlinks", - "mk_spath", - "readlink", - "resolve_symlinks", - "split", - "symlink", - "this_path", - "unlink_symlink", -] +Install: ``pip install scitex-path``. +See: https://github.com/ywatanabe1989/scitex-path +""" -# EOF +import sys as _sys + +try: + import scitex_path as _real +except ImportError as _e: # pragma: no cover + raise ImportError( + "scitex.path requires the 'scitex-path' package. " + "Install with: pip install scitex-path" + ) from _e + +_sys.modules[__name__] = _real diff --git a/src/scitex/repro/__init__.py b/src/scitex/repro/__init__.py index f49c393fa..8442fe0e3 100755 --- a/src/scitex/repro/__init__.py +++ b/src/scitex/repro/__init__.py @@ -1,66 +1,21 @@ -#!/usr/bin/env python3 -"""SciTeX repro module — delegates to scitex-repro. - -Provides tools for reproducible scientific computing: -- Random state management (RandomStateManager) -- ID generation (gen_ID) -- Timestamp generation (gen_timestamp) -- Array hashing (hash_array) -""" - -from scitex_repro import ( - RandomStateManager, - gen_ID, - gen_id, - gen_timestamp, - get, - hash_array, - reset, - timestamp, -) +"""SciTeX repro — thin compatibility shim for scitex-repro. +Aliases ``scitex.repro`` to the standalone ``scitex_repro`` package via +``sys.modules`` so ``scitex.repro is scitex_repro`` and any new public name +added to scitex_repro is automatically visible. -# Legacy function for backward compatibility (user-confirmed fallback) -def fix_seeds( - seed=42, - os=True, - random=True, - np=True, - torch=True, - tf=False, - jax=False, - verbose=False, - **kwargs, -): - """ - Deprecated: Use stx.repro.RandomStateManager instead. - - This function maintains backward compatibility with the old fix_seeds API. - """ - import warnings - - warnings.warn( - "fix_seeds is deprecated. Use stx.repro.RandomStateManager instead.", - DeprecationWarning, - stacklevel=2, - ) - return RandomStateManager(seed=seed, verbose=verbose) +Install: ``pip install scitex-repro``. +See: https://github.com/ywatanabe1989/scitex-repro +""" +import sys as _sys -__all__ = [ - # ID and timestamp utilities - "gen_ID", - "gen_id", - "gen_timestamp", - "timestamp", - # Hash utilities - "hash_array", - # Random state management - "RandomStateManager", - "get", - "reset", - # Legacy (deprecated) - "fix_seeds", -] +try: + import scitex_repro as _real +except ImportError as _e: # pragma: no cover + raise ImportError( + "scitex.repro requires the 'scitex-repro' package. " + "Install with: pip install scitex-repro" + ) from _e -# EOF +_sys.modules[__name__] = _real diff --git a/src/scitex/str/__init__.py b/src/scitex/str/__init__.py index dda5d446f..70cd0e96e 100755 --- a/src/scitex/str/__init__.py +++ b/src/scitex/str/__init__.py @@ -1,96 +1,21 @@ -#!/usr/bin/env python3 -"""SciTeX str — delegates to scitex-str.""" +"""SciTeX str — thin compatibility shim for scitex-str. -from scitex_str import ( - LaTeXFallbackError, - add_hat_in_latex_style, - auto_factor_axis, - axis_label, - check_latex_capability, - check_unit_consistency, - clean_path, - color_text, - ct, - decapitalize, - disable_latex_fallback, - enable_latex_fallback, - factor_out_digits, - format_axis_label, - format_plot_text, - format_title, - get_fallback_mode, - get_latex_status, - grep, - hat_latex_style, - latex_fallback_decorator, - latex_style, - latex_to_mathtext, - latex_to_unicode, - mask_api, - parse, - print_debug, - printc, - readable_bytes, - remove_ansi, - replace, - reset_latex_cache, - safe_add_hat_in_latex_style, - safe_latex_render, - safe_to_latex_style, - scientific_text, - search, - set_fallback_mode, - smart_tick_formatter, - squeeze_spaces, - title, - title_case, - to_latex_style, -) +Aliases ``scitex.str`` to the standalone ``scitex_str`` package via +``sys.modules`` so ``scitex.str is scitex_str`` and any new public name +added to scitex_str is automatically visible. -__all__ = [ - "LaTeXFallbackError", - "add_hat_in_latex_style", - "auto_factor_axis", - "axis_label", - "check_latex_capability", - "check_unit_consistency", - "clean_path", - "color_text", - "ct", - "decapitalize", - "disable_latex_fallback", - "enable_latex_fallback", - "factor_out_digits", - "format_axis_label", - "format_plot_text", - "format_title", - "get_fallback_mode", - "get_latex_status", - "grep", - "hat_latex_style", - "latex_fallback_decorator", - "latex_style", - "latex_to_mathtext", - "latex_to_unicode", - "mask_api", - "parse", - "print_debug", - "printc", - "readable_bytes", - "remove_ansi", - "replace", - "reset_latex_cache", - "safe_add_hat_in_latex_style", - "safe_latex_render", - "safe_to_latex_style", - "scientific_text", - "search", - "set_fallback_mode", - "smart_tick_formatter", - "squeeze_spaces", - "title", - "title_case", - "to_latex_style", -] +Install: ``pip install scitex-str``. +See: https://github.com/ywatanabe1989/scitex-str +""" -# EOF +import sys as _sys + +try: + import scitex_str as _real +except ImportError as _e: # pragma: no cover + raise ImportError( + "scitex.str requires the 'scitex-str' package. " + "Install with: pip install scitex-str" + ) from _e + +_sys.modules[__name__] = _real diff --git a/src/scitex/types/__init__.py b/src/scitex/types/__init__.py index d5b6f8c59..5262237df 100755 --- a/src/scitex/types/__init__.py +++ b/src/scitex/types/__init__.py @@ -1,20 +1,21 @@ -#!/usr/bin/env python3 -"""SciTeX types module — delegates to scitex-types.""" +"""SciTeX types — thin compatibility shim for scitex-types. -from scitex_types import ( - ArrayLike, - ColorLike, - is_array_like, - is_list_of_type, - is_listed_X, -) +Aliases ``scitex.types`` to the standalone ``scitex_types`` package via +``sys.modules`` so ``scitex.types is scitex_types`` and any new public name +added to scitex_types is automatically visible. -__all__ = [ - "ArrayLike", - "ColorLike", - "is_array_like", - "is_list_of_type", - "is_listed_X", -] +Install: ``pip install scitex-types``. +See: https://github.com/ywatanabe1989/scitex-types +""" -# EOF +import sys as _sys + +try: + import scitex_types as _real +except ImportError as _e: # pragma: no cover + raise ImportError( + "scitex.types requires the 'scitex-types' package. " + "Install with: pip install scitex-types" + ) from _e + +_sys.modules[__name__] = _real