1- # deep_reloader
1+ # deep_reloader
2+
3+ [ 日本語版] ( docs/README.ja.md ) | [ 中文版] ( docs/README.zh-CN.md )
24
35> [ !WARNING]
4- > このソフトウェアは現在プレリリース版です。APIが変更される可能性があります。
6+ > This software is currently in pre-release. The API may change.
57
6- Pythonモジュールの依存関係を解析して、再帰的にリロードを行うライブラリです。特にMayaでのスクリプト開発時に、モジュール変更を即座に反映させるために設計されています。
8+ A Python library that analyzes module dependencies and performs recursive reloading. Designed specifically for Maya script development to instantly reflect module changes.
79
8- ## 機能
10+ ## Features
911
10- - ** 深いリロード ** : 深い階層でもリロードが可能
11- - ** AST解析 ** : 静的解析により from-import文 を正確に検出
12- - ** ワイルドカード対応 ** : ` from module import * ` もサポート
13- - ** 相対インポート対応 ** : パッケージ内の相対インポートを正しく処理
14- - ** 循環参照対応 ** : Pythonで動作する循環インポートを正しくリロード
12+ - ** Deep Reload ** : Reloads modules at any depth level
13+ - ** AST Analysis ** : Accurately detects from-import statements through static analysis
14+ - ** Wildcard Support ** : Supports ` from module import * `
15+ - ** Relative Import Support ** : Properly handles relative imports within packages
16+ - ** Circular Import Support ** : Correctly reloads circular imports that work in Python
1517
16- ## インストール
18+ ## Installation
1719
18- Pythonパスが通っている場所であればどこでも配置可能です。
19- 本READMEでは一般的なMayaのscriptsフォルダーを例として説明します。
20+ The package can be placed anywhere in the Python path.
21+ This README uses Maya's common scripts folder as an example.
2022
2123```
22- ~/Documents/maya/scripts/ (例 )
24+ ~/Documents/maya/scripts/ (example )
2325└── deep_reloader/
2426 ├── __init__.py
2527 ├── _metadata.py
@@ -33,145 +35,145 @@ Pythonパスが通っている場所であればどこでも配置可能です
3335 └── tests/
3436```
3537
36- ## 使用方法
38+ ## Usage
3739
38- ### 基本的な使用方法
40+ ### Basic Usage
3941
4042``` python
41- # 最もシンプルな使用例
43+ # Simplest usage example
4244from deep_reloader import deep_reload
4345deep_reload(your_module)
4446```
4547
46- ### ログ設定
48+ ### Logging Configuration
4749
48- 開発時やデバッグ時には、詳細なログ出力を有効にできます:
50+ For development or debugging, you can enable detailed log output:
4951
5052``` python
5153from deep_reloader import deep_reload, setup_logging
5254import logging
5355
54- # ログレベルを設定(すべてのdeep_reloaderログに影響)
55- logger = setup_logging(logging.DEBUG ) # 詳細なデバッグ情報
56+ # Set log level (affects all deep_reloader logs)
57+ logger = setup_logging(logging.DEBUG ) # Detailed debug information
5658
57- # 返されたロガーを使って直接ログ出力も可能
58- logger.info(" deep_reloaderのログ設定が完了しました " )
59+ # You can also use the returned logger for direct logging
60+ logger.info(" deep_reloader logging configured " )
5961
60- # その後、通常通り使用
62+ # Then use normally
6163deep_reload(your_module)
6264```
6365
64- ** ログレベルの説明 :**
65- - ` logging.DEBUG ` : pycacheクリアなどの詳細情報も表示
66- - ` logging.INFO ` : モジュールリロードの状況を表示(デフォルト)
67- - ` logging.WARNING ` : エラーと警告のみ表示
66+ ** Log Level Descriptions :**
67+ - ` logging.DEBUG ` : Shows detailed information including pycache clearing
68+ - ` logging.INFO ` : Shows module reload status (default)
69+ - ` logging.WARNING ` : Shows only errors and warnings
6870
69- ## テスト実行
71+ ## Running Tests
7072
71- ** 注意: テストはpytestで実行してください。Maya内部での実行はサポートしていません。 **
73+ ** Note: Tests must be run with pytest. Running within Maya is not supported. **
7274
73- このプロジェクトのテストはpytest専用です。開発環境でpytestを使用してテストを実行してください。
75+ Tests for this project are pytest-only. Run tests using pytest in your development environment.
7476
7577``` shell
76- # リポジトリルートに移動(例)
78+ # Navigate to repository root (example)
7779cd ~ /Documents/maya/scripts/deep_reloader
7880
79- # 全テスト実行
81+ # Run all tests
8082pytest tests/ -v
8183
82- # 特定のテストファイル実行
84+ # Run specific test file
8385pytest tests/integration/test_absolute_import.py -v
8486
85- # より詳細な出力
87+ # More detailed output
8688pytest tests/ -vv
8789
88- # 簡潔な出力
90+ # Concise output
8991pytest tests/ -q
9092```
9193
92- ### 動作確認済み環境
94+ ### Verified Environment
9395
94- ** テスト開発環境(Maya以外) :**
95- - Python 3.11.9+(現在の開発環境で検証済み)
96- - pytest 8.4.2+(テスト実行に必須)
96+ ** Test Development Environment (Non-Maya) :**
97+ - Python 3.11.9+ (verified in current development environment)
98+ - pytest 8.4.2+ (required for running tests)
9799
98- ** 注意 ** : 上記はライブラリのテスト・開発で使用している環境です。Maya内での実行環境とは異なります。Mayaのサポートバージョンはまだ確定していません。
100+ ** Note ** : The above is the environment used for library testing and development. It differs from the Maya execution environment. Supported Maya versions are not yet finalized.
99101
100- ## 制限事項・既知の問題
102+ ## Limitations and Known Issues
101103
102- ### isinstance()の失敗(Python言語仕様の制約)
104+ ### isinstance() Failure (Python Language Constraint)
103105
104- リロード前に作成したインスタンスは、リロード後のクラスで ` isinstance() ` が失敗します。これはPython言語仕様の制約であり、すべてのリロードシステムが抱える共通の問題です。
106+ Instances created before reload will fail ` isinstance() ` checks with the reloaded class. This is a constraint of the Python language specification and a common issue with all reload systems.
105107
106- ** 原因 ** : リロード後、クラスオブジェクトのIDが変わるため。
108+ ** Cause ** : After reload, the class object ID changes.
107109
108- ** 例 ** :
110+ ** Example ** :
109111``` python
110- # リロード前
112+ # Before reload
111113my_class = MyClass()
112114isinstance (my_class, MyClass) # True
113115
114- deep_reload(MyClass) # リロード
116+ deep_reload(MyClass) # Reload
115117
116- isinstance (my_class, MyClass) # False(my_classは古いMyClassのインスタンス、MyClassは新しいクラス)
118+ isinstance (my_class, MyClass) # False (my_class is an instance of old MyClass, MyClass is the new class)
117119```
118120
119- ** 回避策 ** :
120- - リロード後にインスタンスを再作成する
121- - クラス名での文字列比較を使用する( ` type(my_class).__name__ == 'MyClass' ` )
122- - Mayaを再起動する
121+ ** Workarounds ** :
122+ - Recreate instances after reload
123+ - Use string comparison with class name ( ` type(my_class).__name__ == 'MyClass' ` )
124+ - Restart Maya
123125
124- ### import文非対応(仕様)
126+ ### import Statement Not Supported (By Design)
125127
126- ` import xxx ` 形式の依存関係は対応していません。
128+ ` import xxx ` style dependencies are not supported.
127129
128- ** 理由 ** : リロード時に親モジュールへ自動追加された属性を復元する処理が複雑になるため。
130+ ** Reason ** : Restoring attributes automatically added to parent modules during reload adds complexity.
129131
130- ** 対応形式 ** : from-import形式のみ
131- - ` from xxx import yyy ` 形式
132- - ` from .xxx import yyy ` 形式
133- - ` from . import yyy ` 形式
132+ ** Supported Forms ** : from-import only
133+ - ` from xxx import yyy ` style
134+ - ` from .xxx import yyy ` style
135+ - ` from . import yyy ` style
134136
135- ### 単一パッケージのみリロード(仕様)
137+ ### Single Package Reload Only (By Design)
136138
137- ` deep_reload() ` は、渡されたモジュールと同じパッケージに属するモジュールのみをリロードします。
139+ ` deep_reload() ` only reloads modules that belong to the same package as the passed module.
138140
139- ** 理由 ** : 組み込みモジュール( ` sys ` 等)やサードパーティライブラリ( ` maya.cmds ` , ` PySide2 ` 等)のリロードを防ぎ、システムの安定性を保つため。
141+ ** Reason ** : Prevents reloading of built-in modules ( ` sys ` , etc.) and third-party libraries ( ` maya.cmds ` , ` PySide2 ` , etc.) to maintain system stability.
140142
141- ** 例 ** : ` deep_reload(myutils) ` を実行すると、 ` myutils ` が属するパッケージのモジュールがリロード対象になります。
143+ ** Example ** : Running ` deep_reload(myutils) ` will reload only modules in the package that ` myutils ` belongs to.
142144
143- ** 複数の自作パッケージを開発している場合 ** :
144- パッケージ間に依存関係がある場合、正常にリロードできない可能性があります。基本的には単一パッケージを使用することを推奨します。
145- どうしても必要な場合は、依存関係の順序を考慮して複数回 ` deep_reload() ` を呼び出してください。
145+ ** When developing multiple custom packages ** :
146+ If there are dependencies between packages, reloading may not work correctly. It is recommended to use a single package.
147+ If absolutely necessary, call ` deep_reload() ` multiple times considering dependency order.
146148``` python
147- # 複数のパッケージでリロードしたい場合(非推奨)
149+ # When you need to reload multiple packages (not recommended)
148150deep_reload(myutils)
149151deep_reload(mytools)
150152```
151153
152- ### パッケージ構造が必須(仕様)
154+ ### Package Structure Required (By Design)
153155
154- ` deep_reload() ` はパッケージ化されたモジュールのみをサポートします。
156+ ` deep_reload() ` only supports packaged modules.
155157
156- ** 理由 ** : 単体モジュールでは、標準ライブラリとユーザーコードの区別ができず、システムモジュールを誤ってリロードする危険性があるため。
158+ ** Reason ** : Standalone modules cannot distinguish between standard library and user code, risking accidental system module reloads.
157159
158- ** 非対応 ** : 単体の ` .py ` ファイル(例: ` ~/maya/scripts/my_tool.py ` )
160+ ** Not Supported ** : Standalone ` .py ` files (e.g., ` ~/maya/scripts/my_tool.py ` )
159161
160- ** 単体モジュールの場合 ** : 標準の ` importlib.reload() ` を使用してください。
162+ ** For standalone modules ** : Use standard ` importlib.reload() ` .
161163
162- ** 複数モジュールを使用する場合 ** : パッケージ化してください( ` __init__.py ` を含むディレクトリ構造を推奨)。
164+ ** When using multiple modules ** : Package them (directory structure with ` __init__.py ` recommended).
163165
164- ## リリース状況
166+ ## Release Status
165167
166- - ✅ コア機能実装完了( from-import対応)
167- - ✅ テストスイート
168- - ✅ ドキュメント整備
169- - ✅ Maya環境での動作検証
170- - ✅ 循環インポート対応
171- - 🔄 APIの安定化作業中
172- - 📋 デバッグログの強化
173- - 📋 パフォーマンス最適化とキャッシュ機能
168+ - ✅ Core functionality complete ( from-import support)
169+ - ✅ Test suite
170+ - ✅ Documentation
171+ - ✅ Maya environment verification
172+ - ✅ Circular import support
173+ - 🔄 API stabilization in progress
174+ - 📋 Enhanced debug logging
175+ - 📋 Performance optimization and caching
174176
175- ## ライセンス
177+ ## License
176178
177- MIT License - 詳細は [ LICENSE] ( LICENSE ) ファイルを参照してください。
179+ MIT License - See [ LICENSE] ( LICENSE ) file for details.
0 commit comments