Skip to content
Open
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
1 change: 1 addition & 0 deletions src/rez/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ def _parse_env_var(self, value):
"debug_memcache": Bool,
"debug_resolve_memcache": Bool,
"debug_context_tracking": Bool,
"debug_shell_startup": Bool,
"debug_all": Bool,
"debug_none": Bool,
"quiet": Bool,
Expand Down
6 changes: 5 additions & 1 deletion src/rez/resolved_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from rez.utils.data_utils import deep_del
from rez.utils.filesystem import TempDirs, is_subdirectory, canonical_path
from rez.utils.memcached import pool_memcached_connections
from rez.utils.logging_ import print_error, print_warning
from rez.utils.logging_ import print_debug, print_error, print_warning
from rez.utils.which import which
from rez.rex import RexExecutor, Python, OutputStyle, literal
from rez.rex_bindings import VersionBinding, VariantBinding, \
Expand Down Expand Up @@ -1454,6 +1454,10 @@ def execute_shell(self, shell=None, parent_environ=None, rcfile=None,

# write out the native context file
context_code = executor.get_output()

if config.debug("shell_startup"):
print_debug("Writing context to %s" % context_file)

with open(context_file, 'w', encoding="utf-8") as f:
f.write(context_code)

Expand Down
3 changes: 3 additions & 0 deletions src/rez/rezconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,9 @@
# Print debugging info when an AMPQ server is used in context tracking
debug_context_tracking = False

# Print debugging info related to shell startup
debug_shell_startup = False

# Turn on all debugging messages
debug_all = False

Expand Down
16 changes: 15 additions & 1 deletion src/rez/shells.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from rez.rex import RexExecutor, ActionInterpreter, OutputStyle
from rez.util import shlex_join, is_non_string_iterable
from rez.utils.which import which
from rez.utils.logging_ import print_warning
from rez.utils.logging_ import print_debug, print_warning
from rez.utils.execution import Popen
from rez.system import system
from rez.exceptions import RezSystemError
Expand Down Expand Up @@ -404,6 +404,10 @@ def _record_shell(ex, files, bind_rez=True, print_msg=False):
def _write_shell(ex, filename):
code = ex.get_output()
target_file = os.path.join(tmpdir, filename)

if config.debug("shell_startup"):
print_debug("Writing shell script to %s" % target_file)

with open(target_file, 'w') as f:
f.write(code)
return target_file
Expand Down Expand Up @@ -467,6 +471,9 @@ def _create_ex():
print_msg=bind_rez)
_write_shell(ex, os.path.basename(file_))

if config.debug("shell_startup"):
print_debug("Setting $HOME for new shell to %s" % tmpdir)

executor.setenv("HOME", tmpdir)

# keep history
Expand All @@ -489,6 +496,10 @@ def _create_ex():

code = executor.get_output()
target_file = os.path.join(tmpdir, "rez-shell.%s" % self.file_extension())

if config.debug("shell_startup"):
print_debug("Writing rez-shell to %s" % target_file)

with open(target_file, 'w') as f:
f.write(code)

Expand All @@ -503,6 +514,9 @@ def _create_ex():
cmd = pre_command
cmd.extend([self.executable, target_file])

if config.debug("shell_startup"):
print_debug("Launching shell with command: %s" % self.join(cmd))

try:
p = Popen(cmd, env=env, **Popen_args)
except Exception as e:
Expand Down
7 changes: 7 additions & 0 deletions src/rezplugins/shell/_utils/powershell_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from rez.utils.platform_ import platform_
from rez.utils.execution import Popen
from rez.util import shlex_join
from rez.utils.logging_ import print_debug
from .windows import get_syspaths_from_registry, to_windows_path


Expand Down Expand Up @@ -173,6 +174,9 @@ def _record_shell(ex, files, bind_rez=True, print_msg=False):
target_file = os.path.join(tmpdir,
"rez-shell.%s" % self.file_extension())

if config.debug("shell_startup"):
print_debug("Writing shell script to %s" % target_file)

with open(target_file, 'w') as f:
f.write(code)

Expand Down Expand Up @@ -200,6 +204,9 @@ def _record_shell(ex, files, bind_rez=True, print_msg=False):
if shell_command is None:
cmd.insert(1, "-NoExit")

if config.debug("shell_startup"):
print_debug("Launching shell with command: %s" % self.join(cmd))

p = Popen(cmd, env=env, **Popen_args)
return p

Expand Down
7 changes: 7 additions & 0 deletions src/rezplugins/shell/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from rez.system import system
from rez.utils.execution import Popen
from rez.utils.platform_ import platform_
from rez.utils.logging_ import print_debug
from ._utils.windows import to_windows_path, get_syspaths_from_registry
from functools import partial
import os
Expand Down Expand Up @@ -172,6 +173,9 @@ def _create_ex():
target_file = os.path.join(tmpdir, "rez-shell.%s"
% self.file_extension())

if config.debug("shell_startup"):
print_debug("Writing shell script to %s" % target_file)

with open(target_file, 'w') as f:
f.write(code)

Expand All @@ -193,6 +197,9 @@ def _create_ex():
else:
cmd_flags = ['/Q', '/C']

if config.debug("shell_startup"):
print_debug("Launching shell with command: %s" % self.join(cmd))

cmd += [self.executable]
cmd += cmd_flags
cmd += ['call {}'.format(target_file)]
Expand Down
Loading