diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2015-08-19 20:29:08 +0100 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2015-08-19 20:29:08 +0100 |
commit | e2124f4d4c74770ccc0b9fc5f0e17becda578063 (patch) | |
tree | ef4fe9606a20f684a9576839988175f5611f41c5 /setuptools/command/easy_install.py | |
parent | 5cbb2ada2e22f95b1dd0cd8ed14643a8cb3766cd (diff) | |
download | external_python_setuptools-e2124f4d4c74770ccc0b9fc5f0e17becda578063.tar.gz external_python_setuptools-e2124f4d4c74770ccc0b9fc5f0e17becda578063.tar.bz2 external_python_setuptools-e2124f4d4c74770ccc0b9fc5f0e17becda578063.zip |
Extract a class for the behavior that rewrites the sys.path
Diffstat (limited to 'setuptools/command/easy_install.py')
-rwxr-xr-x | setuptools/command/easy_install.py | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index b6b0cffd..2b639c1b 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1547,26 +1547,9 @@ class PthDistributions(Environment): self.dirty = False - @classmethod - def _wrap_lines(cls, lines): - yield cls.prelude - for line in lines: - yield line - yield cls.postlude - - _inline = lambda text: textwrap.dedent(text).strip().replace('\n', '; ') - prelude = _inline(""" - import sys - sys.__plen = len(sys.path) - """) - postlude = _inline(""" - import sys - new = sys.path[sys.__plen:] - del sys.path[sys.__plen:] - p = getattr(sys, '__egginsert', 0) - sys.path[p:p] = new - sys.__egginsert = p + len(new) - """) + @staticmethod + def _wrap_lines(lines): + return lines def add(self, dist): """Add `dist` to the distribution map""" @@ -1605,6 +1588,33 @@ class PthDistributions(Environment): return path +class RewritePthDistributions(PthDistributions): + + @classmethod + def _wrap_lines(cls, lines): + yield cls.prelude + for line in lines: + yield line + yield cls.postlude + + _inline = lambda text: textwrap.dedent(text).strip().replace('\n', '; ') + prelude = _inline(""" + import sys + sys.__plen = len(sys.path) + """) + postlude = _inline(""" + import sys + new = sys.path[sys.__plen:] + del sys.path[sys.__plen:] + p = getattr(sys, '__egginsert', 0) + sys.path[p:p] = new + sys.__egginsert = p + len(new) + """) + + +PthDistributions = RewritePthDistributions + + def _first_line_re(): """ Return a regular expression based on first_line_re suitable for matching |