Skip to content

Commit

Permalink
fix #4829: fix the import of pip_shims
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming committed Nov 5, 2021
1 parent e368271 commit 4b14b63
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pipenv/vendor/pip_shims/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@
if "pip_shims" in sys.modules:
# mainly to keep a reference to the old module on hand so it doesn't get
# weakref'd away
old_module = sys.modules["pip_shims"]
if __name__ != "pip_shims":
del sys.modules["pip_shims"]


module = sys.modules["pip_shims"] = shims._new()
if __name__ in sys.modules:
old_module = sys.modules[__name__]


module = sys.modules["pip_shims"] = sys.modules[__name__] = shims._new()
module.shims = shims
module.__dict__.update(
{
Expand Down
22 changes: 22 additions & 0 deletions tasks/vendoring/patches/vendor/pip_shims-import.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/pipenv/vendor/pip_shims/__init__.py b/pipenv/vendor/pip_shims/__init__.py
index c66a075a..febea8df 100644
--- a/pipenv/vendor/pip_shims/__init__.py
+++ b/pipenv/vendor/pip_shims/__init__.py
@@ -31,10 +31,15 @@ __version__ = "0.6.0"
if "pip_shims" in sys.modules:
# mainly to keep a reference to the old module on hand so it doesn't get
# weakref'd away
- old_module = sys.modules["pip_shims"]
+ if __name__ != "pip_shims":
+ del sys.modules["pip_shims"]


-module = sys.modules["pip_shims"] = shims._new()
+if __name__ in sys.modules:
+ old_module = sys.modules[__name__]
+
+
+module = sys.modules["pip_shims"] = sys.modules[__name__] = shims._new()
module.shims = shims
module.__dict__.update(
{

0 comments on commit 4b14b63

Please sign in to comment.