Skip to content

Commit dc5eb79

Browse files
authored
Avoid showing new windows on Windows (#1929)
Signed-off-by: Bernat Gabor <[email protected]>
1 parent 6c098d8 commit dc5eb79

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

docs/changelog/1928.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Avoid spawning new windows when doing seed package upgrades in the background on Windows - by :user:`gaborbernat`.

src/virtualenv/seed/wheels/periodic_update.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from virtualenv.app_data import AppDataDiskFolder
2323
from virtualenv.info import PY2
2424
from virtualenv.util.path import Path
25-
from virtualenv.util.subprocess import DETACHED_PROCESS, Popen
25+
from virtualenv.util.subprocess import CREATE_NO_WINDOW, Popen
2626

2727
from ..wheels.embed import BUNDLE_SUPPORT
2828
from ..wheels.util import Wheel
@@ -186,7 +186,7 @@ def trigger_update(distribution, for_py_version, wheel, search_dirs, app_data, p
186186
pipe = None if debug else subprocess.PIPE
187187
kwargs = {"stdout": pipe, "stderr": pipe}
188188
if not debug and sys.platform == "win32":
189-
kwargs["creationflags"] = DETACHED_PROCESS
189+
kwargs["creationflags"] = CREATE_NO_WINDOW
190190
process = Popen(cmd, **kwargs)
191191
logging.info(
192192
"triggered periodic upgrade of %s%s (for python %s) via background process having PID %d",

src/virtualenv/util/subprocess/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
Popen = subprocess.Popen
1414

1515

16-
DETACHED_PROCESS = 0x00000008
16+
CREATE_NO_WINDOW = 0x80000000
1717

1818

1919
def run_cmd(cmd):
@@ -32,5 +32,5 @@ def run_cmd(cmd):
3232
"subprocess",
3333
"Popen",
3434
"run_cmd",
35-
"DETACHED_PROCESS",
35+
"CREATE_NO_WINDOW",
3636
)

tests/unit/seed/wheels/test_periodic_update.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
trigger_update,
3030
)
3131
from virtualenv.util.path import Path
32-
from virtualenv.util.subprocess import DETACHED_PROCESS
32+
from virtualenv.util.subprocess import CREATE_NO_WINDOW
3333

3434

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

0 commit comments

Comments
 (0)