Distributing Multi-File Modules

All but the simplest of Maya add-ons involve more than one file. For example, a fully implemented render utility node will have at least three files:

Each of these files must go into a different directory on the target system. Even with just three files, having the user or site-administrator install them separately, by hand, can be an unwanted burden, and that burden will only grow with the number of files involved, as will opportunities for mistakes.

To simplify multi-file distribution, Maya provides the ability to package them into modules.

About modules

A module consists of a root directory which contains a module description file and the following sub-directories:

When creating the module you place your icons in the icons subdirectory, your C++ and Python plug-ins in the plug-ins subdirectory, your presets in the presets subdirectory (same structure as Maya's presets directory) and your MEL and Python scripts in the scripts subdirectory.

You can override any of these directory structures in the module description file by using the following syntax: <folder to override>:<new location for this folder>. See Module folder structure for more information.

In the module's root directory, place a copy of the module description file with the fourth field set to a suggested path. Distribution simply involves providing the user with a copy of the directory tree, possibly in compressed form.

Module description file

The module description file contains a single line of text with four base fields, separated by blanks:

For example, if version 1.3 of myModule is installed in /opt/MyCompany/myModule, then the module file would contain the following line of text.

+ myModule 1.3 /opt/MyCompany/myModule

Conditions can also be added before the module name, for example:

+ (Conditions ) “moduleName” “moduleVersion” “moduleLocation”

The conditions can be one of the following.

See Specifying the conditions for loading the module for more information.

Installing the module

Individual users wishing to install the module would do the following:

  1. Uncompress the distribution, if necessary.
  2. Move or copy the module's entire directory tree to wherever they want to keep it.
  3. Change the fourth field of the module description file to contain the full path to the module's directory tree.
  4. Place a copy of the modified module description file into one of the directories in their MAYA_MODULE_PATH environment variable.

Site administrators wishing to install a common copy of the module for multiple users would follow a similar set of steps:

  1. Uncompress the distribution, if necessary.
  2. Move or copy the module's entire directory tree to a directory which is accessible to all users, such as a network drive.
  3. Change the fourth field of the module description file to contain the full path to the module's directory tree.
  4. Place a copy of the modified module description file into a common directory which all users have in their MAYA_MODULE_PATH environment variables.

There are three approaches to doing this which are identical to those discussed for the MAYA_PLUG_IN_PATH variable in Distributing individual files.

When Maya starts up, it will read in the module description file and add the module's icons directory to its XBMLANGPATH, add the module's plug-ins directory to its MAYA_PLUG_IN_PATH, add the module's presets directory to its MAYA_PRESET_PATH and add the module's scripts directory to its MAYA_SCRIPT_PATH and PYTHON_PATH.

NOTE:

MAYA_MODULE_PATH defines the search paths for Maya module files. To see what directories this environment variable is set to, use the getenv command in the Maya Script Editor or Maya command line as follows:

getenv MAYA_MODULE_PATH

You can also set this environment variable to a directory of your choice. To do so, you must create a Maya.env file.

For more information about the Maya.env file, including the location to which it should be saved on each platform, see Setting environment variables using Maya.env.

For more information about these environment variables, see the File path variables topic in the Maya User Guide.