From 616f65c7d68871fd1816eff231c6bf3bc8326767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sat, 8 Feb 2025 16:15:32 +0000 Subject: [PATCH] Use pathlib write_text for more situations in build.py --- build.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/build.py b/build.py index 3ea08e5c..af102d54 100755 --- a/build.py +++ b/build.py @@ -1330,10 +1330,7 @@ def cmd_sip(options, args): header = min(glob.glob('*.h')) sources = sorted(glob.glob('*.cpp')) del sip_pwd - with open(sbf, 'w') as f: - f.write("sources = {}\n".format(' '.join(sources))) - f.write("headers = {}\n".format(header)) - + Path(sbf).write_text(f"sources = {' '.join(sources)}\nheaders = {header}\n") classesNeedingClassInfo = { 'sip_corewxTreeCtrl.cpp' : 'wxTreeCtrl', } def processSrc(src, keepHashLines=False): @@ -2212,8 +2209,7 @@ def cmd_sdist(options, args): shutil.rmtree(opj(PDEST, 'docs'), ignore_errors=True) if options.nodoc: os.makedirs(opj(PDEST, 'docs')) - with open(opj(PDEST, 'docs', 'README.txt'), 'wt') as f: - f.write("The sphinx files and generated docs are not included in this archive.\n") + Path(PDEST, 'docs', 'README.txt').write_text("The sphinx files and generated docs are not included in this archive.\n") else: shutil.copytree('docs', opj(PDEST, 'docs'), ignore=shutil.ignore_patterns('html', 'build', '__pycache__', 'cpp'))