diff --git a/Install.py b/Install.py index 15f575f..53aa307 100644 --- a/Install.py +++ b/Install.py @@ -31,7 +31,7 @@ except ImportError: from scripts.config.data import ( TOOL_NAME, TOOL_VERSION, TOOL_AUTHOR, TOOL_LANG, - TOOL_WSCL_NAME, TOOL_HELP_URL, ROOT_PATH, SCRIPTS_PATH, + TOOL_WSCL_NAME, TOOL_HELP_URL, TOOL_PATH, SCRIPTS_PATH, ICONS_PATH, STYLES_PATH, DNA_FILE_PATH, DNA_IMG_PATH, PLUGIN_PATH, PYDNA_PATH, DNACALIB_PATH, BUILDER_PATH, DNALIB_PATH, UI_PATH, UTILS_PATH, TOOL_MAIN_SCRIPT, @@ -56,9 +56,9 @@ def get_script_path(): except: return os.getcwd() -ROOT_PATH = get_script_path() -if ROOT_PATH not in sys.path: - sys.path.insert(0, ROOT_PATH) +TOOL_PATH = get_script_path() +if TOOL_PATH not in sys.path: + sys.path.insert(0, TOOL_PATH) #===================================== 3. Utility Functions ===================================== @@ -234,7 +234,7 @@ class InstallDialog(QtWidgets.QDialog): def create_mod_file(self): """Create or update the .mod file for Maya""" modules_dir = get_maya_modules_dir() - mod_content = f"""+ {TOOL_NAME} {TOOL_VERSION} {ROOT_PATH} + mod_content = f"""+ {TOOL_NAME} {TOOL_VERSION} {TOOL_PATH} scripts: {SCRIPTS_PATH} """ mod_file_path = os.path.join(modules_dir, TOOL_MOD_FILENAME) @@ -330,6 +330,9 @@ class InstallDialog(QtWidgets.QDialog): return f""" import sys import os +TOOL_PATH = r'{TOOL_PATH}' +if TOOL_PATH not in sys.path: + sys.path.insert(0, TOOL_PATH) SCRIPTS_PATH = r'{SCRIPTS_PATH}' if SCRIPTS_PATH not in sys.path: sys.path.insert(0, SCRIPTS_PATH) @@ -339,9 +342,9 @@ try: {TOOL_NAME}.show() except ImportError as e: print("Error importing {TOOL_NAME}:", str(e)) - print("Scripts path:", SCRIPTS_PATH) + print("Scripts path:", {SCRIPTS_PATH}) print("sys.path:", sys.path) - print("Contents of Scripts folder:", os.listdir(SCRIPTS_PATH)) + print("Contents of Scripts folder:", os.listdir({SCRIPTS_PATH})) """ def uninstall_tool(self): @@ -435,7 +438,7 @@ except ImportError as e: def _validate_paths(self): """Validate all required paths exist""" paths = { - "Root": ROOT_PATH, + "Root": TOOL_PATH, "Scripts": SCRIPTS_PATH, "Icons": ICONS_PATH } diff --git a/__pycache__/Install.cpython-39.pyc b/__pycache__/Install.cpython-39.pyc deleted file mode 100644 index 866665a..0000000 Binary files a/__pycache__/Install.cpython-39.pyc and /dev/null differ diff --git a/scripts/MetaFusion.py b/scripts/MetaFusion.py index f30e5fd..3509624 100644 --- a/scripts/MetaFusion.py +++ b/scripts/MetaFusion.py @@ -34,7 +34,7 @@ except ImportError: from scripts.config.data import ( TOOL_NAME, TOOL_VERSION, TOOL_AUTHOR, TOOL_LANG, - TOOL_WSCL_NAME, TOOL_HELP_URL, ROOT_PATH, SCRIPTS_PATH, + TOOL_WSCL_NAME, TOOL_HELP_URL, TOOL_PATH, SCRIPTS_PATH, ICONS_PATH, STYLES_PATH, DNA_FILE_PATH, DNA_IMG_PATH, PLUGIN_PATH, PYDNA_PATH, DNACALIB_PATH, BUILDER_PATH, DNALIB_PATH, UI_PATH, UTILS_PATH, TOOL_MAIN_SCRIPT, diff --git a/scripts/__pycache__/__init__.cpython-39.pyc b/scripts/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 214e193..0000000 Binary files a/scripts/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/scripts/config/__pycache__/__init__.cpython-39.pyc b/scripts/config/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 748d792..0000000 Binary files a/scripts/config/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/scripts/config/__pycache__/data.cpython-39.pyc b/scripts/config/__pycache__/data.cpython-39.pyc deleted file mode 100644 index 75dbc30..0000000 Binary files a/scripts/config/__pycache__/data.cpython-39.pyc and /dev/null differ diff --git a/scripts/config/data.py b/scripts/config/data.py index bc70370..6c85c05 100644 --- a/scripts/config/data.py +++ b/scripts/config/data.py @@ -14,11 +14,11 @@ TOOL_WSCL_NAME = str(f"{TOOL_NAME}WorkSpaceControl") TOOL_HELP_URL = str(f"https://gitea.cgnico.com/CGNICO/{TOOL_NAME}/wiki") # BASE_PATH -ROOT_PATH = str(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))).replace("\\", "/")) -SCRIPTS_PATH = str(os.path.join(ROOT_PATH, "scripts").replace("\\", "/")) +TOOL_PATH = str(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))).replace("\\", "/")) +SCRIPTS_PATH = str(os.path.join(TOOL_PATH, "scripts").replace("\\", "/")) # 资源路径 -RESOURCES_PATH = str(os.path.join(ROOT_PATH, "resources").replace("\\", "/")) +RESOURCES_PATH = str(os.path.join(TOOL_PATH, "resources").replace("\\", "/")) ICONS_PATH = str(os.path.join(RESOURCES_PATH, "icons").replace("\\", "/")) STYLES_PATH = str(os.path.join(RESOURCES_PATH, "styles").replace("\\", "/")) DNA_FILE_PATH = str(os.path.join(RESOURCES_PATH, "dna").replace("\\", "/")) @@ -46,11 +46,11 @@ PYTHON_VERSION_MAP = { PYTHON_VERSION_DIR = str(PYTHON_VERSION_MAP.get(version_tuple, "python3")) # PATHS -PLUGIN_PATH = str(os.path.join(ROOT_PATH, "plugins", SYSTEM_OS, MAYA_VERSION).replace("\\", "/")) -PYDNA_PATH = str(os.path.join(ROOT_PATH, "plugins", SYSTEM_OS, "pydna", PYTHON_VERSION_DIR).replace("\\", "/")) +PLUGIN_PATH = str(os.path.join(TOOL_PATH, "plugins", SYSTEM_OS, MAYA_VERSION).replace("\\", "/")) +PYDNA_PATH = str(os.path.join(TOOL_PATH, "plugins", SYSTEM_OS, "pydna", PYTHON_VERSION_DIR).replace("\\", "/")) # TOOLS_PATH -DNACALIB_PATH = str(os.path.join(ROOT_PATH, "dnacalib").replace("\\", "/")) +DNACALIB_PATH = str(os.path.join(TOOL_PATH, "dnacalib").replace("\\", "/")) BUILDER_PATH = str(os.path.join(SCRIPTS_PATH, "builder").replace("\\", "/")) DNALIB_PATH = str(os.path.join(SCRIPTS_PATH, "dnalib").replace("\\", "/")) UI_PATH = str(os.path.join(SCRIPTS_PATH, "ui").replace("\\", "/")) @@ -65,7 +65,7 @@ TOOL_MOD_FILENAME = str(f"{TOOL_NAME}.mod") if __name__ == "__main__": validate_paths = { - ROOT_PATH, + TOOL_PATH, SCRIPTS_PATH, ICONS_PATH, STYLES_PATH, @@ -91,7 +91,7 @@ if __name__ == "__main__": print(f"TOOL_WSCL_NAME: {TOOL_WSCL_NAME}") print(f"TOOL_HELP_URL: {TOOL_HELP_URL}") - print(f"ROOT_PATH: {ROOT_PATH}") + print(f"TOOL_PATH: {TOOL_PATH}") print(f"SCRIPTS_PATH: {SCRIPTS_PATH}") print(f"ICONS_PATH: {ICONS_PATH}") print(f"STYLES_PATH: {STYLES_PATH}")