Environment Variables¶
Since our development environment is controlled completely by passing environment variables from one process to its children, in general we allow all variables to flow freely. There are, however, a few circumstances in which we need to inhibit this flow.
Maya and Nuke, for example, add to the PYTHONHOME
, and our
launchers add to SITETOOLS_SITES
(e.g., for the app’s special flavour of
PyQt, etc.), and these changes must not propigate to child processes.
These tools allow us to manage those variables which should not propigate. In a “freeze”, the current state of given variables will be stored in the environment (for which you can provide part of the variable name). Then you can modify those variables for use, and launch the app. Upon Python startup, these tools will reset any variables which have been flagged with the default, unnamed, namespace.
Environ Variables¶
-
SITETOOLS_ENVIRON_DIFF
¶ Where the default, unnamed, freeze is stored.
Warning
Do not use this directly, as the format is subject to change without notice. Instead, use
sitecustomize.environ.freeze()
.
API Reference¶
-
sitetools.environ.
freeze
(environ, names, label=None)¶ Flag the given names to reset to their current value in the next Python.
Parameters: This is useful to reset environment variables that are set by wrapper scripts that are nessesary to bootstrap the process, but we do not want to carry into any subprocess. E.g.
LD_LIBRARY_PATH
.This may be called multiple times for the same label as it updates any existing freezes.
Usage:
import os from subprocess import call from sitecustomize.environ import freeze env = dict(os.environ) env['DEMO'] = 'one' freeze(env, ['DEMO']) env['DEMO'] = 'two' call(['python', '-c', 'import os; print os.environ["DEMO"]'], env=env) # Prints: one