Houdini 17.5 Reference

Houdini Packages

How to write and combine multiple environment variable definition files for different plug-ins, tools, and add-ons.

On this page

Overview

Traditionally, the way to set the values of environment variables in Houdini was to edit the houdini.env file. The most important variable to set up is the $HOUDINI_PATH, which tells Houdini where to look for files such as assets. You can also create convenience variables (for example $TEXTURE_DIR) and edit system variables (such as the binary search path $PATH).

The problem is that not only the user wants to set environment variables, but also studios, plug-in authors, and so on. Multiple parties would end up rewriting or appending to the houdini.env file, sometimes causing errors or redundancy.

Also, you might want variables defined some times and not others (for example, switching between project-specific paths, or turning "experimental" assets on and off).

The new solution for this kind of set-up is packages. Packages are .json files in HOUDINI_PATH/packages. Each package file contains a specification for how to modify the environment (including the Houdini Path and other variables).

You can then have separate packages for:

  • Studio variables.

  • Project variables.

  • User variables.

  • Variables for each separate plug-in, tool, or add-on.

The file format supports a small expression language to allow some automation. With expressions you can, for example:

  • Enable/disable a tool installation or specify what package(s) are required by a tool.

  • Write generic package files.

  • Write a single package to manage a multi-platform setup.

  • Set variables conditionally with simple operators, Houdini keywords and environment variables.

This removes the need to edit houdini.env.

Using package files

  • Package files must be valid JSON and must have the .json extension.

  • Houdini will scan the following directories on startup (if they exist) for package files:

    • $HOUDINI_USER_PREF_DIR/packages

    • $HFS/packages

    • $HSITE/houdinimajor.minor/packages (for example, $HSITE/houdini18.0/packages)

    • $HOUDINI_PACKAGE_DIR

      Houdini will process the package files directly in $HOUDINI_PACKAGE_DIR, do not add a packages directory under $HOUDINI_PACKAGE_DIR.

      $HSITE must be set to an existing directory before starting Houdini.

  • Houdini process files it finds first in the directory order above, then within each directory alphabetically by file name.

  • You can have multiple package files in each packages directory on the above path.

  • Houdini does not scan subdirectories inside packages.

Writing the package file

Manipulating the Houdini Path

To...Do this

Prepend a new directory to the Houdini Path

{
    "path" : "/user/bob/libs"
}

The path top-level key is a convenience for manipulating the $HOUDINI_PATH variable. See also how to set arbitrary environment variables below.

Prepend multiple directories to the Houdini Path

{
    "path" : [
        "/user/bob/libs",
        "/user/tom/libs",
        "/user/sam/libs"
    ]
}

Edit the value of a variable using the method and value keys

New path elements are prepended by default.

In places where you would use a string value to prepend to the path, you can replace it with a JSON object containing a value key with the value of the new path element, and a method key specifying how to modify the variable’s current value.

The value for method can be prepend (the default, add new element(s) at the start of the existing path), append (add new element(s) at the end of the existing path), or replace (clear the previous value and set the variable to the new value).

To append one element and prepend two others to the Houdini Path:

{
    "path" : 
    [
        {
            "value" : "/user/bob/libs",
            "method" : "append"
        },
        "/user/tom/libs",
        "/user/sam/libs"
    ]
}

To overwrite the previous Houdini Path with a new path:

{
    "path" : 
    [
        {        
            "value" : 
                [
                    "/user/bob/libs",
                    "/user/tom/libs",
                    "/user/sam/libs"
                ],
            "method" : "replace"
        }
    ]
}

Specify that the package file depends on another package file.

If you use a recommends key and the other package file is not found, Houdini displays a warning but still processes this package file.

{
    "recommends" : "package_name",
    "path" : "/user/bob/libs"
}

If you use requires and the other package file is not found, Houdini displays an error and does not process this package file.

{
    "requires" : ["package1","package2"],
    "path" : "/user/bob/libs"
}

The value of either key can be a package name string or an array of package name strings.

Add or don’t add a path element based on an expression

In places where you would use a string value, you can replace it with a JSON object where instead of value, the key is a simple expression, and the value is the path element value to use if the expression evaluates to true.

{
    "path" : 
        [
            {"houdini_os != 'windows'" : "/user/bob/libs"},
            {"houdini_os == 'windows'" : "$HOME/bob_win_libs"},
            {"$use_tom_libs == '1'" : "$HOME/tom_libs"}
        ]
}

See package expressions below.

Mark a package as "not enabled" so Houdini ignores it

The the enable top-level key:

{
    "enable" : false,
    "path" : "/user/bob/libs"
}

Instead of a boolean, the value of the enable key can be a string containing an expression:

{
    "enable": "houdini_os == 'linux'"
}

If you want to reverse the meaning of the expression, you can make it generate the value false instead of the default true:

{
    "enable": { "houdini_os == 'linux'": false }
}

Set arbitrary environment variables

To...Do this

Set/modify an environment variable

The top-level key env lets you set environment variable values. You can create custom variables, and set the system PATH and the Houdini path variables as well.

  • The value of the env key is a JSON array.

  • The array can contain JSON Objects where the keys are environment variable names (without the $ prefix), and the values are string values to use to set/modify the value.

  • Unlike under the path key, under env the default is to set a variable, rather than prepend to a path.

  • Where you would use a string value, you can replace it with a JSON object specifying a method, and a value or expression. See package expressions below for more information.

The following prepends $HOME/bob_tool to the $BOB environment variable, and manipulates the $HOUDINI_PATH variable directly instead of using the path top-level key as documented above.

{
    "requires" : ["package1","package2"],
    "env": [
        {
            "BOB": "$HOME/bob_tool"
        },
        {
            "HOUDINI_PATH" :
            [
                "$BOB/libs",
                {
                    "houdini_version>'17.5' and houdini_version<'17.5.250'": "$BOB/test",
                    "method": "append"
                }
            ]
        }
    ]
}

You can also use an alternate syntax for defining environment variables using the reserved keys var and value:

{
    "requires" : ["package1","package2"],
    "env": [
        {
            "var": "BOB",
            "value": "$HOME/bob_tool"
        },
        {
            "var": "HOUDINI_PATH",
            "value": [
                "$BOB/libs",
                {
                    "houdini_version>'17.5' and houdini_version<'17.5.250'": "$BOB/test2",
                    "method": "append"
                }
            ]
        }
    ]
}

Relative path variables

To...Do this

Set environment variable relative to the package

The $HOUDINI_PACKAGE_PATH variable let you identify the current package path in your variable value.

For instance, given this package file /home/user/bob/packages/bob.json

{
    "env": [
        {
            "HOUDINI_PATH": "$HOUDINI_PACKAGE_PATH/../tools"
        }
    ]
}

Houdini will resolve HOUDINI_PATH as

HOUDINI_PATH := '/home/user/bob/packages/../tools;&'

Warning

. and .. are used to make paths relative to the Houdini current working folder. They cannot be used to make paths relative to the current package path.

Examples

Path

Simple append

{
    "path": "$HOME/bob_tool/libs"
}

Add multiple paths

{
    "path": ["$HOME/bob_tool/libs", "$HOME/bob_tool/test"]
}

With expression

{
    "path": {"houdini_os == 'windows'": "$HOME/bob_tool/libs"}
}

Env

Define multiple environment variables

{
    "env" : 
    [
        {
            "BOB" : "$HOME/bob_tool"
        },
        {
            "TOM" : "$HOME/tom_tool"
        }
    ]
}

Use expressions

{
    "env": [
        {
            "QUAD_LIBS": 
            { 
                "houdini_version > '17.0' and houdini_version < '17.5'" : "$HOME/quad_libs"
            }
        }
    ]
}

Use expressions with environment variables

{
    "env": [
        { "SERVER1": { " $MY_SERVER_SETUP == 'ICARUS' ": "/servers/icarus" } },
        { "SERVER2": { " $MY_SERVER_SETUP == 'MERCURY' ": "/servers/mercury" } }
    ]
}   

Create and reuse variables

{
    "env" : 
    [
        {
            "BOB" : "$HOME/bob_tool"
        },
        {
            "BOB_TEST" : "$BOB/test"
        }
    ]
}

Prepend path to HOUDINI_PATH

{
    "env" : 
    [
        {
            "HOUDINI_PATH" : "$HOME/bob_tool"
        }
    ]
}

Append path to HOUDINI_PATH

{
    "env" : 
    [
        {
            "HOUDINI_PATH" : 
            {
                "value": "$HOME/bob_tool",
                "method": "append"
            }
        }
    ]
}

Replace HOUDINI_PATH

{
    "env" : 
    [
        {
            "HOUDINI_PATH" :
            {
                "value": 
                [
                    "$HOME/bob_tool",
                    "$HOME/tom_tool"
                ],
                "method": "replace"
            }
        }
    ]
}

Multiple variables

{
    "env": 
    [
        {
            "BOB" : "$HOME/bob_tool"
        },
        {
            "HOUDINI_PATH" :
            {
                "value": 
                [
                    "$BOB/libs",
                    {
                        "houdini_version>'17.5' and houdini_version<'17.5.250'": "$BOB/test",
                        "method": "append"
                    }
                ]
            }
        }
    ]
}

Modify system PATH

{
    "env" : 
    [
        {
            "PATH" :
            { 
                "value": 
                [
                    "$HOME/bob_tool",
                    {
                        "value": "$HOME/tom_tool",
                        "method": "append"
                    }
                ]
            }
        }
    ]
}

Recommends/requires

Display warning if bob_tool package is missing

{
    "recommends": "bob_tool"
}

Multiple dependencies

{
    "recommends": [ "bob_tool", "tom_tool" ]
}

Conditional dependency

{
    "recommends": { "houdini_version > '17.0'": "sam_tool" }
}

Display error if bob_tool package is missing

{
    "requires": "bob_tool"
}

Multiple requirements

{
    "requires": [ "bob_tool", "tom_tool" ]
}

Conditional requirement

{
    "requires": { "houdini_version > '17.0'": "sam_tool" }
}

Package Expressions

Expressions can be used for setting package variables conditionally. The grammar supports boolean expressions defined with the following set of comparison and logical operators.

  • The expression can use the following operators: (, ), ==, !=, <, >, <=, >=, and, or.

  • You can establish precedence using brackets (). Otherwise and and or have higher precedence, and the comparison operators all have the same lower precedence.

  • You can compare with a literal string by enclosing the string in single quotes.

    'This is a valid string'
    
  • You can use environment variables in a comparison by prefixing the variable name with $.

    $MY_VAR == '/var/tmp'
    $HOME == '/user/bob'
    
  • You can use the following "keywords" as part of a comparison:

    houdini_version

    The current Houdini version (full version path).

    houdini_os

    The OS platform ('windows', 'linux', 'macos')

  • The expression language supports string values only. Other types may be supported in the future for new identifiers.

Examples

"houdini_version == '16.5'"

"houdini_version == '16.5' and houdini_os=='linux'"

"houdini_version => '16.5' and houdini_version < '17.5'"

"houdini_os != 'windows' or houdini_version == '17.5' or houdini_version == '17.5.56'"

"(houdini_os != 'macos') or (houdini_version >= '17.4' and houdini_version <= '17.5')"

"houdini_os == 'windows' and houdini_version >= '17.5' and $USE_XYZ == 'TRUE'"

Tips

  • You can quickly display the contents and order of the Houdini Path in Houdini’s Python shell by calling hou.houdiniPath().

  • You can define a variable earlier in the array and then use that variable in a value later in the array. Make sure the variables are defined before they are used.

  • Houdini sets the environment variables are set by Houdini after it has processed all packages, so custom variables defined in one package are not available for use in other packages.

  • Environment variables you set in these files only affect the Houdini process (for example, they do not affect the shell if you launch Houdini from a command line).

Reference

User interface

  • Menus

    Explains each of the items in the main menus.

  • Viewers

    Viewer pane types.

  • Panes

    Documents the options in various panes.

  • Windows

    Documents the options in various user interface windows.

Programming

  • Expression functions

    Expression functions let you compute the value of parameters.

  • Expression cookbook

    Tips and tricks for writing expressions to accomplish various effects.

  • Python Scripting

    How to script Houdini using Python and the Houdini Object Model.

  • VEX

    VEX is a high-performance expression language used in many places in Houdini, such as writing shaders.

  • HScript commands

    HScript is Houdini’s legacy scripting language.

Command line

Guru level

Plugin installation

  • Houdini Packages

    How to write and combine multiple environment variable definition files for different plug-ins, tools, and add-ons.