prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Pyramid app frozen with py2exe fails because of Chameleon imports
  If I freeze a Pyramid application with py2exe and try to run it, it fails during the startup, with the following traceback:
  
  ```
  Traceback (most recent call last):
    File "web_server.py", line 2, in <module>
    File "pyramid\config\__init__.pyc", line 66, in <module>
    File "pyramid\config\rendering.pyc", line 11, in <module>
    File "pyramid\chameleon_text.pyc", line 3, in <module>
    File "chameleon\__init__.pyc", line 1, in <module>
    File "chameleon\zpt\template.pyc", line 10, in <module>
    File "chameleon\tales.pyc", line 19, in <module>
    File "chameleon\compiler.pyc", line 145, in <module>
    File "chameleon\codegen.pyc", line 93, in template
    File "inspect.pyc", line 701, in getsource
    File "inspect.pyc", line 690, in getsourcelines
    File "inspect.pyc", line 538, in findsource
  IOError: could not get source code
  ```
  
  My application doesn't use Chameleon, but the Pyramid modules still import it, which ultimately causes the .exe to fail to run.
  
  
  </issue>
  <code>
  [start of pyramid/chameleon_zpt.py]
  1 from zope.interface import implementer
  2 
  3 from chameleon.zpt.template import PageTemplateFile
  4 
  5 from pyramid.interfaces import ITemplateRenderer
  6 from pyramid.decorator import reify
  7 from pyramid import renderers
  8 
  9 def renderer_factory(info):
  10     return renderers.template_renderer_factory(info, ZPTTemplateRenderer)
  11 
  12 @implementer(ITemplateRenderer)
  13 class ZPTTemplateRenderer(object):
  14     def __init__(self, path, lookup, macro=None):
  15         self.path = path
  16         self.lookup = lookup
  17         self.macro = macro
  18 
  19     @reify # avoid looking up reload_templates before manager pushed
  20     def template(self):
  21         tf = PageTemplateFile(
  22             self.path,
  23             auto_reload=self.lookup.auto_reload,
  24             debug=self.lookup.debug,
  25             translate=self.lookup.translate
  26             )
  27         if self.macro:
  28             # render only the portion of the template included in a
  29             # define-macro named the value of self.macro
  30             macro_renderer = tf.macros[self.macro].include
  31             tf._render = macro_renderer
  32         return tf
  33 
  34     def implementation(self):
  35         return self.template
  36     
  37     def __call__(self, value, system):
  38         try:
  39             system.update(value)
  40         except (TypeError, ValueError):
  41             raise ValueError('renderer was passed non-dictionary as value')
  42         result = self.template(**system)
  43         return result
  44 
  45
  [end of pyramid/chameleon_zpt.py]
  [start of pyramid/chameleon_text.py]
  1 from zope.interface import implementer
  2 
  3 from chameleon.zpt.template import PageTextTemplateFile
  4 
  5 from pyramid.interfaces import ITemplateRenderer
  6 
  7 from pyramid.decorator import reify
  8 from pyramid import renderers
  9 
  10 def renderer_factory(info):
  11     return renderers.template_renderer_factory(info, TextTemplateRenderer)
  12 
  13 @implementer(ITemplateRenderer)
  14 class TextTemplateRenderer(object):
  15     def __init__(self, path, lookup, macro=None):
  16         self.path = path
  17         self.lookup = lookup
  18         # text template renderers have no macros, so we ignore the
  19         # macro arg
  20 
  21     @reify # avoid looking up reload_templates before manager pushed
  22     def template(self):
  23         return PageTextTemplateFile(self.path,
  24                                     auto_reload=self.lookup.auto_reload,
  25                                     debug=self.lookup.debug,
  26                                     translate=self.lookup.translate)
  27 
  28     def implementation(self):
  29         return self.template
  30     
  31     def __call__(self, value, system):
  32         try:
  33             system.update(value)
  34         except (TypeError, ValueError):
  35             raise ValueError('renderer was passed non-dictionary as value')
  36         result = self.template(**system)
  37         return result
  38 
  39
  [end of pyramid/chameleon_text.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/pyramid/chameleon_text.py b/pyramid/chameleon_text.py
  --- a/pyramid/chameleon_text.py
  +++ b/pyramid/chameleon_text.py
  @@ -1,7 +1,5 @@
   from zope.interface import implementer
   
  -from chameleon.zpt.template import PageTextTemplateFile
  -
   from pyramid.interfaces import ITemplateRenderer
   
   from pyramid.decorator import reify
  @@ -20,6 +18,7 @@
   
       @reify # avoid looking up reload_templates before manager pushed
       def template(self):
  +        from chameleon.zpt.template import PageTextTemplateFile
           return PageTextTemplateFile(self.path,
                                       auto_reload=self.lookup.auto_reload,
                                       debug=self.lookup.debug,
  diff --git a/pyramid/chameleon_zpt.py b/pyramid/chameleon_zpt.py
  --- a/pyramid/chameleon_zpt.py
  +++ b/pyramid/chameleon_zpt.py
  @@ -1,7 +1,5 @@
   from zope.interface import implementer
   
  -from chameleon.zpt.template import PageTemplateFile
  -
   from pyramid.interfaces import ITemplateRenderer
   from pyramid.decorator import reify
   from pyramid import renderers
  @@ -18,6 +16,7 @@
   
       @reify # avoid looking up reload_templates before manager pushed
       def template(self):
  +        from chameleon.zpt.template import PageTemplateFile
           tf = PageTemplateFile(
               self.path,
               auto_reload=self.lookup.auto_reload,
  
verification_info: {"golden_diff": "diff --git a/pyramid/chameleon_text.py b/pyramid/chameleon_text.py\n--- a/pyramid/chameleon_text.py\n+++ b/pyramid/chameleon_text.py\n@@ -1,7 +1,5 @@\n from zope.interface import implementer\n \n-from chameleon.zpt.template import PageTextTemplateFile\n-\n from pyramid.interfaces import ITemplateRenderer\n \n from pyramid.decorator import reify\n@@ -20,6 +18,7 @@\n \n     @reify # avoid looking up reload_templates before manager pushed\n     def template(self):\n+        from chameleon.zpt.template import PageTextTemplateFile\n         return PageTextTemplateFile(self.path,\n                                     auto_reload=self.lookup.auto_reload,\n                                     debug=self.lookup.debug,\ndiff --git a/pyramid/chameleon_zpt.py b/pyramid/chameleon_zpt.py\n--- a/pyramid/chameleon_zpt.py\n+++ b/pyramid/chameleon_zpt.py\n@@ -1,7 +1,5 @@\n from zope.interface import implementer\n \n-from chameleon.zpt.template import PageTemplateFile\n-\n from pyramid.interfaces import ITemplateRenderer\n from pyramid.decorator import reify\n from pyramid import renderers\n@@ -18,6 +16,7 @@\n \n     @reify # avoid looking up reload_templates before manager pushed\n     def template(self):\n+        from chameleon.zpt.template import PageTemplateFile\n         tf = PageTemplateFile(\n             self.path,\n             auto_reload=self.lookup.auto_reload,\n", "issue": "Pyramid app frozen with py2exe fails because of Chameleon imports\nIf I freeze a Pyramid application with py2exe and try to run it, it fails during the startup, with the following traceback:\n\n```\nTraceback (most recent call last):\n  File \"web_server.py\", line 2, in <module>\n  File \"pyramid\\config\\__init__.pyc\", line 66, in <module>\n  File \"pyramid\\config\\rendering.pyc\", line 11, in <module>\n  File \"pyramid\\chameleon_text.pyc\", line 3, in <module>\n  File \"chameleon\\__init__.pyc\", line 1, in <module>\n  File \"chameleon\\zpt\\template.pyc\", line 10, in <module>\n  File \"chameleon\\tales.pyc\", line 19, in <module>\n  File \"chameleon\\compiler.pyc\", line 145, in <module>\n  File \"chameleon\\codegen.pyc\", line 93, in template\n  File \"inspect.pyc\", line 701, in getsource\n  File \"inspect.pyc\", line 690, in getsourcelines\n  File \"inspect.pyc\", line 538, in findsource\nIOError: could not get source code\n```\n\nMy application doesn't use Chameleon, but the Pyramid modules still import it, which ultimately causes the .exe to fail to run.\n\n", "before_files": [{"content": "from zope.interface import implementer\n\nfrom chameleon.zpt.template import PageTemplateFile\n\nfrom pyramid.interfaces import ITemplateRenderer\nfrom pyramid.decorator import reify\nfrom pyramid import renderers\n\ndef renderer_factory(info):\n    return renderers.template_renderer_factory(info, ZPTTemplateRenderer)\n\n@implementer(ITemplateRenderer)\nclass ZPTTemplateRenderer(object):\n    def __init__(self, path, lookup, macro=None):\n        self.path = path\n        self.lookup = lookup\n        self.macro = macro\n\n    @reify # avoid looking up reload_templates before manager pushed\n    def template(self):\n        tf = PageTemplateFile(\n            self.path,\n            auto_reload=self.lookup.auto_reload,\n            debug=self.lookup.debug,\n            translate=self.lookup.translate\n            )\n        if self.macro:\n            # render only the portion of the template included in a\n            # define-macro named the value of self.macro\n            macro_renderer = tf.macros[self.macro].include\n            tf._render = macro_renderer\n        return tf\n\n    def implementation(self):\n        return self.template\n    \n    def __call__(self, value, system):\n        try:\n            system.update(value)\n        except (TypeError, ValueError):\n            raise ValueError('renderer was passed non-dictionary as value')\n        result = self.template(**system)\n        return result\n\n", "path": "pyramid/chameleon_zpt.py"}, {"content": "from zope.interface import implementer\n\nfrom chameleon.zpt.template import PageTextTemplateFile\n\nfrom pyramid.interfaces import ITemplateRenderer\n\nfrom pyramid.decorator import reify\nfrom pyramid import renderers\n\ndef renderer_factory(info):\n    return renderers.template_renderer_factory(info, TextTemplateRenderer)\n\n@implementer(ITemplateRenderer)\nclass TextTemplateRenderer(object):\n    def __init__(self, path, lookup, macro=None):\n        self.path = path\n        self.lookup = lookup\n        # text template renderers have no macros, so we ignore the\n        # macro arg\n\n    @reify # avoid looking up reload_templates before manager pushed\n    def template(self):\n        return PageTextTemplateFile(self.path,\n                                    auto_reload=self.lookup.auto_reload,\n                                    debug=self.lookup.debug,\n                                    translate=self.lookup.translate)\n\n    def implementation(self):\n        return self.template\n    \n    def __call__(self, value, system):\n        try:\n            system.update(value)\n        except (TypeError, ValueError):\n            raise ValueError('renderer was passed non-dictionary as value')\n        result = self.template(**system)\n        return result\n\n", "path": "pyramid/chameleon_text.py"}]}