Skip to content

Commit

Permalink
Merge branch 'issue_1071-bundle-post_commands'
Browse files Browse the repository at this point in the history
  • Loading branch information
ajohns committed May 10, 2021
2 parents 3f66e9c + 935ad1b commit c44e83e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
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

0 comments on commit c44e83e

Please sign in to comment.