Skip to content

Instantly share code, notes, and snippets.

@iccir
Created May 21, 2019 12:04
Show Gist options
  • Save iccir/c57016305e46be97ea3524301cad9f69 to your computer and use it in GitHub Desktop.
Save iccir/c57016305e46be97ea3524301cad9f69 to your computer and use it in GitHub Desktop.
Python 3 build system for Sublime Text 3

Python 3 Build System

This always kills the previous run. Useful when using matplotlib so you don't end up with a large number of windows.

import Default.exec
ExistingCommandMap = { }
class build_python3(Default.exec.ExecCommand):
def run(self, cmd=None, kill=False, **kwargs):
file = cmd
if file in ExistingCommandMap:
existing = ExistingCommandMap[file]
ExistingCommandMap[file] = None
try:
existing.run(kill=True)
except:
pass
if kill:
super().run(kill=True, **kwargs)
else:
ExistingCommandMap[file] = self
super().run(cmd=[ "python3", "-B", "-u", file ], **kwargs)
{
"target": "build_python3",
"cmd": "$file",
"cancel": { "kill": "true" },
"file_regex": "^[ ]File \"(...?)\", line ([0-9]*)",
"selector": "source.python"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment