Hi,
I just loaded up ST and it asked to be upgraded. I upgraded it to the latest build 4213 and now my SublimeREPL setup no longer works. No errors, just nothing. I use the script below to launch tabs with either an interactive terminal or to run a file, both do nothing and show no errors.
Did something in the latest build finally break the abandoned SublimeREPL package? Is there a way to have these features with Terminus?
Thank you,
Gabriel
import os
import sublime_plugin
class ProjectVenvReplCommand(sublime_plugin.TextCommand):
"""
Starts a SublimeREPL, searching upward for a .venv/bin/python interpreter
from the current file's location.
"""
def run(self, edit, interactive=False, name=" "):
window = self.view.window()
for view in window.views():
if view.is_dirty() and view.file_name():
view.run_command("save")
python_path = self.get_venv_python(self.view.file_name())
print(f"Using Python interpreter: {python_path}")
if interactive is False:
# Run the current file in a REPL.
path, filename = os.path.split(self.view.file_name())
open_file = path + "/" + filename
# Execute the file and let Python terminate afterward.
# Remove the interactive flag so that the REPL is killed
cmd_list = [python_path, "-u", open_file]
else:
# Start an interactive Python REPL.
cmd_list = [python_path, "-u", "-i"]
self.repl_open(cmd_list=cmd_list, name=name)
def get_venv_python(self, start_path):
"""
Search upward from the current file's path to find .venv/bin/python.
Returns the interpreter path if found, otherwise fallback to system python.
"""
if not start_path:
return "/usr/bin/python3" # fallback
dir_path = os.path.dirname(start_path)
while dir_path != os.path.dirname(dir_path): # stop at root
candidate = os.path.join(dir_path, ".venv", "bin", "python")
if os.path.isfile(candidate) and os.access(candidate, os.X_OK):
return candidate
dir_path = os.path.dirname(dir_path)
return "/usr/bin/python3" # fallback
def repl_open(self, cmd_list, name):
"""Open a SublimeREPL using provided commands"""
self.view.window().run_command(
"repl_open",
{
"encoding": "utf8",
"type": "subprocess",
"cmd": cmd_list,
"cwd": "$file_path",
"syntax": "Packages/Python/Python.sublime-syntax",
"external_id": name,
},
)