Skip to content

Commit

Permalink
Merge pull request wxWidgets#2603 from komoto48g/py312-warn
Browse files Browse the repository at this point in the history
DeprecationWarning due to distutils
  • Loading branch information
swt2c authored Sep 13, 2024
2 parents 299dcb3 + 0da5a0b commit 99d1749
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 24 deletions.
5 changes: 4 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@
except ImportError:
from buildtools.backports.shutil_which import which

try:
from setuptools.modified import newer, newer_group
except ImportError:
from distutils.dep_util import newer, newer_group

from distutils.dep_util import newer, newer_group
from buildtools.config import Config, msg, opj, posixjoin, loadETG, etg2sip, findCmd, \
phoenixDir, wxDir, copyIfNewer, copyFile, \
macSetLoaderNames, \
Expand Down
47 changes: 25 additions & 22 deletions buildtools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@

from distutils.file_util import copy_file
from distutils.dir_util import mkpath
from distutils.dep_util import newer
try:
from setuptools.modified import newer
except ImportError:
from distutils.dep_util import newer

import distutils.sysconfig

Expand Down Expand Up @@ -907,29 +910,29 @@ def runcmd(cmd, getOutput=False, echoCmd=True, fatal=True, onError=None):
otherKwArgs = dict(stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)

sp = subprocess.Popen(cmd, shell=True, env=os.environ, **otherKwArgs)
with subprocess.Popen(cmd, shell=True, env=os.environ, **otherKwArgs) as sp:

output = None
if getOutput:
outputEncoding = 'cp1252' if sys.platform == 'win32' else 'utf-8'
output = sp.stdout.read()
if sys.version_info > (3,):
output = output.decode(outputEncoding)
output = output.rstrip()

rval = sp.wait()
if rval:
# Failed!
#raise subprocess.CalledProcessError(rval, cmd)
print("Command '%s' failed with exit code %d." % (cmd, rval))
output = None
if getOutput:
print(output)
if onError is not None:
onError()
if fatal:
sys.exit(rval)

return output
outputEncoding = 'cp1252' if sys.platform == 'win32' else 'utf-8'
output = sp.stdout.read()
if sys.version_info > (3,):
output = output.decode(outputEncoding)
output = output.rstrip()

rval = sp.wait()
if rval:
# Failed!
#raise subprocess.CalledProcessError(rval, cmd)
print("Command '%s' failed with exit code %d." % (cmd, rval))
if getOutput:
print(output)
if onError is not None:
onError()
if fatal:
sys.exit(rval)

return output


def myExecfile(filename, ns):
Expand Down
6 changes: 5 additions & 1 deletion buildtools/distutils_hacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
import distutils.command.install_headers
import distutils.command.clean

from distutils.dep_util import newer, newer_group
try:
from setuptools.modified import newer, newer_group
except ImportError:
from distutils.dep_util import newer, newer_group

from distutils import log

from .config import Config, posixjoin, loadETG, etg2sip
Expand Down

0 comments on commit 99d1749

Please sign in to comment.