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

[foxy] Support scoping environment variables (#601) #630

Merged
merged 1 commit into from
Jul 25, 2022

Conversation

jacobperron
Copy link
Member

@jacobperron jacobperron commented Jul 22, 2022

Backport #601 to Foxy.

Resolves ros2/ros2#1244

This is a partial backport, since Foxy does not support the forwarding option of GroupAction. Therefore, we're not actually using the new ResetEnvironment action, but I don't think it hurts to include it here in case users want to leverage it.

* Support scoping environment variables

Resolves #597

Wherever actions were previously using os.environ, now get environment variables from the launch
context. There are a few exceptions where os.environ is still used since a launch context is not
available (e.g. logging directory and overriding launch process output).

Maintain a stack of environment variables in the launch context, similar to launch configurations.
Add new actions PushEnvironment and PopEnvironment to interact with the stack.
Push and pop the environment inside the GroupAction to support scoping.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Reset environment in GroupAction

Add a new ResetEnvironment action that sets the contexts environment
back to it's initial state (os.environ).

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Operate directly on os.environ

Rather than keeping a copy of os.environ that entities must operate on, instead operate directly on os.environ.
This way if any Python interacting with the launch API also modifies os.environ, it should work as they expect.
Also keeps the behavior backwards compatible.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron
Copy link
Member Author

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

Copy link
Member

@audrow audrow left a comment

Choose a reason for hiding this comment

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

Looks good with green CI.

@jacobperron
Copy link
Member Author

jacobperron commented Jul 25, 2022

Windows: Build Status

Warnings and test failure are preexisting.

@jacobperron jacobperron merged commit aabc241 into foxy Jul 25, 2022
@delete-merged-branch delete-merged-branch bot deleted the jacob/backport_601 branch July 25, 2022 22:06
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.

2 participants