Houdini Packages, Subprocess, and duplicate env vars

   2407   5   1
User Avatar
Member
5 posts
Joined: Sept. 2011
Offline
I have an issue and I'm curious if any of you have any solutions. I've set some environment variables via a package located in a custom directory set via HOUDINI_PACAGE_DIR. When I run Houdini the variable load find and there are no issues. However, for purposes of publishing on a pipeline, I am using subprocess within a python script to copy, open, and execute some rops within a hip files. The strange thing is, the values of the env vars I've set within that package are doubled or a copy of that values is appended. MYENV1 would normally have a values of "C:/Users/me/some/path". When accessed from within a Houdini hip file opened via subprocess it has a value of "C:/Users/me/some/path;C:/Users/me/some/path". Additionally, this behavior does not happen if I set the environment variables via houdini.env.

I'm not sure how to prevent this from happening. Any thoughts?

Here's the simple package json I was using:
{
    "enable": false,
    "env": [
        {
            "MYENV1": [
                {
                    "houdini_os == 'windows'": "C:/Users/me/some/path"
                },
                {
                    "houdini_os == 'macos'": "/Users/me/some/path"
                }
            ]
        },
        {
            "MYENV2": [
                {
                    "houdini_os == 'windows'": "C:/Users/me/some/other/path"
                },
                {
                    "houdini_os == 'macos'": "/Users/me/some/other/path"
                }
            ]
        }
    ]
}
User Avatar
Member
9237 posts
Joined: July 2007
Online
It theoretically makes sense, if you are spawning a subprocess in an environment that already has that variable, packages prepend paths by default so you may end up with duplicate path

Maybe try using
"method" : "replace"

Or there is also
"load_package_once" : true
Which I don't know if would work for nested calls but worth a try
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
5 posts
Joined: Sept. 2011
Offline
It's strange. I've tried setting both of these in my package and I'm still getting a double loading of the environment variables.
User Avatar
Member
9237 posts
Joined: July 2007
Online
plobnop
It's strange. I've tried setting both of these in my package and I'm still getting a double loading of the environment variables.
"method" is per variable setting, make sure it's specified in correct places in your json according to https://www.sidefx.com/docs/houdini/ref/plugins.html [www.sidefx.com]
but again there may also be other causes for your issue
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
5 posts
Joined: Sept. 2011
Offline
Thanks for the link tamte. I've been using the info on that page for all along. I'm beginning to wonder if this is a bug. If I remove the houdini_os expression I no longer get a duplication of my env var values. Either this is a bug or I'm still not getting the syntax correct in my package.

WORKS (does not duplicate var value):
{
    "enable": true,
    "load_package_once": true,
    "env": [
        {
            "var": "MYENVVAR1",
            "value": "C:/Users/me/some/path",
            "method": "replace"
        },
        {
            "var": "MYENVVAR2",
            "value": "C:/Users/me/some/other/path",
            "method": "replace"
        }
    ]
}
os.environ result:
MYENVVAR1:C:/Users/me/some/path
MYENVVAR2:C:/Users/me/some/other/path
Does NOT work (duplicates var value):
{
    "enable": true,
    "load_package_once": true,
    "env": [
        {
            "var": "MYENVVAR1",
            "value": [
                {
                    "houdini_os == 'windows'": "C:/Users/me/some/path",
                    "method": "replace"
                },
            ]
        },
        {
            "var": "MYENVVAR2",
            "value": [
                {
                    "houdini_os == 'windows'": "C:/Users/me/some/other/path",
                    "method": "replace"
                },
            ]
        }
    ]
}
os.environ result:
MYENVVAR1:C:/Users/me/some/path;C:/Users/me/some/path
MYENVVAR2:C:/Users/me/some/other/path;C:/Users/me/some/other/path
User Avatar
Staff
450 posts
Joined: Feb. 2018
Offline
Try setting HOUDINI_PACKAGE_SKIP=1 before launching your process, this will disable the package processing and will prevent the subprocess to duplicate the env vars.
  • Quick Links