summaryrefslogtreecommitdiff
path: root/setuptools/command/easy_install.py
diff options
context:
space:
mode:
authorJurko Gospodnetić <jurko.gospodnetic@pke.hr>2014-04-15 23:35:44 +0200
committerJurko Gospodnetić <jurko.gospodnetic@pke.hr>2014-04-15 23:35:44 +0200
commit92cbda9859d98267e36c836ca954ca884df9b07c (patch)
tree8bcd54b7b9141a7285041f033c621682437d333c /setuptools/command/easy_install.py
parentcb4b1a9e751b10d63d91197934d1d8f8fff44be9 (diff)
downloadpython-setuptools-git-92cbda9859d98267e36c836ca954ca884df9b07c.tar.gz
make easy_install.uncache_zipdir() remove more stale zipimporter instances
Since paths are case-insensitive on Windows, zipped egg modules may be loaded using different but equivalent paths. Importing each such different path causes a new zipimporter to be instantiated. Removing cached zipimporter instances must then not forget about removing those created for differently spelled paths to the same replaced egg. Other missed zipimporter instances are those used to access zipped eggs stored inside zipped eggs. When clearing zipimporter instances got a given path, we need to clear all the instances related to any of its subpaths as well. --HG-- extra : rebase_source : 86aeadd1e639fbc83d27a0c551fdc2b8a68a6f85
Diffstat (limited to 'setuptools/command/easy_install.py')
-rwxr-xr-xsetuptools/command/easy_install.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index 8c281590..d4bb2b90 100755
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -1597,18 +1597,20 @@ def uncache_zipdir(path):
whomever is in charge of maintaining that cache.
"""
- _uncache(path, zipimport._zip_directory_cache)
- _uncache(path, sys.path_importer_cache)
-
-def _uncache(path, cache):
- if path in cache:
- del cache[path]
- else:
- normalized_path = normalize_path(path)
- for p in cache:
- if normalize_path(p) == normalized_path:
- del cache[p]
- return
+ normalized_path = normalize_path(path)
+ _uncache(normalized_path, zipimport._zip_directory_cache)
+ _uncache(normalized_path, sys.path_importer_cache)
+
+def _uncache(normalized_path, cache):
+ to_remove = []
+ prefix_len = len(normalized_path)
+ for p in cache:
+ np = normalize_path(p)
+ if (np.startswith(normalized_path) and
+ np[prefix_len:prefix_len + 1] in (os.sep, '')):
+ to_remove.append(p)
+ for p in to_remove:
+ del cache[p]
def is_python(text, filename='<string>'):
"Is this string a valid Python script?"