nerdvegas / rez-shotgun

Rez extension for Shotgun Toolkit
Apache License 2.0
22 stars 5 forks source link

SUGGESTION: Tying into tk-multi-launchapp's {version} substitution to help resolve rez package version(s) #4

Closed sreenathan-nair closed 4 years ago

sreenathan-nair commented 4 years ago

Hi,

First off, thank you very much for all your work and sharing this! It has been very helpful.

I wanted to give a suggestion regarding having multiple version definitions in a single launchapp block. (I apologize if the feature is already in the works, just thought I'll mention my findings here).

I had a situation where multiple versions of Maya needed to be configured where the only variable was the version while all dependencies remained the same. Rather than duplicating the launchapp block I hooked into the versions key available in launchapp to define this, like so:

settings.tk-multi-launchapp.maya:
  engine: tk-maya
  versions:
    - "2020.2"
    - "2020.0"
  extra:
    rez:
      packages:
        - "maya-{version}"
        # My plugin(s) contain variant definitions for each maya version and therefore resolve appropriately
        # - <plugin>-<plugin_version>
      parent_variables:
        - PYTHONPATH
        - MAYA_MODULE_PATH
        - MAYA_SCRIPT_PATH
  menu_name: "Maya {version}"
  group: "Maya"
  location: "@apps.tk-multi-launchapp.location"
  hook_app_launch: "{config}/tk-multi-launchapp/rez_app_launch.py"
  linux_path: "maya"
  mac_path: "Maya.app"
  windows_path: "maya.exe"

In order to make this work, I had to slightly alter: this

to

rez_packages = [package.format(version=version) for package in rez_info.get("packages", [])]

This allowed the code to resolve the package version, based on the version argument passed to the hook.

Thanks again!

j0yu commented 4 years ago

Nice suggestion, I'll add it in!