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 | 2860a5609939c94dec74a7f2b0347e6c7c5a508f (patch) | |
tree | 6fb1318bb398336f5ae9e2ed5d99e4ed98d5043d | |
parent | 41b15086543f8e7403090032cc12df56a2c804e0 (diff) | |
download | python-setuptools-bitbucket-2860a5609939c94dec74a7f2b0347e6c7c5a508f.tar.gz |
Extract a class for the behavior that rewrites the sys.path
-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 |