Skip to content

Commit

Permalink
Avoid showing new windows on Windows (#1929)
Browse files Browse the repository at this point in the history
Signed-off-by: Bernat Gabor <[email protected]>
  • Loading branch information
gaborbernat authored Aug 31, 2020
1 parent 6c098d8 commit dc5eb79
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/changelog/1928.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid spawning new windows when doing seed package upgrades in the background on Windows - by :user:`gaborbernat`.
4 changes: 2 additions & 2 deletions src/virtualenv/seed/wheels/periodic_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from virtualenv.app_data import AppDataDiskFolder
from virtualenv.info import PY2
from virtualenv.util.path import Path
from virtualenv.util.subprocess import DETACHED_PROCESS, Popen
from virtualenv.util.subprocess import CREATE_NO_WINDOW, Popen

from ..wheels.embed import BUNDLE_SUPPORT
from ..wheels.util import Wheel
Expand Down Expand Up @@ -186,7 +186,7 @@ def trigger_update(distribution, for_py_version, wheel, search_dirs, app_data, p
pipe = None if debug else subprocess.PIPE
kwargs = {"stdout": pipe, "stderr": pipe}
if not debug and sys.platform == "win32":
kwargs["creationflags"] = DETACHED_PROCESS
kwargs["creationflags"] = CREATE_NO_WINDOW
process = Popen(cmd, **kwargs)
logging.info(
"triggered periodic upgrade of %s%s (for python %s) via background process having PID %d",
Expand Down
4 changes: 2 additions & 2 deletions src/virtualenv/util/subprocess/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Popen = subprocess.Popen


DETACHED_PROCESS = 0x00000008
CREATE_NO_WINDOW = 0x80000000


def run_cmd(cmd):
Expand All @@ -32,5 +32,5 @@ def run_cmd(cmd):
"subprocess",
"Popen",
"run_cmd",
"DETACHED_PROCESS",
"CREATE_NO_WINDOW",
)
4 changes: 2 additions & 2 deletions tests/unit/seed/wheels/test_periodic_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
trigger_update,
)
from virtualenv.util.path import Path
from virtualenv.util.subprocess import DETACHED_PROCESS
from virtualenv.util.subprocess import CREATE_NO_WINDOW


@pytest.fixture(autouse=True)
Expand Down Expand Up @@ -224,7 +224,7 @@ def test_trigger_update_no_debug(for_py_version, session_app_data, tmp_path, moc
assert args == ([sys.executable, "-c", cmd],)
expected = {"stdout": subprocess.PIPE, "stderr": subprocess.PIPE}
if sys.platform == "win32":
expected["creationflags"] = DETACHED_PROCESS
expected["creationflags"] = CREATE_NO_WINDOW
assert kwargs == expected
assert process.communicate.call_count == 0

Expand Down

0 comments on commit dc5eb79

Please sign in to comment.