Open
Description
Describe the Bug
I encountered an issue when building p11-kit on Windows. The build process fails due to an empty header file being generated.
Upon investigation, it seems that writing to a file object without using a with outfile:
context manager does not work with meson runpython
on Windows.
To Reproduce
This issue can be reproduced by building p11-kit
on Windows, or by running the following example header generator:
# file: writefile.py
import argparse
def write(outfile):
outfile.write("Done")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--outfile", type=argparse.FileType("w"), default="foo.txt")
args = parser.parse_args()
write(args.outfile)
-
On Windows:
- Running
python writefile.py
correctly writes "Done" tofoo.txt
. - Running
meson runpython writefile.py
results in an emptyfoo.txt
.
- Running
-
On Linux:
- Both methods work as expected, writing "Done" to
foo.txt
.
- Both methods work as expected, writing "Done" to
Expected Behavior
Aligning the behavior with direct Python execution would be beneficial. This would allow scripts to function as expected on Windows.
System Parameters
- Native build
- Windows 10
- Python 3.13.2
- Meson 1.7.1
- Ninja 1.12.1
Metadata
Metadata
Assignees
Labels
No labels