-
Notifications
You must be signed in to change notification settings - Fork 214
Description
Version: Gaffer 1.5.5.0-windows
Description
Environment variables which not in Context Variables will be convert to uppercase so that Context.substitute()
method only recognize uppercase environment variables when use gaffer env python
or gaffer dispatch
to execute some background command line task.
This is because of CPython's os.environ object will convert all env var names to uppercase on Windows platform:
CPython-3.10 os.py Line: 748
In Gaffer's app env
and dispatch
, they will use os.environ.copy()
to create an env var's dict and pass it to the subprocess.call
's env param to launch a new gaffer process, this is a gaffer env
's example:
Gaffer-main env-1.py Line: 102 and Line: 117
That will cause when I use GafferUI in foreground, I can use Context.substitute('${Path}')
to expand env var Path
normally, but in background app I must use ${PATH}
rather than ${Path}
.
This is because of the Context
instance will use a map belongs to a global Environment
instance to memorize all env vars in current process, and when a new gaffer process created, this map will be refreshed by reading env vars from the macro environ
which all env var names were overrided to uppercase by the parent process in subprocess.call
's param:
Gaffer-main Context.cpp Line: 76
In the CG industry pipeline, we use env var path to handle cross platform production requirement, for example working on Windows and submit some batch process or render job to Linux render farm. This bug will cause trouble for the above situation.
Steps to reproduce
- Launch an interactive environment by command:
gaffer env python
- Execute these command:
import Gaffer
script = Gaffer.ScriptNode()
context = script.context()
print(context.substitute('${Path}'))
print(context.substitute('${PATH}'))
print(context.substitute('${Path}'))
will return nothing butprint(context.substitute('${PATH}'))
will return the value of env varPath
on your system.- Execute these code in a foreground GafferUI's python editor,
print(context.substitute('${PATH}'))
will return nothing butprint(context.substitute('${Path}'))
will return the value of env varPath