prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  building flex with +lex variant fails
  Using an older system (suse 13 with python 2.7.6) and the symlink code in the package fails entirely.
  @mjwoods 
  
  
  </issue>
  <code>
  [start of var/spack/repos/builtin/packages/flex/package.py]
  1 ##############################################################################
  2 # Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
  3 # Produced at the Lawrence Livermore National Laboratory.
  4 #
  5 # This file is part of Spack.
  6 # Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
  7 # LLNL-CODE-647188
  8 #
  9 # For details, see https://github.com/llnl/spack
  10 # Please also see the LICENSE file for our notice and the LGPL.
  11 #
  12 # This program is free software; you can redistribute it and/or modify
  13 # it under the terms of the GNU Lesser General Public License (as
  14 # published by the Free Software Foundation) version 2.1, February 1999.
  15 #
  16 # This program is distributed in the hope that it will be useful, but
  17 # WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
  18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
  19 # conditions of the GNU Lesser General Public License for more details.
  20 #
  21 # You should have received a copy of the GNU Lesser General Public
  22 # License along with this program; if not, write to the Free Software
  23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24 ##############################################################################
  25 from spack import *
  26 import os
  27 
  28 
  29 class Flex(AutotoolsPackage):
  30     """Flex is a tool for generating scanners."""
  31 
  32     homepage = "https://github.com/westes/flex"
  33     url = "https://github.com/westes/flex/releases/download/v2.6.1/flex-2.6.1.tar.gz"
  34 
  35     version('2.6.3', 'a5f65570cd9107ec8a8ec88f17b31bb1')
  36     # Problematic version:
  37     # See issue #2554; https://github.com/westes/flex/issues/113
  38     # version('2.6.2', 'cc6d76c333db7653d5caf423a3335239')
  39     version('2.6.1', '05bcd8fb629e0ae130311e8a6106fa82')
  40     version('2.6.0', '760be2ee9433e822b6eb65318311c19d')
  41     version('2.5.39', '5865e76ac69c05699f476515592750d7')
  42 
  43     variant('lex', default=True,
  44             description="Provide symlinks for lex and libl")
  45 
  46     depends_on('bison',         type='build')
  47     depends_on('gettext@0.19:', type='build')
  48     depends_on('help2man',      type='build')
  49 
  50     # Older tarballs don't come with a configure script
  51     depends_on('m4',       type='build')
  52     depends_on('autoconf', type='build', when='@:2.6.0')
  53     depends_on('automake', type='build', when='@:2.6.0')
  54     depends_on('libtool',  type='build', when='@:2.6.0')
  55 
  56     def url_for_version(self, version):
  57         url = "https://github.com/westes/flex"
  58         if version >= Version('2.6.1'):
  59             url += "/releases/download/v{0}/flex-{0}.tar.gz".format(version)
  60         elif version == Version('2.6.0'):
  61             url += "/archive/v{0}.tar.gz".format(version)
  62         elif version >= Version('2.5.37'):
  63             url += "/archive/flex-{0}.tar.gz".format(version)
  64         else:
  65             url += "/archive/flex-{0}.tar.gz".format(version.dashed)
  66 
  67         return url
  68 
  69     @run_after('install')
  70     def symlink_lex(self):
  71         if self.spec.satisfies('+lex'):
  72             dso = dso_suffix
  73             for dir, flex, lex in \
  74                     ((self.prefix.bin, 'flex', 'lex'),
  75                      (self.prefix.lib, 'libfl.a', 'libl.a'),
  76                      (self.prefix.lib, 'libfl.' + dso, 'libl.' + dso)):
  77                 with working_dir(dir):
  78                     if (os.path.isfile(flex) and not
  79                             os.path.lexists(lex)):
  80                         symlink(flex, lex)
  81
  [end of var/spack/repos/builtin/packages/flex/package.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/var/spack/repos/builtin/packages/flex/package.py b/var/spack/repos/builtin/packages/flex/package.py
  --- a/var/spack/repos/builtin/packages/flex/package.py
  +++ b/var/spack/repos/builtin/packages/flex/package.py
  @@ -32,6 +32,7 @@
       homepage = "https://github.com/westes/flex"
       url = "https://github.com/westes/flex/releases/download/v2.6.1/flex-2.6.1.tar.gz"
   
  +    version('2.6.4', '2882e3179748cc9f9c23ec593d6adc8d')
       version('2.6.3', 'a5f65570cd9107ec8a8ec88f17b31bb1')
       # Problematic version:
       # See issue #2554; https://github.com/westes/flex/issues/113
  @@ -68,13 +69,17 @@
   
       @run_after('install')
       def symlink_lex(self):
  +        """Install symlinks for lex compatibility."""
           if self.spec.satisfies('+lex'):
               dso = dso_suffix
               for dir, flex, lex in \
  -                    ((self.prefix.bin, 'flex', 'lex'),
  -                     (self.prefix.lib, 'libfl.a', 'libl.a'),
  -                     (self.prefix.lib, 'libfl.' + dso, 'libl.' + dso)):
  -                with working_dir(dir):
  -                    if (os.path.isfile(flex) and not
  -                            os.path.lexists(lex)):
  -                        symlink(flex, lex)
  +                    ((self.prefix.bin,   'flex', 'lex'),
  +                     (self.prefix.lib,   'libfl.a', 'libl.a'),
  +                     (self.prefix.lib,   'libfl.' + dso, 'libl.' + dso),
  +                     (self.prefix.lib64, 'libfl.a', 'libl.a'),
  +                     (self.prefix.lib64, 'libfl.' + dso, 'libl.' + dso)):
  +
  +                if os.path.isdir(dir):
  +                    with working_dir(dir):
  +                        if (os.path.isfile(flex) and not os.path.lexists(lex)):
  +                            symlink(flex, lex)
  
verification_info: {"golden_diff": "diff --git a/var/spack/repos/builtin/packages/flex/package.py b/var/spack/repos/builtin/packages/flex/package.py\n--- a/var/spack/repos/builtin/packages/flex/package.py\n+++ b/var/spack/repos/builtin/packages/flex/package.py\n@@ -32,6 +32,7 @@\n     homepage = \"https://github.com/westes/flex\"\n     url = \"https://github.com/westes/flex/releases/download/v2.6.1/flex-2.6.1.tar.gz\"\n \n+    version('2.6.4', '2882e3179748cc9f9c23ec593d6adc8d')\n     version('2.6.3', 'a5f65570cd9107ec8a8ec88f17b31bb1')\n     # Problematic version:\n     # See issue #2554; https://github.com/westes/flex/issues/113\n@@ -68,13 +69,17 @@\n \n     @run_after('install')\n     def symlink_lex(self):\n+        \"\"\"Install symlinks for lex compatibility.\"\"\"\n         if self.spec.satisfies('+lex'):\n             dso = dso_suffix\n             for dir, flex, lex in \\\n-                    ((self.prefix.bin, 'flex', 'lex'),\n-                     (self.prefix.lib, 'libfl.a', 'libl.a'),\n-                     (self.prefix.lib, 'libfl.' + dso, 'libl.' + dso)):\n-                with working_dir(dir):\n-                    if (os.path.isfile(flex) and not\n-                            os.path.lexists(lex)):\n-                        symlink(flex, lex)\n+                    ((self.prefix.bin,   'flex', 'lex'),\n+                     (self.prefix.lib,   'libfl.a', 'libl.a'),\n+                     (self.prefix.lib,   'libfl.' + dso, 'libl.' + dso),\n+                     (self.prefix.lib64, 'libfl.a', 'libl.a'),\n+                     (self.prefix.lib64, 'libfl.' + dso, 'libl.' + dso)):\n+\n+                if os.path.isdir(dir):\n+                    with working_dir(dir):\n+                        if (os.path.isfile(flex) and not os.path.lexists(lex)):\n+                            symlink(flex, lex)\n", "issue": "building flex with +lex variant fails\nUsing an older system (suse 13 with python 2.7.6) and the symlink code in the package fails entirely.\r\n@mjwoods \r\n\n", "before_files": [{"content": "##############################################################################\n# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.\n# Produced at the Lawrence Livermore National Laboratory.\n#\n# This file is part of Spack.\n# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.\n# LLNL-CODE-647188\n#\n# For details, see https://github.com/llnl/spack\n# Please also see the LICENSE file for our notice and the LGPL.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU Lesser General Public License (as\n# published by the Free Software Foundation) version 2.1, February 1999.\n#\n# This program is distributed in the hope that it will be useful, but\n# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and\n# conditions of the GNU Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this program; if not, write to the Free Software\n# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n##############################################################################\nfrom spack import *\nimport os\n\n\nclass Flex(AutotoolsPackage):\n    \"\"\"Flex is a tool for generating scanners.\"\"\"\n\n    homepage = \"https://github.com/westes/flex\"\n    url = \"https://github.com/westes/flex/releases/download/v2.6.1/flex-2.6.1.tar.gz\"\n\n    version('2.6.3', 'a5f65570cd9107ec8a8ec88f17b31bb1')\n    # Problematic version:\n    # See issue #2554; https://github.com/westes/flex/issues/113\n    # version('2.6.2', 'cc6d76c333db7653d5caf423a3335239')\n    version('2.6.1', '05bcd8fb629e0ae130311e8a6106fa82')\n    version('2.6.0', '760be2ee9433e822b6eb65318311c19d')\n    version('2.5.39', '5865e76ac69c05699f476515592750d7')\n\n    variant('lex', default=True,\n            description=\"Provide symlinks for lex and libl\")\n\n    depends_on('bison',         type='build')\n    depends_on('gettext@0.19:', type='build')\n    depends_on('help2man',      type='build')\n\n    # Older tarballs don't come with a configure script\n    depends_on('m4',       type='build')\n    depends_on('autoconf', type='build', when='@:2.6.0')\n    depends_on('automake', type='build', when='@:2.6.0')\n    depends_on('libtool',  type='build', when='@:2.6.0')\n\n    def url_for_version(self, version):\n        url = \"https://github.com/westes/flex\"\n        if version >= Version('2.6.1'):\n            url += \"/releases/download/v{0}/flex-{0}.tar.gz\".format(version)\n        elif version == Version('2.6.0'):\n            url += \"/archive/v{0}.tar.gz\".format(version)\n        elif version >= Version('2.5.37'):\n            url += \"/archive/flex-{0}.tar.gz\".format(version)\n        else:\n            url += \"/archive/flex-{0}.tar.gz\".format(version.dashed)\n\n        return url\n\n    @run_after('install')\n    def symlink_lex(self):\n        if self.spec.satisfies('+lex'):\n            dso = dso_suffix\n            for dir, flex, lex in \\\n                    ((self.prefix.bin, 'flex', 'lex'),\n                     (self.prefix.lib, 'libfl.a', 'libl.a'),\n                     (self.prefix.lib, 'libfl.' + dso, 'libl.' + dso)):\n                with working_dir(dir):\n                    if (os.path.isfile(flex) and not\n                            os.path.lexists(lex)):\n                        symlink(flex, lex)\n", "path": "var/spack/repos/builtin/packages/flex/package.py"}]}