Update Install.py
This commit is contained in:
parent
bca7b92fcb
commit
643ba521d8
60
Install.py
60
Install.py
@ -245,29 +245,51 @@ class InstallDialog(QtWidgets.QDialog):
|
|||||||
print("Uninstallation cancelled")
|
print("Uninstallation cancelled")
|
||||||
|
|
||||||
def create_mod_file(self):
|
def create_mod_file(self):
|
||||||
"""Create or update the .mod file for Maya"""
|
"""创建或更新Maya的.mod文件"""
|
||||||
modules_dir = get_maya_modules_dir()
|
modules_dir = get_maya_modules_dir()
|
||||||
mod_content = f"""+ {TOOL_NAME} {TOOL_VERSION} {TOOL_PATH}
|
|
||||||
scripts: {SCRIPTS_PATH}
|
|
||||||
plug-ins: plugins/{SYSTEM_OS}/{MAYA_VERSION}
|
|
||||||
XBMLANGPATH+:=resources/icons
|
|
||||||
PYTHONPATH+:=plugins/{SYSTEM_OS}/{MAYA_VERSION}
|
|
||||||
PYTHONPATH+:=plugins/{SYSTEM_OS}/{MAYA_VERSION}/pydna/{PYTHON_VERSION_DIR}
|
|
||||||
TOOL_PATH+:={TOOL_PATH}
|
|
||||||
"""
|
|
||||||
mod_file_path = os.path.join(modules_dir, TOOL_MOD_FILENAME)
|
|
||||||
self._write_mod_file(mod_file_path, mod_content)
|
|
||||||
|
|
||||||
def _write_mod_file(self, file_path, content):
|
# 获取所有Maya版本和对应的Python版本
|
||||||
"""Helper method to write .mod file"""
|
version_map = {
|
||||||
|
"2022": "python3",
|
||||||
|
"2023": "python397",
|
||||||
|
"2024": "python3108",
|
||||||
|
"2025": "python311"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 系统映射
|
||||||
|
os_paths = {
|
||||||
|
"win64": "Windows",
|
||||||
|
"linux": "Linux"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 创建mod文件内容
|
||||||
|
mod_content = f"""+ {TOOL_NAME} {TOOL_VERSION} {TOOL_PATH}
|
||||||
|
"""
|
||||||
|
|
||||||
|
# 添加每个Maya版本的配置
|
||||||
|
for maya_version, python_version in version_map.items():
|
||||||
|
# 添加每个操作系统的配置
|
||||||
|
for os_name, os_path in os_paths.items():
|
||||||
|
mod_content += f"""
|
||||||
|
if MAYA_VERSION == {maya_version} && PLATFORM == {os_name}
|
||||||
|
scripts: {SCRIPTS_PATH}
|
||||||
|
plug-ins: {os.path.join(PLUGIN_PATH, os_path)}
|
||||||
|
XBMLANGPATH+:={ICONS_PATH}
|
||||||
|
PATH+:={os.path.join(PLUGIN_PATH, os_path)}
|
||||||
|
PATH+:={os.path.join(PLUGIN_PATH, os_path, "pydna", python_version)}
|
||||||
|
PYTHONPATH+:={SCRIPTS_PATH}
|
||||||
|
PYTHONPATH+:={os.path.join(PLUGIN_PATH, os_path, "pydna", python_version)}
|
||||||
|
endif
|
||||||
|
"""
|
||||||
|
|
||||||
|
# 写入mod文件
|
||||||
|
mod_file_path = os.path.join(modules_dir, TOOL_MOD_FILENAME)
|
||||||
try:
|
try:
|
||||||
with open(file_path, "w") as f:
|
with open(mod_file_path, "w", encoding="utf-8") as f:
|
||||||
f.write(content)
|
f.write(mod_content)
|
||||||
print(f"Successfully created/updated: {file_path}")
|
print(f"Created mod file: {mod_file_path}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_msg = f"Error writing .mod file: {e}"
|
print(f"Error creating mod file {mod_file_path}: {e}")
|
||||||
print(error_msg)
|
|
||||||
QtWidgets.QMessageBox.critical(self, "Error", error_msg)
|
|
||||||
|
|
||||||
def uninstall_mod_file(self):
|
def uninstall_mod_file(self):
|
||||||
modules_dir = get_maya_modules_dir()
|
modules_dir = get_maya_modules_dir()
|
||||||
|
Loading…
Reference in New Issue
Block a user