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
3d404fd3
Commit
3d404fd3
authored
Aug 15, 2020
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor to use lookups and consolidate behaviors.
parent
77eeb77f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
12 deletions
+8
-12
_distutils_hack/__init__.py
_distutils_hack/__init__.py
+8
-12
No files found.
_distutils_hack/__init__.py
View file @
3d404fd3
...
@@ -66,14 +66,14 @@ def do_override():
...
@@ -66,14 +66,14 @@ def do_override():
class
DistutilsMetaFinder
:
class
DistutilsMetaFinder
:
def
find_spec
(
self
,
fullname
,
path
,
target
=
None
):
def
find_spec
(
self
,
fullname
,
path
,
target
=
None
):
self
.
_disable_for_pip
(
fullname
,
path
)
if
path
is
not
None
:
return
if
path
is
not
None
or
fullname
!=
"distutils"
:
return
None
return
self
.
get_distutils_spec
()
method_name
=
'spec_for_{fullname}'
.
format
(
**
locals
())
method
=
getattr
(
self
,
method_name
,
lambda
:
None
)
return
method
()
def
get_distutils_spec
(
self
):
def
spec_for_distutils
(
self
):
import
importlib.util
import
importlib.util
class
DistutilsLoader
(
importlib
.
util
.
abc
.
Loader
):
class
DistutilsLoader
(
importlib
.
util
.
abc
.
Loader
):
...
@@ -86,17 +86,13 @@ class DistutilsMetaFinder:
...
@@ -86,17 +86,13 @@ class DistutilsMetaFinder:
return
importlib
.
util
.
spec_from_loader
(
'distutils'
,
DistutilsLoader
())
return
importlib
.
util
.
spec_from_loader
(
'distutils'
,
DistutilsLoader
())
def
_disable_for_pip
(
self
,
fullname
,
path
):
def
spec_for_pip
(
self
):
"""
"""
Ensure stdlib distutils when running under pip.
Ensure stdlib distutils when running under pip.
See pypa/pip#8761 for rationale.
See pypa/pip#8761 for rationale.
"""
"""
if
path
is
not
None
or
fullname
!=
"pip"
:
return
# pip is being imported the first time.
clear_distutils
()
clear_distutils
()
self
.
get_distutils_spec
=
lambda
:
None
self
.
spec_for_distutils
=
lambda
:
None
DISTUTILS_FINDER
=
DistutilsMetaFinder
()
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