diff options
author | Gabor Kertesz <gabor.kertesz@linaro.org> | 2021-10-19 12:08:46 +0200 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2021-10-19 09:41:17 -0400 |
commit | 747982e6cb3e83083a990b909d56e455ff1568f6 (patch) | |
tree | a0835f245302e6205ea2d981848a69d3d619b2d6 /mesonbuild/mesonlib/vsenv.py | |
parent | 492cc9bf95d573e037155b588dc5110ded4d9a35 (diff) | |
download | meson-747982e6cb3e83083a990b909d56e455ff1568f6.zip meson-747982e6cb3e83083a990b909d56e455ff1568f6.tar.gz meson-747982e6cb3e83083a990b909d56e455ff1568f6.tar.bz2 |
Fix NamedTemporaryFile file reopen issue on Win #9412
NamedTemporaryFile can't be opened by name on Windows.
For Windows the created temporary bat file is now closed before
passing to a subprocess, prevented from removal automatically upon
close and deleted explicitly upon finish.
Diffstat (limited to 'mesonbuild/mesonlib/vsenv.py')
-rw-r--r-- | mesonbuild/mesonlib/vsenv.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/mesonbuild/mesonlib/vsenv.py b/mesonbuild/mesonlib/vsenv.py index 6532970..fd1ca15 100644 --- a/mesonbuild/mesonlib/vsenv.py +++ b/mesonbuild/mesonlib/vsenv.py @@ -73,10 +73,12 @@ def _setup_vsenv(force: bool) -> bool: mlog.log('Activating VS', bat_info[0]['catalog']['productDisplayVersion']) bat_separator = '---SPLIT---' bat_contents = bat_template.format(bat_path, bat_separator) - bat_file = tempfile.NamedTemporaryFile('w', suffix='.bat', encoding='utf-8') + bat_file = tempfile.NamedTemporaryFile('w', suffix='.bat', encoding='utf-8', delete=False) bat_file.write(bat_contents) bat_file.flush() - bat_output = subprocess.check_output(str(bat_file), universal_newlines=True) + bat_file.close() + bat_output = subprocess.check_output(bat_file.name, universal_newlines=True) + os.unlink(bat_file.name) bat_lines = bat_output.split('\n') bat_separator_seen = False for bat_line in bat_lines: |