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

[Feature] Additional tools to Path #661

Conversation

bfloch
Copy link
Contributor

@bfloch bfloch commented Jul 11, 2019

Implements #660.

  • Backwards compatible
  • Unit tests

Compatibility

  1. It is fully backwards compatible. A new config variable is introduced, that defaults to current behavior replace
  2. Reuses the standard_system_paths variable usage
  3. External shell plugins will not be affected but can remove the rezconfig logic and have to decorate get_syspaths with syspaths_composer to make use of the new feature.

What do we gain?

  • Ability to prepend / append paths to shell's syspath as opposed to only replacing it. Compare [Feature] Additional tools to add to PATH #660
  • Removed control logic of standard_system_paths out of plugin implementation into central decorator syspaths_composer

bfloch added 3 commits July 11, 2019 13:36
… PATH

Shells now have the option not only to replace the $PATH with
standard_system_paths, but also to append or prepend to it.
This is controlled with the new standard_system_paths_visibility config
variable that can be set to:
- replace (default)
- prepend
- append
This optimization was originally handled within the Shell, but the
dependency on configuration behaviour should not be really the
responsibility of the implementer.
Note that caching (cls.syspaths) is still responsibility of the Shell
implementation, since we shall not reason about it.
…d to PATH

Note how the config change is not part of the cache, which is what you want.
@bfloch bfloch force-pushed the feature/issue_660_additional_path branch from 210df34 to 9b05b24 Compare July 11, 2019 20:21
@bfloch
Copy link
Contributor Author

bfloch commented Jul 11, 2019

Tests passing:

@nerdvegas
Copy link
Contributor

nerdvegas commented Jul 11, 2019 via email

@bfloch
Copy link
Contributor Author

bfloch commented Jul 12, 2019

Btw. @nerdvegas:
What's the correct pattern to reset the rez.config for each test?
Currently the state is kind of bleeding-through, which is not necessarily a problem since I reset the two parameters I am interested in, but it would be great if the config was clean for each test.

@bfloch bfloch changed the title Feature/issue 660 additional path [Feature] Additional tools to Path (#660) Jul 12, 2019
@bfloch bfloch changed the title [Feature] Additional tools to Path (#660) [Feature] Additional tools to Path Jul 12, 2019
@JeanChristopheMorinPerso
Copy link
Member

What's the correct pattern to reset the rez.config for each test?

In theory, the TestBase class (which is subclassed by the TestShells class takes care of resetting the config for each test. TO change the settings, you can use self.update_settings. See https://github.com/nerdvegas/rez/blob/e1e135ad0c882b42ddedd5155e73a86ef41f8620/src/rez/tests/util.py#L61

@nerdvegas
Copy link
Contributor

Hey @bfloch this in on my radar, but I'm not sure I'll be able to get to it until after SIGGRAPH, just FYI.
Thx
A

@bfloch
Copy link
Contributor Author

bfloch commented Jul 21, 2019

No worries. I'll have it more tested next week and try to make the tests cleaner.
Have a great show.

@@ -68,14 +68,11 @@ def get_startup_sequence(cls, rcfile, norc, stdin, command):
)

@classmethod
@syspaths_composer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the functionality of syspaths_composer is fine, however I don't think it's correct for it to be a decorator like this.

The intent of Shell.get_syspaths is to define what system paths are associated with that shell - not how to then apply them. So I would just take the functionality from the decorator, and apply it only where syspaths are actually set into PATH (https://github.com/nerdvegas/rez/blob/master/src/rez/rex.py#L1124)

@nerdvegas
Copy link
Contributor

This is just a comment - much as mentioned in #698, this feature may be unnecessary when we implement better env-var management (as described in #707). I don't want to hold back this PR to wait for that, but I think it's worth noting that this could become deprecated in lieu of that at some point (which would be good, because it means less edge cases).

@@ -366,10 +366,18 @@
# scripts (such as .bashrc). If False, package commands are sourced after.
package_commands_sourced_first = True

# Defines how the standard_system_paths configuration acts on the $PATH:
# - "replace": Replace $PATH if standard_system_paths is set
# - "append": Append standard_system_paths to determined $PATH
Copy link
Contributor

@nerdvegas nerdvegas Aug 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is confusing, I think you mean:

Append 'standard_system_path' to automatically determined system paths

..right? Because the comment mentions $PATH, it's confusing because it seems like this is just getting appended to the entirety of $PATH. It's not clear that you mean the initially determined $PATH.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok ignore that, I think I have an idea on how to make this clearer. It's jut inherently a little hard to explain I think.

@@ -271,6 +278,7 @@ def _parse_env_var(self, value):
"plugin_path": PathList,
"bind_module_path": PathList,
"standard_system_paths": PathList,
"standard_system_paths_visibility": StandardPathVisibility_,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "standard_system_paths_mode" would be more intuitive.

# Defines paths to initially set $PATH to, if a resolve appends/prepends $PATH.
# If this is an empty list, then this initial value is determined automatically
# depending on the shell (for example, *nix shells create a temp clean shell and
# get $PATH from there; Windows inspects its registry).
# The way the list is combined with $PATH is controlled via
# rez_standard_system_paths_visibility.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead:

# ...$PATH from there; Windows inspects its registry).
# 
# To specify both your own systems paths, AND automatically determined system paths, use the 
# "standard_system_paths_visibility" setting. For example, setting this to "append" will initially
# set $PATH to the automated system paths, followed by the paths listed here.

@bfloch
Copy link
Contributor Author

bfloch commented Sep 6, 2019

I agree. Let's focus on #707.

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

Successfully merging this pull request may close these issues.

3 participants