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: #1810
  • Loading branch information
ianw committed May 4, 2020
1 parent 6dffcf2 commit eec1b47
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/virtualenv/create/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@ 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(sysconfig.get_makefile_filename())
result["makefile_filename"] = encode_path(get_makefile_filename())
except ImportError:
pass

Expand Down
9 changes: 8 additions & 1 deletion src/virtualenv/discovery/py_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
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 @@ -79,7 +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()),
("makefile_filename", get_makefile_filename()),
]
if k is not None
}
Expand Down

0 comments on commit eec1b47

Please sign in to comment.