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

added bundle support for a post_commands.py file #1073

Merged
merged 1 commit into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions src/rez/resolved_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1408,11 +1408,14 @@ def execute_shell(self, shell=None, parent_environ=None, rcfile=None,

self._execute(executor)

executor.env.REZ_SHELL_INIT_TIMESTAMP = str(int(time.time()))
executor.env.REZ_SHELL_INTERACTIVE = "1" if command is None else "0"

if post_actions_callback:
header_comment(executor, "post-actions-callback")
post_actions_callback(executor)

executor.env.REZ_SHELL_INIT_TIMESTAMP = str(int(time.time()))
executor.env.REZ_SHELL_INTERACTIVE = "1" if command is None else "0"
self._execute_bundle_post_actions_callback(executor)

# write out the native context file
context_code = executor.get_output()
Expand Down Expand Up @@ -1693,6 +1696,31 @@ def _print_version(value):

return r

def _execute_bundle_post_actions_callback(self, executor):
"""
In bundles, you can drop a 'post_commands.py' file (rex) alongside the
'bundle.yaml' file, and it will be sourced after all package commands.
"""
if not self.load_path:
return

with self._detect_bundle(self.load_path):
bundle_dir = self._get_bundle_path()

if not bundle_dir:
return

rex_filepath = os.path.join(bundle_dir, "post_commands.py")
if not os.path.exists(rex_filepath):
return

# load the rex code an execute it within the executor
with open(rex_filepath) as f:
rex_py = f.read()

header_comment(executor, "bundle post-commands")
executor.execute_code(rex_py)

@classmethod
@contextmanager
def _detect_bundle(cls, path):
Expand Down
2 changes: 1 addition & 1 deletion src/rez/utils/_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


# Update this value to version up Rez. Do not place anything else in this file.
_rez_version = "2.86.1"
_rez_version = "2.87.0"


# Copyright 2013-2016 Allan Johns.
Expand Down