简体   繁体   English

Sublime Text 3中没有新构建系统的构建时间

[英]No build time for new build system in Sublime Text 3

I successfully added python3 as a new build system as follows: 我成功地将python3添加为新的构建系统,如下所示:

{
    "cmd": ["python3", "-i", "-u", "$file"],
    "file_regex": "^[ ]File \"(...?)\", line ([0-9]*)",
    "selector": "source.python"
}

I couldn't get any build time output in python3 system but I can in other build systems. 我在python3系统中无法获得任何构建时间输出,但在其他构建系统中却可以。 Any idea would be appreciated. 任何想法将不胜感激。 Thank you. 谢谢。

The reason you don't see a build time is that you're specifying -i as an argument to python3 . 您看不到构建时间的原因是,您将-i指定为python3的参数。 That makes it interactive, but there is no way to actually provide it any input because Sublime doesn't let you interact with a running program; 这使它具有交互性,但是实际上无法提供任何输入,因为Sublime不允许您与正在运行的程序进行交互。 it just lets you start it and wait for it to finish. 它只是让您启动它并等待它完成。 As such, you're not getting any build time because the build goes on forever and never actually stops. 这样一来,您就不会获得任何构建时间,因为构建可以永久进行,并且从未真正停止。

As a verification, note that the last thing that's presented in the output panel is the >>> prompt of the interactive interpreter, where it's waiting for input that you can't provide. 作为验证,请注意,输出面板中最后显示的是交互式解释器的>>>提示,它在等待您无法提供的输入。 Additionally the Tools > Cancel Build remains available, and selecting it terminates the build (although in this case is doesn't tell you how long it was running). 此外,“ Tools > Cancel Build仍然可用,选择它会终止构建(尽管在这种情况下,它并不告诉您运行了多长时间)。 That command is disabled if there's not a build running. 如果没有构建正在运行,则该命令将被禁用。

One way to fix your problem would be to remove the -i from your cmd entry above. 解决问题的一种方法是从上面的cmd条目中删除-i Alternatively, you could use a version of the Python.sublime-build that ships with Sublime, modified to run python3 instead of python : 另外,您可以使用Sublime随附的Python.sublime-build版本,将Python.sublime-build修改为运行python3而不是python

{
    "shell_cmd": "python3 -u \"$file\"",
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",

    "env": {"PYTHONIOENCODING": "utf-8"},

    "variants":
    [
        {
            "name": "Syntax Check",
            "shell_cmd": "python3 -m py_compile \"${file}\"",
        }
    ]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM