summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2020-08-31 21:09:14 -0400
committerJason R. Coombs <jaraco@jaraco.com>2020-08-31 21:11:24 -0400
commitae27e13a663cc53d15632e884f7b4d601a8605dc (patch)
treef63306eca83feb7cfbe1eb9ee9760b1bbdcdee83
parent467915b93d3965a7bad42a4e3ec6ce49843f874b (diff)
downloadpython-setuptools-git-ae27e13a663cc53d15632e884f7b4d601a8605dc.tar.gz
Supply a copy of _optim_args_from_interpreter_flags for Python 3.5 compatibility. Ref pypa/setuptools#2357.
-rw-r--r--distutils/py35compat.py19
-rw-r--r--distutils/util.py4
2 files changed, 22 insertions, 1 deletions
diff --git a/distutils/py35compat.py b/distutils/py35compat.py
new file mode 100644
index 00000000..79b2e7f3
--- /dev/null
+++ b/distutils/py35compat.py
@@ -0,0 +1,19 @@
+import sys
+import subprocess
+
+
+def __optim_args_from_interpreter_flags():
+ """Return a list of command-line arguments reproducing the current
+ optimization settings in sys.flags."""
+ args = []
+ value = sys.flags.optimize
+ if value > 0:
+ args.append("-" + "O" * value)
+ return args
+
+
+_optim_args_from_interpreter_flags = getattr(
+ subprocess,
+ "_optim_args_from_interpreter_flags",
+ __optim_args_from_interpreter_flags,
+)
diff --git a/distutils/util.py b/distutils/util.py
index 9d6c5cbd..f5aca794 100644
--- a/distutils/util.py
+++ b/distutils/util.py
@@ -14,6 +14,8 @@ from distutils.dep_util import newer
from distutils.spawn import spawn
from distutils import log
from distutils.errors import DistutilsByteCompileError
+from .py35compat import _optim_args_from_interpreter_flags
+
def get_host_platform():
"""Return a string that identifies the current platform. This is used mainly to
@@ -420,7 +422,7 @@ byte_compile(files, optimize=%r, force=%r,
""" % (optimize, force, prefix, base_dir, verbose))
cmd = [sys.executable]
- cmd.extend(subprocess._optim_args_from_interpreter_flags())
+ cmd.extend(_optim_args_from_interpreter_flags())
cmd.append(script_name)
spawn(cmd, dry_run=dry_run)
execute(os.remove, (script_name,), "removing %s" % script_name,