From 3c4091d86859da42d2070e01e777926a1498ae1f Mon Sep 17 00:00:00 2001 From: Bernat Gabor Date: Mon, 4 May 2020 07:25:56 +0100 Subject: [PATCH] Make change a bit more compact Signed-off-by: Bernat Gabor --- src/virtualenv/create/debug.py | 11 +++-------- src/virtualenv/discovery/py_info.py | 13 +++---------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/virtualenv/create/debug.py b/src/virtualenv/create/debug.py index 5ff76eafd..8106e9a7f 100644 --- a/src/virtualenv/create/debug.py +++ b/src/virtualenv/create/debug.py @@ -55,14 +55,9 @@ def run(): try: import sysconfig - try: - get_makefile_filename = sysconfig.get_makefile_filename - except AttributeError: - # On some platforms, get_makefile_filename doesn't exist - # https://bugs.python.org/issue22199 - get_makefile_filename = sysconfig._get_makefile_filename - - result["makefile_filename"] = encode_path(get_makefile_filename()) + # https://bugs.python.org/issue22199 + makefile_filename = getattr(sysconfig, "get_makefile_filename", getattr(sysconfig, "_get_makefile_filename")) + result["makefile_filename"] = encode_path(makefile_filename()) except ImportError: pass diff --git a/src/virtualenv/discovery/py_info.py b/src/virtualenv/discovery/py_info.py index 996ef3357..ef0be593b 100644 --- a/src/virtualenv/discovery/py_info.py +++ b/src/virtualenv/discovery/py_info.py @@ -24,14 +24,6 @@ def _get_path_extensions(): return list(OrderedDict.fromkeys([""] + os.environ.get("PATHEXT", "").lower().split(os.pathsep))) -try: - get_makefile_filename = sysconfig.get_makefile_filename -except AttributeError: - # On some platforms, get_makefile_filename doesn't exist - # https://bugs.python.org/issue22199 - get_makefile_filename = sysconfig._get_makefile_filename - - EXTENSIONS = _get_path_extensions() _CONF_VAR_RE = re.compile(r"\{\w+\}") @@ -83,12 +75,13 @@ def abs_path(v): self.stdout_encoding = u(getattr(sys.stdout, "encoding", None)) self.sysconfig_paths = {u(i): u(sysconfig.get_path(i, expand=False)) for i in sysconfig.get_path_names()} - + # https://bugs.python.org/issue22199 + makefile_filename = getattr(sysconfig, "get_makefile_filename", getattr(sysconfig, "_get_makefile_filename")) self.sysconfig = { u(k): u(v) for k, v in [ # a list of content to store from sysconfig - ("makefile_filename", get_makefile_filename()), + ("makefile_filename", makefile_filename()), ] if k is not None }