Skip to content

Commit

Permalink
Allows to have main program file in a directory. Fixes spine-tools/Sp…
Browse files Browse the repository at this point in the history
  • Loading branch information
jkiviluo committed Dec 1, 2024
1 parent eb224ab commit 72a7ce2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions spine_items/tool/tool_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,13 @@ def make_python_basic_console_commands(self, cmdline_args):
list: List of commands for the Python Basic Console
"""
commands = []
fp = self.tool_specification.main_prgm
fp = self.tool_specification.main_prgm.replace(os.sep, "/")
full_fp = os.path.join(self.basedir, self.tool_specification.main_prgm).replace(os.sep, "/")
commandline_args = [full_fp] + cmdline_args
fmt_cmdline_args = '["' + escape_backward_slashes('", "'.join(commandline_args)) + '"]'
commands.append(f"import sys; sys.argv = {fmt_cmdline_args};")
commands.append(f"import os; os.chdir({repr(self.basedir)})")
basedir = self.basedir.replace(os.sep, "/")
commands.append(f"import os; os.chdir({repr(basedir)})")
commands += self._make_exec_code(fp, full_fp)
return commands

Expand Down

0 comments on commit 72a7ce2

Please sign in to comment.