mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-06 12:00:13 +01:00
Python 2.7 doesn't have TemporaryDirectory
(cherry picked from commit ef81730d8a)
This commit is contained in:
7
build.py
7
build.py
@@ -43,7 +43,8 @@ from buildtools.config import Config, msg, opj, posixjoin, loadETG, etg2sip, fi
|
|||||||
phoenixDir, wxDir, copyIfNewer, copyFile, \
|
phoenixDir, wxDir, copyIfNewer, copyFile, \
|
||||||
macSetLoaderNames, \
|
macSetLoaderNames, \
|
||||||
getVcsRev, runcmd, textfile_open, getSipFiles, \
|
getVcsRev, runcmd, textfile_open, getSipFiles, \
|
||||||
getVisCVersion, getToolsPlatformName, updateLicenseFiles
|
getVisCVersion, getToolsPlatformName, updateLicenseFiles, \
|
||||||
|
TemporaryDirectory
|
||||||
|
|
||||||
import buildtools.version as version
|
import buildtools.version as version
|
||||||
|
|
||||||
@@ -890,7 +891,7 @@ def do_regenerate_sysconfig():
|
|||||||
TODO: Can this be done in a way that doesn't require overwriting a file in
|
TODO: Can this be done in a way that doesn't require overwriting a file in
|
||||||
the environment?
|
the environment?
|
||||||
"""
|
"""
|
||||||
with tempfile.TemporaryDirectory() as td:
|
with TemporaryDirectory() as td:
|
||||||
pwd = pushDir(td)
|
pwd = pushDir(td)
|
||||||
|
|
||||||
# generate a new sysconfig data file
|
# generate a new sysconfig data file
|
||||||
@@ -899,7 +900,7 @@ def do_regenerate_sysconfig():
|
|||||||
|
|
||||||
# On success the new data module will have been written to a subfolder
|
# On success the new data module will have been written to a subfolder
|
||||||
# of the current folder, which is recorded in ./pybuilddir.tx
|
# of the current folder, which is recorded in ./pybuilddir.tx
|
||||||
with open('pybuilddir.txt', 'r', encoding='utf-8') as fp:
|
with open('pybuilddir.txt', 'r') as fp:
|
||||||
pybd = fp.read()
|
pybd = fp.read()
|
||||||
|
|
||||||
# grab the file in that folder and copy it into the Python lib
|
# grab the file in that folder and copy it into the Python lib
|
||||||
|
|||||||
@@ -971,3 +971,20 @@ def updateLicenseFiles(cfg):
|
|||||||
with open('LICENSE.txt', 'w') as f:
|
with open('LICENSE.txt', 'w') as f:
|
||||||
f.write(text)
|
f.write(text)
|
||||||
|
|
||||||
|
try:
|
||||||
|
from tempfile import TemporaryDirectory
|
||||||
|
except ImportError:
|
||||||
|
from tempfile import mkdtemp
|
||||||
|
|
||||||
|
class TemporaryDirectory(object):
|
||||||
|
def __init__(self, suffix='', prefix='tmp', dir=None):
|
||||||
|
self.name = mkdtemp(suffix, prefix, dir)
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
def __exit__(self, exc, value, tb):
|
||||||
|
self.cleanup()
|
||||||
|
|
||||||
|
def cleanup(self):
|
||||||
|
shutil.rmtree(self.name)
|
||||||
|
|||||||
Reference in New Issue
Block a user