Merge pull request #1572 from pbrod/Fix_issue1571

Fixes issue 1571:
This commit is contained in:
Robin Dunn
2020-03-23 16:07:22 -07:00
committed by GitHub
38 changed files with 230 additions and 266 deletions

View File

@@ -91,8 +91,8 @@ def getWxRelease(wxRoot=None):
if not wxRoot:
global wxRootDir
wxRoot = wxRootDir
configureText = open(os.path.join(wxRoot, "configure.in"), "r").read()
with open(os.path.join(wxRoot, "configure.in"), "r") as fid:
configureText = fid.read()
majorVersion = re.search("wx_major_version_number=(\d+)", configureText).group(1)
minorVersion = re.search("wx_minor_version_number=(\d+)", configureText).group(1)
@@ -592,9 +592,8 @@ def main(wxDir, args):
for include in glob.glob(header_dir + "/*.h"):
headers += "#include <wx/" + os.path.basename(include) + ">\n"
framework_header = open("%s.h" % fwname, "w")
framework_header.write(header_template % headers)
framework_header.close()
with open("%s.h" % fwname, "w") as framework_header:
framework_header.write(header_template % headers)
run("ln -s -f %s wx" % header_dir)
os.chdir("wx-%s/wx" % version)

View File

@@ -349,10 +349,9 @@ class Configuration(object):
# then the version number is built without a revision number. IOW, it
# is a release build. (In theory)
if os.path.exists('REV.txt'):
f = open('REV.txt')
self.VER_FLAGS += f.read().strip()
with open('REV.txt') as f:
self.VER_FLAGS += f.read().strip()
self.BUILD_TYPE = 'snapshot'
f.close()
elif os.environ.get('WXPYTHON_RELEASE') == 'yes':
self.BUILD_TYPE = 'release'
else:
@@ -676,10 +675,11 @@ def _getSbfValue(etg, keyName):
cfg = Config()
sbf = opj(cfg.SIPOUT, etg.NAME + '.sbf')
out = list()
for line in open(sbf):
key, value = line.split('=')
if key.strip() == keyName:
return sorted([opj(cfg.SIPOUT, v) for v in value.strip().split()])
with open(sbf) as fid:
for line in fid:
key, value = line.split('=')
if key.strip() == keyName:
return sorted([opj(cfg.SIPOUT, v) for v in value.strip().split()])
return None
def getEtgSipCppFiles(etg):
@@ -748,16 +748,14 @@ def writeIfChanged(filename, text):
"""
if os.path.exists(filename):
f = textfile_open(filename, 'rt')
current = f.read()
f.close()
with textfile_open(filename, 'rt') as f:
current = f.read()
if current == text:
return
f = textfile_open(filename, 'wt')
f.write(text)
f.close()
with textfile_open(filename, 'wt') as f:
f.write(text)
# TODO: we might be able to get rid of this when the install code is updated...

View File

@@ -72,7 +72,8 @@ class build_ext (build_ext_base):
def _sip_calc_signature(self):
sip_bin = self._find_sip()
return sha1(open(sip_bin, "rb").read()).hexdigest()
with open(sip_bin, "rb") as fid:
return sha1(fid.read()).hexdigest()
def _sip_signature_file(self):
return os.path.join(self._sip_output_dir(), "sip.signature")
@@ -90,7 +91,8 @@ class build_ext (build_ext_base):
if not os.path.isfile(sigfile):
self.force = True
else:
old_sig = open(sigfile).read()
with open(sigfile) as fid:
old_sig = fid.read()
new_sig = self._sip_calc_signature()
if old_sig != new_sig:
self.force = True
@@ -136,7 +138,8 @@ class build_ext (build_ext_base):
sbf = os.path.join(self._sip_output_dir(), replace_suffix(sipbasename, ".sbf"))
if newer_group([sip]+depends, sbf) or self.force:
self._sip_compile(sip_bin, sip, sbf)
open(self._sip_signature_file(), "w").write(self._sip_calc_signature())
with open(self._sip_signature_file(), "w") as f_out:
f_out.write(self._sip_calc_signature())
out = self._get_sip_output_list(sbf)
generated_sources.extend(out)