Skip to content

Commit

Permalink
Wrap usage of get_makefile_filename
Browse files Browse the repository at this point in the history
Per the issue mentioned inline, this function may have different
names.  Probe for the _ prefixed version as well.

Closes: pypa#1810
  • Loading branch information
ianw committed May 4, 2020
1 parent 6dffcf2 commit 78a752f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/virtualenv/create/debug.py
Expand Up @@ -55,7 +55,14 @@ def run():
try:
import sysconfig

result["makefile_filename"] = encode_path(sysconfig.get_makefile_filename())
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())
except ImportError:
pass

Expand Down
12 changes: 9 additions & 3 deletions src/virtualenv/discovery/py_info.py
Expand Up @@ -24,6 +24,14 @@ 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+\}")

Expand Down Expand Up @@ -78,9 +86,7 @@ def abs_path(v):

self.sysconfig = {
u(k): u(v)
for k, v in [ # a list of content to store from sysconfig
("makefile_filename", sysconfig.get_makefile_filename()),
]
for k, v in [("makefile_filename", get_makefile_filename()),] # a list of content to store from sysconfig
if k is not None
}

Expand Down

0 comments on commit 78a752f

Please sign in to comment.