Sublime Forum

Build System & Python Question

#1

I would like to know where I can edit the build systems? You have the Build System menu selection which then pops out a sub menu. Where can I edit that?

If I select just python out of the build system and use the command B on a Mac it displays the time to run and output. If I use the Python 3 build I get the output and >>> afterwards.

Thanks in advance.

0 Likes

#2

The contents of the build system menu is dynamically created by gathering the names of all sublime-build files that Sublime knows about; builds appear in the menu with a name that is the name of the file.

In your case that means that there is a Python.sublime-build file somewhere and Python3.sublime-build file somewhere.

Many builds are shipped with Sublime; you can’t remove or edit them, but you can add your own. Python.sublime-build comes from the Python package that ships with Sublime.

You can use View Package File and enter sublime-build to filter down to just build files, or python sublime-build to find just Python builds, etc; when you find the one you want you can select it to open it. If it’s not one that ships with Sublime you can edit the contents.

In your case, it sounds like the Python3.sublime-build file is telling Python to go interactive or is not specifying $file anywhere to tell it what to run, which is making it start interactive directly; neither will work.

In a pinch you can open up the Python.sublime-build to see what it’s doing and mimic that in yours; odds are all you need to do is copy/paste it over yours and replace python with python3 or similar.

0 Likes

#3

Maybe I’m missing something in your reply. I’m using a Mac with the latest OSX that does not include Python 2.0. So you have to install Python on your own. In sublime with out creating a new build system is it going to see Python3? and if not based on what you said above I would “NOT” be able to edit the default for a Python build system to have it call Python3 correct? If there was an alias would that work?
I like keeping everything simple and not adding / installing anything more than what I need.
Thank you

0 Likes

#4

Mac’s come with a version of Python pre-installed; the issue there is that for a long time it was Python 2, and if you wanted to use Python 3, you had to self install it and make your own build.

Newer versions of MacOS come with Python 3 out of the box, and the build system that ships with Sublime Text 4 will automatically use it.

If you’re still using Sublime Text 3, then you still need to make your own build system for this because Python 3 is installed as an executable named python3, but the build system that ships with ST3 just calls python.

Without creating a new build system or doing anything else, it’s not going to see Python 3 in a case like that. You could however make a symlink from python3 to python or whatever else you like though.

In any case, all Sublime is doing is asking your OS to execute something named either python or python3 (depending on your version of Sublime or the build you’ve created). So, you’re free to do something like install GarageBand and symlink it to the name python if you want GarageBand to execute when you try to build Python programs (or if you will, Sublime neither knows nor cares).

That said, I would point out that creating your own build system is less “installing” and more “customizing”, in the same vein as changing settings.

1 Like