Skip to content

Prevent showing cmd on Windows and using pythonw.exe (pythonw.exe -m ruff) #107

@dalthviz

Description

@dalthviz

As part of adding support for ruff on Spyder, I stumbled with a couple of issues on Windows (spyder-ide/spyder#24970). Seems like on Windows a cmd is shown everytime a run_ruff call is done. Checking, seems like doing the following changes prevent any cmd appereance on Windows:

  • Pass the CREATE_NO_WINDOW flag in the Popen call. So changing:

p = Popen(cmd, stdin=PIPE, stdout=PIPE)

To be something like (including adding the new import for CREATE_NO_WINDOW)

    p = Popen(cmd, stdin=PIPE, stdout=PIPE, creationflags=CREATE_NO_WINDOW) 
  • Ensure python.exe usage (instead of for example pythonw.exe) when running ruff as a module. So changing:

cmd = [sys.executable, "-m", "ruff"]

To be

    cmd = [sys.executable.replace("pythonw", "python"), "-m", "ruff"]

Let me know if the above makes sense and I will submit a PR with the changes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions