diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2020-08-31 21:13:25 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2020-08-31 21:13:25 -0400 |
commit | 37d8f047eb7419959b20e5acbae92da6ad98b7e2 (patch) | |
tree | 0b530a3d29d03b557a221651d224d97bf66afd88 | |
parent | ad6ffd40c6343644187eb06d4db9c62919f0c9b6 (diff) | |
parent | ae27e13a663cc53d15632e884f7b4d601a8605dc (diff) | |
download | python-setuptools-git-37d8f047eb7419959b20e5acbae92da6ad98b7e2.tar.gz |
Merge branch 'clean' into master
-rw-r--r-- | distutils/py35compat.py | 19 | ||||
-rw-r--r-- | distutils/py38compat.py | 7 | ||||
-rw-r--r-- | distutils/tests/py38compat.py | 3 | ||||
-rw-r--r-- | distutils/util.py | 8 |
4 files changed, 34 insertions, 3 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/py38compat.py b/distutils/py38compat.py new file mode 100644 index 00000000..fa9ba73f --- /dev/null +++ b/distutils/py38compat.py @@ -0,0 +1,7 @@ +def aix_platform(osname, version, release): + try: + import _aix_support + return _aix_support.aix_platform() + except ImportError: + pass + return "%s-%s.%s" % (osname, version, release) diff --git a/distutils/tests/py38compat.py b/distutils/tests/py38compat.py index 46ff5758..32269c7b 100644 --- a/distutils/tests/py38compat.py +++ b/distutils/tests/py38compat.py @@ -1,6 +1,9 @@ # flake8: noqa import contextlib +import builtins + +ModuleNotFoundError = getattr(builtins, 'ModuleNotFoundError', ImportError) try: from test.support.warnings_helper import check_warnings diff --git a/distutils/util.py b/distutils/util.py index 4b002ece..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 @@ -79,8 +81,8 @@ def get_host_platform(): machine += ".%s" % bitness[sys.maxsize] # fall through to standard osname-release-machine representation elif osname[:3] == "aix": - from _aix_support import aix_platform - return aix_platform() + from .py38compat import aix_platform + return aix_platform(osname, version, release) elif osname[:6] == "cygwin": osname = "cygwin" rel_re = re.compile (r'[\d.]+', re.ASCII) @@ -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, |