Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
62240650
Commit
62240650
authored
Aug 12, 2020
by
Jason R. Coombs
Committed by
GitHub
Aug 12, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2297 from radarhere/master
Change load_module to exec_module
parents
7fbca8ce
3af54b4b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
+11
-7
changelog.d/2297.misc.rst
changelog.d/2297.misc.rst
+1
-0
setuptools/command/bdist_egg.py
setuptools/command/bdist_egg.py
+4
-3
setuptools/command/build_ext.py
setuptools/command/build_ext.py
+6
-4
No files found.
changelog.d/2297.misc.rst
0 → 100644
View file @
62240650
Once again, in stubs prefer exec_module to the deprecated load_module.
setuptools/command/bdist_egg.py
View file @
62240650
...
...
@@ -55,11 +55,12 @@ def write_stub(resource, pyfile):
_stub_template
=
textwrap
.
dedent
(
"""
def __bootstrap__():
global __bootstrap__, __loader__, __file__
import sys, pkg_resources
from importlib.machinery import ExtensionFileLoader
import sys, pkg_resources, importlib.util
__file__ = pkg_resources.resource_filename(__name__, %r)
__loader__ = None; del __bootstrap__, __loader__
ExtensionFileLoader(__name__,__file__).load_module()
spec = importlib.util.spec_from_file_location(__name__,__file__)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
__bootstrap__()
"""
).
lstrip
()
with
open
(
pyfile
,
'w'
)
as
f
:
...
...
setuptools/command/build_ext.py
View file @
62240650
...
...
@@ -254,8 +254,8 @@ class build_ext(_build_ext):
'
\
n
'
.
join
([
"def __bootstrap__():"
,
" global __bootstrap__, __file__, __loader__"
,
" import sys, os, pkg_resources
"
+
if_dl
(
", dl"
),
" from importlib.machinery import ExtensionFileLoader"
,
" import sys, os, pkg_resources
, importlib.util"
+
if_dl
(
", dl"
)
,
" __file__ = pkg_resources.resource_filename"
"(__name__,%r)"
%
os
.
path
.
basename
(
ext
.
_file_name
),
...
...
@@ -267,8 +267,10 @@ class build_ext(_build_ext):
" try:"
,
" os.chdir(os.path.dirname(__file__))"
,
if_dl
(
" sys.setdlopenflags(dl.RTLD_NOW)"
),
" ExtensionFileLoader(__name__,"
,
" __file__).load_module()"
,
" spec = importlib.util.spec_from_file_location("
,
" __name__, __file__)"
,
" mod = importlib.util.module_from_spec(spec)"
,
" spec.loader.exec_module(mod)"
,
" finally:"
,
if_dl
(
" sys.setdlopenflags(old_flags)"
),
" os.chdir(old_dir)"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment