Skip to content

Commit

Permalink
feat: Add support for the portable version of maya, which can be foun…
Browse files Browse the repository at this point in the history
…d by adding the MAYA_LOCATION environment variable.

Signed-off-by: liujingjing <[email protected]>
  • Loading branch information
liujingjing authored and yjjjj committed May 10, 2024
1 parent e2f0e58 commit c2ead6b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 23 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ MAYA_UMBRELLA_LANG
```shell
MAYA_UMBRELLA_IGNORE_BACKUP
```

如果是便携版Maya,可以通过添加 `MAYA_LOCATION` 环境变量指定路径如 `d:/your/path` 并且在 `/path/`路径下放maya版本文件夹, 比如Maya2024, Maya完整路径是 `d:/your/path/Maya2024`
```shell
SET MAYA_LOCATION=d:/your/path/
```

如果忽略请设置为
```shell
SET MAYA_UMBRELLA_IGNORE_BACKUP=true
Expand Down
57 changes: 34 additions & 23 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,36 @@

def _setup_maya(maya_version):
"""Set up the appropriate Maya version for testing."""
try:
import winreg
except ImportError:
return {}
try:
key = winreg.OpenKey(
winreg.HKEY_LOCAL_MACHINE,
f"SOFTWARE\\Autodesk\\Maya\\{maya_version}\\Setup\\InstallPath",
)
root, _ = winreg.QueryValueEx(key, "MAYA_INSTALL_LOCATION")
if not os.path.isdir(root):
print("Failed to locate the appropriate Maya path in the registration list.")
except OSError:
root = _get_registry("MAYA_INSTALL_LOCATION",
f"SOFTWARE\\Autodesk\\Maya\\{maya_version}\\Setup\\InstallPath"
)

maya_location = os.environ.get("MAYA_LOCATION", root)
if not maya_location:
print("maya not found.")
return
bin_root = os.path.join(root, "bin")

bin_root = os.path.join(maya_location, "bin")
return {"maya_root": root, "bin_root": bin_root}


def _assemble_env_paths(*paths):
return ";".join(paths)


def _get_registry(key_name, path):
try:
import winreg # noqa: F401
except ImportError:
return {}
try:
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path) as key:
value, _ = winreg.QueryValueEx(key, key_name)
return value
except WindowsError:
return None


@nox.session
def lint(session: nox.Session) -> None:
session.install("wemake-python-styleguide")
Expand Down Expand Up @@ -209,15 +217,18 @@ def dynamic_session(session: nox.Session):
# Dynamic to set up nox sessions for Maya 2018-2026.
# For example, to run tests for Maya 2018, run:
# nox -s maya-2018
for maya_version in range(2018, 2026):
maya_setup = _setup_maya(maya_version)
if maya_setup:
add_dynamic_maya_session(f"maya-{maya_version}", os.path.join(maya_setup["bin_root"], "maya.exe"))
maya_python = os.path.join(maya_setup["bin_root"], "mayapy.exe")
test_runner = os.path.join(ROOT, "tests", "_test_runner.py")
add_dynamic_maya_test_session(maya_version, maya_python, test_runner)
standalone_runner = os.path.join(ROOT, "run_maya_standalone.py")
add_dynamic_maya_standalone_session(maya_version, maya_python, standalone_runner)
parser = argparse.ArgumentParser()
parser.add_argument('-s')
args = parser.parse_args()
maya_version = "".join(filter(str.isdigit, args.s))
maya_setup = _setup_maya(maya_version)
if maya_setup:
add_dynamic_maya_session(f"maya-{maya_version}", os.path.join(maya_setup["bin_root"], "maya.exe"))
maya_python = os.path.join(maya_setup["bin_root"], "mayapy.exe")
test_runner = os.path.join(ROOT, "tests", "_test_runner.py")
add_dynamic_maya_test_session(maya_version, maya_python, test_runner)
standalone_runner = os.path.join(ROOT, "run_maya_standalone.py")
add_dynamic_maya_standalone_session(maya_version, maya_python, standalone_runner)


@nox.session(name="make-zip")
Expand Down

0 comments on commit c2ead6b

Please sign in to comment.