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
be7a0a31
Commit
be7a0a31
authored
Aug 14, 2020
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bypass .pth loader when distutils is loaded from pip. Workaround for pypa/pip#8761.
parent
4837f218
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
_distutils_hack/__init__.py
_distutils_hack/__init__.py
+12
-1
No files found.
_distutils_hack/__init__.py
View file @
be7a0a31
...
...
@@ -3,6 +3,7 @@ import os
import
re
import
importlib
import
warnings
import
inspect
is_pypy
=
'__pypy__'
in
sys
.
builtin_module_names
...
...
@@ -66,7 +67,7 @@ def do_override():
class
DistutilsMetaFinder
:
def
find_spec
(
self
,
fullname
,
path
,
target
=
None
):
if
path
is
not
None
or
fullname
!=
"distutils"
:
if
path
is
not
None
or
fullname
!=
"distutils"
or
self
.
_bypass
()
:
return
None
return
self
.
get_distutils_spec
()
...
...
@@ -84,6 +85,16 @@ class DistutilsMetaFinder:
return
importlib
.
util
.
spec_from_loader
(
'distutils'
,
DistutilsLoader
())
def
_bypass
(
self
):
"""
Suppress the import of distutils from setuptools when running under pip.
See pypa/pip#8761 for rationale.
"""
return
any
(
level
.
frame
.
f_globals
[
'__name__'
].
startswith
(
'pip.'
)
for
level
in
inspect
.
stack
(
context
=
False
)
)
DISTUTILS_FINDER
=
DistutilsMetaFinder
()
...
...
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