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
89e9d3c8
Commit
89e9d3c8
authored
Jul 13, 2020
by
Paul Ganssle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust distutils shim when removing _distutils_importer
parent
03b36b5d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
6 deletions
+30
-6
_distutils_importer/__init__.py
_distutils_importer/__init__.py
+14
-3
setuptools/sandbox.py
setuptools/sandbox.py
+16
-3
No files found.
_distutils_importer/__init__.py
View file @
89e9d3c8
import
sys
here
=
os
.
path
.
dirname
(
__file__
)
NEW_DISTUTILS_LOCATION
=
os
.
path
.
join
(
here
,
'distutils-shim-package'
)
_HERE
=
os
.
path
.
dirname
(
__file__
)
NEW_DISTUTILS_LOCATION
=
os
.
path
.
join
(
_HERE
,
'distutils-shim-package'
)
sys
.
path
.
insert
(
0
,
NEW_DISTUTILS_LOCATION
)
def
add_shim
():
if
NEW_DISTUTILS_LOCATION
not
in
sys
.
path
:
sys
.
path
.
insert
(
0
,
NEW_DISTUTILS_LOCATION
)
def
remove_shim
():
try
:
sys
.
path
.
remove
(
NEW_DISTUTILS_LOCATION
)
except
ValueError
:
pass
add_shim
()
setuptools/sandbox.py
View file @
89e9d3c8
...
...
@@ -185,8 +185,8 @@ def setup_context(setup_dir):
temp_dir
=
os
.
path
.
join
(
setup_dir
,
'temp'
)
with
save_pkg_resources_state
():
with
save_modules
():
hide_setuptools
()
with
save_path
():
hide_setuptools
()
with
save_argv
():
with
override_temp
(
temp_dir
):
with
pushd
(
setup_dir
):
...
...
@@ -195,6 +195,15 @@ def setup_context(setup_dir):
yield
_MODULES_TO_HIDE
=
{
'setuptools'
,
'distutils'
,
'pkg_resources'
,
'Cython'
,
'_distutils_importer'
,
}
def
_needs_hiding
(
mod_name
):
"""
>>> _needs_hiding('setuptools')
...
...
@@ -212,8 +221,8 @@ def _needs_hiding(mod_name):
>>> _needs_hiding('Cython')
True
"""
pattern
=
re
.
compile
(
r'(setuptools|pkg_resources|distutils|Cython)(\
.|$)
')
return b
ool(pattern.match(mod_name))
base_module
=
mod_name
.
split
(
'.'
,
1
)[
0
]
return
b
ase_module
in
_MODULES_TO_HIDE
def
hide_setuptools
():
...
...
@@ -223,6 +232,10 @@ def hide_setuptools():
necessary to avoid issues such as #315 where setuptools upgrading itself
would fail to find a function declared in the metadata.
"""
_distutils_importer
=
sys
.
modules
.
get
(
'_distutils_importer'
,
None
)
if
_distutils_importer
is
not
None
:
_distutils_importer
.
remove_shim
()
modules
=
filter
(
_needs_hiding
,
sys
.
modules
)
_clear_modules
(
modules
)
...
...
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