From 5cbb2ada2e22f95b1dd0cd8ed14643a8cb3766cd Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 19 Aug 2015 19:58:12 +0100 Subject: Calculate prelude and postlude early --- setuptools/command/easy_install.py | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'setuptools/command/easy_install.py') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 0e912156..b6b0cffd 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1547,25 +1547,26 @@ class PthDistributions(Environment): self.dirty = False - def _wrap_lines(self, lines): - yield self._inline(""" - import sys - sys.__plen = len(sys.path) - """) + @classmethod + def _wrap_lines(cls, lines): + yield cls.prelude for line in lines: yield line - yield self._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) - """) + yield cls.postlude - @staticmethod - def _inline(text): - return textwrap.dedent(text).strip().replace('\n', '; ') + _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) + """) def add(self, dist): """Add `dist` to the distribution map""" -- cgit v1.2.1