Does anyone have an example of using REZ's Python API? I looked around for documentation, and took a look through this google group, but the only thing I have found is this:
]$ rez-bind rez
created package 'rez-2.0.0' in /home/ajohns/packages
# Now we can resolve a rez environment, and use the API
]$ rez-env rez -- python -c 'import rez; print rez.__version__'
2.0.0
.. which worked for me, and I have started looking through the REZ source code to find which methods I could be using, but I also thought I'd describe the process I am trying to implement and see if anyone has done something similar (or if its even possible)
I have a stand alone python module that I would like to import other python modules into. I would like to use REZ to create a context for those imports, without launching the initial context with the command line tools.
Typically I would do something like:
]$ rez-env cool_module-2.0 -- run_this_command
or
]$ rez-env cool_module-3.0 -- python
>>>from cool_module import coolness
but, in this case, I would like to be able to do the rez-env call from within the python script, without having to launch the python script initially within a REZ context. Is that something that is possible? Something like this:
rez-env rez -- python
>>> import rez
>>> ctx = rez.get_context('cool_module-2+')
>>> ctx.run_pacakge_commands()
>>> from cool_module import coolness
I'm not sure how that would work if the rez-context I requested had a requirement conflict with the version of Python I happened to be running - Maybe that would just return an error of some sort: "unable to resolve requested context" ..
Thanks for any help, I'm open to suggestions of different approaches to this problem as well!
Seth