Skip to content

Commit

Permalink
Wrap usage of get_makefile_filename (#1811)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianw authored May 4, 2020
1 parent 6dffcf2 commit 73793c7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/changelog/1810.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes older CPython2 versions use ``_get_makefile_filename`` instead of ``get_makefile_filename`` on ``sysconfig`` - by :user:`ianw`.
4 changes: 3 additions & 1 deletion src/virtualenv/create/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def run():
try:
import sysconfig

result["makefile_filename"] = encode_path(sysconfig.get_makefile_filename())
# https://bugs.python.org/issue22199
makefile = getattr(sysconfig, "get_makefile_filename", getattr(sysconfig, "_get_makefile_filename", None))
result["makefile_filename"] = encode_path(makefile())
except ImportError:
pass

Expand Down
8 changes: 5 additions & 3 deletions src/virtualenv/discovery/py_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +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 = getattr(sysconfig, "get_makefile_filename", getattr(sysconfig, "_get_makefile_filename", None))
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 [
# a list of content to store from sysconfig
("makefile_filename", makefile()),
]
if k is not None
}
Expand Down

0 comments on commit 73793c7

Please sign in to comment.