prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Problems while importing scapy on some environments (e.g. Eclipse, some peculiarly configured Windows boxes etc.) 
  Scapy Version: v2.3.3-1008
  System: Windows10
  Python Version: 2.7.14
  
  Updated (closed) issue: [#1029](https://github.com/secdev/scapy/issues/1029l)
  
  File: scapy/\_\_init\_\_.py
  
  There are a problems of using master/scapy  on some environments  like e.g. Eclipse, some peculiarly configured Windows - mostly old - boxes etc.)
  When scapy is started/imported and git is installed, some console windows appears while _version() is performed.
  Also this issue has impact on decrease of scapy launch/import speed.
  
  Problem (unexpected lauching of git, git bash console window appearing) exist because of
  condition in _version_from_git_describe() does not works as expected on my/our boxes (old Windows?, old buggy Python 2.7.8 where '/' path separator is not treated in the same way as '\\'? nevermind...)
  
  Simple fix below fully avoids our problems:
  
  ```
  diff --git a/scapy/__init__.py b/scapy/__init__.py
  index 4893a9f..4f38578 100644
  --- a/scapy/__init__.py
  +++ b/scapy/__init__.py
  @@ -38,7 +38,7 @@ def _version_from_git_describe():
           >>> _version_from_git_describe()
           '2.3.2.dev346'
       """
  -    if not os.path.isdir(os.path.join(_SCAPY_PKG_DIR, '../.git')):
  +    if not os.path.isdir(os.path.join(os.path.dirname(_SCAPY_PKG_DIR), '.git')):
           raise ValueError('not in scapy git repo')
   
       p = subprocess.Popen(['git', 'describe', '--always'], cwd=_SCAPY_PKG_DIR,
  ```
  
  Thanks,
  Adam Karpierz
  
  
  </issue>
  <code>
  [start of scapy/__init__.py]
  1 ## This file is part of Scapy
  2 ## See http://www.secdev.org/projects/scapy for more informations
  3 ## Copyright (C) Philippe Biondi <phil@secdev.org>
  4 ## This program is published under a GPLv2 license
  5 
  6 """
  7 Scapy: create, send, sniff, dissect and manipulate network packets.
  8 
  9 Usable either from an interactive console or as a Python library.
  10 http://www.secdev.org/projects/scapy
  11 """
  12 
  13 import os
  14 import re
  15 import subprocess
  16 
  17 
  18 _SCAPY_PKG_DIR = os.path.dirname(__file__)
  19 
  20 def _version_from_git_describe():
  21     """
  22     Read the version from ``git describe``. It returns the latest tag with an
  23     optional suffix if the current directory is not exactly on the tag.
  24 
  25     Example::
  26 
  27         $ git describe --always
  28         v2.3.2-346-g164a52c075c8
  29 
  30     The tag prefix (``v``) and the git commit sha1 (``-g164a52c075c8``) are
  31     removed if present.
  32 
  33     If the current directory is not exactly on the tag, a ``.devN`` suffix is
  34     appended where N is the number of commits made after the last tag.
  35 
  36     Example::
  37 
  38         >>> _version_from_git_describe()
  39         '2.3.2.dev346'
  40     """
  41     if not os.path.isdir(os.path.join(_SCAPY_PKG_DIR, '../.git')):
  42         raise ValueError('not in scapy git repo')
  43 
  44     p = subprocess.Popen(['git', 'describe', '--always'], cwd=_SCAPY_PKG_DIR,
  45                          stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  46 
  47     out, err = p.communicate()
  48 
  49     if p.returncode == 0:
  50         tag = out.decode().strip()
  51         match = re.match('^v?(.+?)-(\\d+)-g[a-f0-9]+$', tag)
  52         if match:
  53             # remove the 'v' prefix and add a '.devN' suffix
  54             return '%s.dev%s' % (match.group(1), match.group(2))
  55         else:
  56             # just remove the 'v' prefix
  57             return re.sub('^v', '', tag)
  58     else:
  59         raise subprocess.CalledProcessError(p.returncode, err)
  60 
  61 def _version():
  62     version_file = os.path.join(_SCAPY_PKG_DIR, 'VERSION')
  63     try:
  64         tag = _version_from_git_describe()
  65         # successfully read the tag from git, write it in VERSION for
  66         # installation and/or archive generation.
  67         with open(version_file, 'w') as f:
  68             f.write(tag)
  69         return tag
  70     except:
  71         # failed to read the tag from git, try to read it from a VERSION file
  72         try:
  73             with open(version_file, 'r') as f:
  74                 tag = f.read()
  75             return tag
  76         except:
  77             # Rely on git archive "export-subst" git attribute.
  78             # See 'man gitattributes' for more details.
  79             git_archive_id = '$Format:%h %d$'
  80             sha1 = git_archive_id.strip().split()[0]
  81             match = re.search('tag:(\\S+)', git_archive_id)
  82             if match:
  83                 return "git-archive.dev" + match.group(1)
  84             elif sha1:
  85                 return "git-archive.dev" + sha1
  86             else:
  87                 return 'unknown.version'
  88 
  89 VERSION = _version()
  90 
  91 if __name__ == "__main__":
  92     from scapy.main import interact
  93     interact()
  94
  [end of scapy/__init__.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/scapy/__init__.py b/scapy/__init__.py
  --- a/scapy/__init__.py
  +++ b/scapy/__init__.py
  @@ -38,7 +38,7 @@
           >>> _version_from_git_describe()
           '2.3.2.dev346'
       """
  -    if not os.path.isdir(os.path.join(_SCAPY_PKG_DIR, '../.git')):
  +    if not os.path.isdir(os.path.join(os.path.dirname(_SCAPY_PKG_DIR), '.git')):
           raise ValueError('not in scapy git repo')
   
       p = subprocess.Popen(['git', 'describe', '--always'], cwd=_SCAPY_PKG_DIR,
  
verification_info: {"golden_diff": "diff --git a/scapy/__init__.py b/scapy/__init__.py\n--- a/scapy/__init__.py\n+++ b/scapy/__init__.py\n@@ -38,7 +38,7 @@\n         >>> _version_from_git_describe()\n         '2.3.2.dev346'\n     \"\"\"\n-    if not os.path.isdir(os.path.join(_SCAPY_PKG_DIR, '../.git')):\n+    if not os.path.isdir(os.path.join(os.path.dirname(_SCAPY_PKG_DIR), '.git')):\n         raise ValueError('not in scapy git repo')\n \n     p = subprocess.Popen(['git', 'describe', '--always'], cwd=_SCAPY_PKG_DIR,\n", "issue": "Problems while importing scapy on some environments (e.g. Eclipse, some peculiarly configured Windows boxes etc.) \nScapy Version: v2.3.3-1008\r\nSystem: Windows10\r\nPython Version: 2.7.14\r\n\r\nUpdated (closed) issue: [#1029](https://github.com/secdev/scapy/issues/1029l)\r\n\r\nFile: scapy/\\_\\_init\\_\\_.py\r\n\r\nThere are a problems of using master/scapy  on some environments  like e.g. Eclipse, some peculiarly configured Windows - mostly old - boxes etc.)\r\nWhen scapy is started/imported and git is installed, some console windows appears while _version() is performed.\r\nAlso this issue has impact on decrease of scapy launch/import speed.\r\n\r\nProblem (unexpected lauching of git, git bash console window appearing) exist because of\r\ncondition in _version_from_git_describe() does not works as expected on my/our boxes (old Windows?, old buggy Python 2.7.8 where '/' path separator is not treated in the same way as '\\\\'? nevermind...)\r\n\r\nSimple fix below fully avoids our problems:\r\n\r\n```\r\ndiff --git a/scapy/__init__.py b/scapy/__init__.py\r\nindex 4893a9f..4f38578 100644\r\n--- a/scapy/__init__.py\r\n+++ b/scapy/__init__.py\r\n@@ -38,7 +38,7 @@ def _version_from_git_describe():\r\n         >>> _version_from_git_describe()\r\n         '2.3.2.dev346'\r\n     \"\"\"\r\n-    if not os.path.isdir(os.path.join(_SCAPY_PKG_DIR, '../.git')):\r\n+    if not os.path.isdir(os.path.join(os.path.dirname(_SCAPY_PKG_DIR), '.git')):\r\n         raise ValueError('not in scapy git repo')\r\n \r\n     p = subprocess.Popen(['git', 'describe', '--always'], cwd=_SCAPY_PKG_DIR,\r\n```\r\n\r\nThanks,\r\nAdam Karpierz\r\n\n", "before_files": [{"content": "## This file is part of Scapy\n## See http://www.secdev.org/projects/scapy for more informations\n## Copyright (C) Philippe Biondi <phil@secdev.org>\n## This program is published under a GPLv2 license\n\n\"\"\"\nScapy: create, send, sniff, dissect and manipulate network packets.\n\nUsable either from an interactive console or as a Python library.\nhttp://www.secdev.org/projects/scapy\n\"\"\"\n\nimport os\nimport re\nimport subprocess\n\n\n_SCAPY_PKG_DIR = os.path.dirname(__file__)\n\ndef _version_from_git_describe():\n    \"\"\"\n    Read the version from ``git describe``. It returns the latest tag with an\n    optional suffix if the current directory is not exactly on the tag.\n\n    Example::\n\n        $ git describe --always\n        v2.3.2-346-g164a52c075c8\n\n    The tag prefix (``v``) and the git commit sha1 (``-g164a52c075c8``) are\n    removed if present.\n\n    If the current directory is not exactly on the tag, a ``.devN`` suffix is\n    appended where N is the number of commits made after the last tag.\n\n    Example::\n\n        >>> _version_from_git_describe()\n        '2.3.2.dev346'\n    \"\"\"\n    if not os.path.isdir(os.path.join(_SCAPY_PKG_DIR, '../.git')):\n        raise ValueError('not in scapy git repo')\n\n    p = subprocess.Popen(['git', 'describe', '--always'], cwd=_SCAPY_PKG_DIR,\n                         stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\n    out, err = p.communicate()\n\n    if p.returncode == 0:\n        tag = out.decode().strip()\n        match = re.match('^v?(.+?)-(\\\\d+)-g[a-f0-9]+$', tag)\n        if match:\n            # remove the 'v' prefix and add a '.devN' suffix\n            return '%s.dev%s' % (match.group(1), match.group(2))\n        else:\n            # just remove the 'v' prefix\n            return re.sub('^v', '', tag)\n    else:\n        raise subprocess.CalledProcessError(p.returncode, err)\n\ndef _version():\n    version_file = os.path.join(_SCAPY_PKG_DIR, 'VERSION')\n    try:\n        tag = _version_from_git_describe()\n        # successfully read the tag from git, write it in VERSION for\n        # installation and/or archive generation.\n        with open(version_file, 'w') as f:\n            f.write(tag)\n        return tag\n    except:\n        # failed to read the tag from git, try to read it from a VERSION file\n        try:\n            with open(version_file, 'r') as f:\n                tag = f.read()\n            return tag\n        except:\n            # Rely on git archive \"export-subst\" git attribute.\n            # See 'man gitattributes' for more details.\n            git_archive_id = '$Format:%h %d$'\n            sha1 = git_archive_id.strip().split()[0]\n            match = re.search('tag:(\\\\S+)', git_archive_id)\n            if match:\n                return \"git-archive.dev\" + match.group(1)\n            elif sha1:\n                return \"git-archive.dev\" + sha1\n            else:\n                return 'unknown.version'\n\nVERSION = _version()\n\nif __name__ == \"__main__\":\n    from scapy.main import interact\n    interact()\n", "path": "scapy/__init__.py"}]}