Sublime Forum

Automaticaly build a specific file per project

#1

hi,
i’m trying to have a python project in ST3, with a specific file to use, build and run, no matter which other file i’m currently editing. when i use shortcut to build, it should find specified file build and run it.
here’s what i currently have, it shows no errors, but in the same time nothing happens project does not run when i use my usual shortcut to build. (so i still need to open manualy correct file ‘main.py’ to be able to run start this app…)
what’s wrong or missing ?

{
        "folders":
    [
        {
            "path": ".",
        }
    ],
    "build_systems":
    [
        {
        "name": "main",
        "cmd": ["/usr/bin/python3", "-u", "main.py"],
        "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
        "selector": "source.python"
        }
    ]
}
0 Likes

Generate automatic projects with Sublimetext based on markdown? What do you guys think?
#2

Maybe try adding a working_dir? e.g.

    "build_systems":
    [
        {
            "name": "main",
            "cmd": ["/usr/bin/python3", "-u", "main.py"],
            "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
            "selector": "source.python",
            "working_dir": "$folder"
        }
    ]
0 Likes

#3

@rwols
thanks for the reply,
but it seems it didn’t help. still no errors, still no run.
one thing is strange though, is that when i close all st3 windows, and from file manager, i double click on my project file, it opens me 2 st3 windows.
one with my project files, and one other that is empty.
when i press my usual build shortcut, i see a message in status bar that says: ‘build finished’ but the project did not run.

0 Likes

#4

here’s my build system file:

{
    "cmd": ["/usr/bin/python3", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "quiet": true
}

if i put myself on the tab with main.py file and use my build shortcut ctrl+b,
the project runs. if i’m positioned on another tab and hit the same shortcut, nothing happens.

0 Likes

#5

ah, maybe i’ve figured it out ?
when i open a project, i must manually go to menu: tools > build system
there project have added a new build system called ‘main’ and i must manualy choose it then it works.

why opening a project do not select this automatically if it’s specified in the project file ?

0 Likes