Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable environment variable behaviors. #1923

Open
herronelou opened this issue Mar 2, 2025 · 1 comment
Open

Configurable environment variable behaviors. #1923

herronelou opened this issue Mar 2, 2025 · 1 comment

Comments

@herronelou
Copy link
Contributor

Currently, rez has two ways to consider env variables: path or not paths.

When an env variable is a path, it will handle slashes and separators a specific way based on the shell used:
https://rez.readthedocs.io/en/stable/package_commands.html#filepaths
https://rez.readthedocs.io/en/stable/configuring_rez.html#pathed_env_vars

def _is_pathed_key(cls, key):

value = self.escape_string(value, is_path=self._is_pathed_key(key))

The current way to configure this is a bit limited, there is no way to exclude any pattern from the global config, nor is there a way to configure a specific pathsep or slash direction for a specific env variable.

Motivation
Some DCCs/apps expect certain conventions that do not always match the OS or the shell's defaults, and being able to configure those would be helpful.
We currently sometimes have to go around rez to make sure some environment variables are set the right way.

Possible implementations
I didn't fully think this through but have 2 examples:

This could be implemented at a global config level, with a mapping of certain env vars and the settings they should use, for example:

env_vars_settings = {
    'HOUDINI_PACKAGE_DIR' : {
        'is_path' = True,
        'list_sparator': ';',
        'path_separator': 'default'
    }
}

Cons: Possibly a lot to configure, possible ambiguity between config and shell plugins.

Another way could be to allow setting it in the packages directly:

env.HOUDINI_PACKAGE_DIR.set_path_separator('/')
env.MYENVPATH.set_is_path(False)

Pros: Pretty granular, less package-specific definitions at the global level
Cons: Can get pretty verbose, what should happen is multiple packages try to configure the same env variable differently?

Related Issues/PRs

@herronelou
Copy link
Contributor Author

Of course right after posting I find this very similar issue: #737

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant