The system variable is accessible to your commands() function as a global, so you could query it there.
name = "my_query"
version = "1.1.3"
build_command = False
def commands():
global system
print(system.os)
(You can skip calling global system if your linter doesn’t mind)
Results in:
$ rez build my_query
$ rez env my_query
windows-10.0.18362
You can list all available variables using locals() which at the time of this writing is:
for key in list(locals()):
print(key)
comment
version
shebang
defined
expandvars
expandable
__builtins__
system
resetenv
source
literal
setenv
env
building
appendenv
implicits
format
unsetenv
stop
getenv
base
prependenv
info
resolve
undefined
this
request
alias
command
error
root
I see that I can specify the literal string "{system.os}" in a rez configuration python file (the file reference by the $REZ_CONFIG_FILE environment variable). Is there a way I can query the expanded value of that in the configuration python code so I can manipulate it? For example, currently {system.os} will expand to CentOS-7.5. However, I want to set a my implicit_packages to request os-CentOS-7. So is there any way I can get the expanded value of system.os in the python configuration file so that I can do some python string operations on it? It's easy in a script since I can import rez.system. But I can't import rez.system in the configuration file without it going into a recursive loop. Thanks.-Brent
--
You received this message because you are subscribed to the Google Groups "rez-config" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rez-config+...@googlegroups.com.
To post to this group, send email to rez-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/rez-config.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to rez-c...@googlegroups.com.
That’s a good question; I would have thought you could import rez.system from there, but it looks like there’s some magic going on in that module to prevent that.
To unsubscribe from this group and stop receiving emails from it, send an email to rez-config+...@googlegroups.com.
implicit_packages = [
"~platform=={system.platform}",
"~arch=={system.arch}",
"~os=={system.os}",
]
import platform
if platform.linux_distribution()[1].startswith('7'):
implicit_packages.add("os-CentOS-7") # or build it with the output platform.linux_distribution() i.e ('CentOS Linux', '7.4.1708', 'Core')
--
You received this message because you are subscribed to the Google Groups "rez-config" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rez-config+...@googlegroups.com.
To post to this group, send email to rez-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/rez-config.
For more options, visit https://groups.google.com/d/optout.