Optimize Path Handling to Improve Code Compatibility and Maintainability#377
Merged
chflame163 merged 2 commits intochflame163:mainfrom Oct 29, 2024
Merged
Optimize Path Handling to Improve Code Compatibility and Maintainability#377chflame163 merged 2 commits intochflame163:mainfrom
chflame163 merged 2 commits intochflame163:mainfrom
Conversation
Owner
|
Thanks for your work |
siyonomicon
pushed a commit
to siyonomicon/ComfyUI_LayerStyle
that referenced
this pull request
Feb 15, 2026
Optimize Path Handling to Improve Code Compatibility and Maintainability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
优化路径处理逻辑,提升代码兼容性和可维护性
问题背景
在使用 ComfyUI-to-Python-Extension 导出工作流为 Python 代码时发现,导出的代码无法正确执行。原因是原有代码通过
__main__计算 extensions 路径,这种方式依赖于执行文件的位置。当导出的 Python 文件在其他位置运行时,就会计算出错误的路径。改动内容
folder_paths模块替代自定义路径计算__main__的依赖,改用folder_paths.base_path获取根路径os.makedirs提供更可靠的目录创建改进优势
测试验证
简单但前瞻性的改动,既解决当前问题,又为未来扩展打好基础。
Optimize Path Handling to Improve Code Compatibility and Maintainability
Background
Issue discovered when using ComfyUI-to-Python-Extension to export workflows as Python code. The original code calculates extensions path via
__main__, which depends on execution file location. This causes path resolution errors when exported Python files are run from different locations.Changes
folder_pathsmodule__main__dependency, usefolder_paths.base_pathfor root path resolutionos.makedirsfor more reliable handlingBenefits
Testing
A simple yet forward-looking change that not only solves current issues but also lays groundwork for future extensibility.