Commit 6e2695da authored by PJ Eby's avatar PJ Eby

Keep site directories (e.g. site-packages) from being included in

.pth files.  (backport from trunk)

--HG--
branch : setuptools-0.6
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4066609
parent 07b31962
...@@ -1246,6 +1246,8 @@ Release Notes/Change History ...@@ -1246,6 +1246,8 @@ Release Notes/Change History
* Removed use of deprecated ``md5`` module if ``hashlib`` is available * Removed use of deprecated ``md5`` module if ``hashlib`` is available
* Keep site directories (e.g. ``site-packages``) from being included in
``.pth`` files.
0.6c7 0.6c7
* ``ftp:`` download URLs now work correctly. * ``ftp:`` download URLs now work correctly.
......
...@@ -272,7 +272,7 @@ class easy_install(Command): ...@@ -272,7 +272,7 @@ class easy_install(Command):
if is_site_dir: if is_site_dir:
if self.pth_file is None: if self.pth_file is None:
self.pth_file = PthDistributions(pth_file) self.pth_file = PthDistributions(pth_file, self.all_site_dirs)
else: else:
self.pth_file = None self.pth_file = None
...@@ -1315,8 +1315,8 @@ class PthDistributions(Environment): ...@@ -1315,8 +1315,8 @@ class PthDistributions(Environment):
dirty = False dirty = False
def __init__(self, filename): def __init__(self, filename, sitedirs=()):
self.filename = filename self.filename = filename; self.sitedirs=map(normalize_path, sitedirs)
self.basedir = normalize_path(os.path.dirname(self.filename)) self.basedir = normalize_path(os.path.dirname(self.filename))
self._load(); Environment.__init__(self, [], None, None) self._load(); Environment.__init__(self, [], None, None)
for path in yield_lines(self.paths): for path in yield_lines(self.paths):
...@@ -1325,7 +1325,7 @@ class PthDistributions(Environment): ...@@ -1325,7 +1325,7 @@ class PthDistributions(Environment):
def _load(self): def _load(self):
self.paths = [] self.paths = []
saw_import = False saw_import = False
seen = {} seen = dict.fromkeys(self.sitedirs)
if os.path.isfile(self.filename): if os.path.isfile(self.filename):
for line in open(self.filename,'rt'): for line in open(self.filename,'rt'):
if line.startswith('import'): if line.startswith('import'):
...@@ -1381,7 +1381,7 @@ class PthDistributions(Environment): ...@@ -1381,7 +1381,7 @@ class PthDistributions(Environment):
def add(self,dist): def add(self,dist):
"""Add `dist` to the distribution map""" """Add `dist` to the distribution map"""
if dist.location not in self.paths: if dist.location not in self.paths and dist.location not in self.sitedirs:
self.paths.append(dist.location); self.dirty = True self.paths.append(dist.location); self.dirty = True
Environment.add(self,dist) Environment.add(self,dist)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment