I have a python script that runs via rez-python. Initially, my sys.path has all the "common" paths found in my python installation like lib/python2.7/site-packages, lib/python2.7/lib-dynload, etc. However, suppose I create and apply a ResolvedContext object that doesn't load any packages that modify $PYTHONPATH. Or maybe it does modify $PYTHONPATH but none of the packages are adding things like site-packages and lib-dynload. After I apply that context, I will no longer be able to import packages like unicodedata because lib-dynload is no longer in sys.path.
I can always make a copy of sys.path before I apply the ResolvedContext and then add it back to sys.path. But that seems a bit hacky. In general, our python packages don't add their own lib/python27 directories to $PYTHONPATH since those directories will be added automatically to sys.path when someone runs the python interpreter. So requesting a python package in our ResolvedContext doesn't work. I could create a package called something like python_base_libs that adds the various lib/python subdirectories to PYTHONPATH and request that in my ResolvedContext. But I would like to know if there is a cleaner way of preserving the bundled lib directories of the interpreter being used in the python process regardless of what I do with ResolvedContext.