Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/2071.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replaced references to the deprecated imp package with references to importlib
5 changes: 3 additions & 2 deletions setuptools/command/bdist_egg.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ def write_stub(resource, pyfile):
_stub_template = textwrap.dedent("""
def __bootstrap__():
global __bootstrap__, __loader__, __file__
import sys, pkg_resources, imp
import sys, pkg_resources
from importlib.machinery import ExtensionFileLoader
__file__ = pkg_resources.resource_filename(__name__, %r)
__loader__ = None; del __bootstrap__, __loader__
imp.load_dynamic(__name__,__file__)
ExtensionFileLoader(__name__,__file__).exec_module()
__bootstrap__()
""").lstrip()
with open(pyfile, 'w') as f:
Expand Down
6 changes: 4 additions & 2 deletions setuptools/command/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ def write_stub(self, output_dir, ext, compile=False):
'\n'.join([
"def __bootstrap__():",
" global __bootstrap__, __file__, __loader__",
" import sys, os, pkg_resources, imp" + if_dl(", dl"),
" import sys, os, pkg_resources" + if_dl(", dl"),
" from importlib.machinery import ExtensionFileLoader",
" __file__ = pkg_resources.resource_filename"
"(__name__,%r)"
% os.path.basename(ext._file_name),
Expand All @@ -266,7 +267,8 @@ def write_stub(self, output_dir, ext, compile=False):
" try:",
" os.chdir(os.path.dirname(__file__))",
if_dl(" sys.setdlopenflags(dl.RTLD_NOW)"),
" imp.load_dynamic(__name__,__file__)",
" ExtensionFileLoader(__name__,",
" __file__).exec_module()",
" finally:",
if_dl(" sys.setdlopenflags(old_flags)"),
" os.chdir(old_dir)",
Expand Down