prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  poetry script: unable to find entry point module, if package resides in src
  `poetry script` is unable to find the entry point module in `src`
  
  ```
  [NameError]
  name 'Module' is not defined
  script <script-name> [<args>]...
  ```
  
  </issue>
  <code>
  [start of poetry/console/commands/script.py]
  1 import sys
  2 
  3 from .venv_command import VenvCommand
  4 
  5 
  6 class ScriptCommand(VenvCommand):
  7     """
  8     Executes a script defined in <comment>pyproject.toml</comment>
  9 
  10     script
  11         { script-name : The name of the script to execute }
  12         { args?* : The command and arguments/options to pass to the script. }
  13     """
  14 
  15     def handle(self):
  16         script = self.argument('script-name')
  17         argv = [script] + self.argument('args')
  18 
  19         scripts = self.poetry.local_config.get('scripts')
  20         if not scripts:
  21             raise RuntimeError('No scripts defined in pyproject.toml')
  22 
  23         if script not in scripts:
  24             raise ValueError('Script {} is not defined'.format(script))
  25 
  26         module, callable_ = scripts[script].split(':')
  27 
  28         cmd = ['python', '-c']
  29 
  30         cmd += [
  31             '"import sys; '
  32             'from importlib import import_module; '
  33             'sys.argv = {!r}; '
  34             'import_module(\'{}\').{}()"'.format(
  35                argv, module, callable_
  36             )
  37         ]
  38 
  39         self.venv.run(*cmd, shell=True, call=True)
  40 
  41     def merge_application_definition(self, merge_args=True):
  42         if self._application is None \
  43                 or (self._application_definition_merged
  44                     and (self._application_definition_merged_with_args or not merge_args)):
  45             return
  46 
  47         if merge_args:
  48             current_arguments = self._definition.get_arguments()
  49             self._definition.set_arguments(self._application.get_definition().get_arguments())
  50             self._definition.add_arguments(current_arguments)
  51 
  52         self._application_definition_merged = True
  53         if merge_args:
  54             self._application_definition_merged_with_args = True
  55
  [end of poetry/console/commands/script.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/poetry/console/commands/script.py b/poetry/console/commands/script.py
  --- a/poetry/console/commands/script.py
  +++ b/poetry/console/commands/script.py
  @@ -1,5 +1,6 @@
   import sys
   
  +from ...masonry.utils.module import Module
   from .venv_command import VenvCommand
   
   
  @@ -25,19 +26,32 @@
   
           module, callable_ = scripts[script].split(':')
   
  +        src_in_sys_path = 'sys.path.append(\'src\'); '\
  +            if self._module.is_in_src() else ''
  +
           cmd = ['python', '-c']
   
           cmd += [
               '"import sys; '
               'from importlib import import_module; '
  -            'sys.argv = {!r}; '
  +            'sys.argv = {!r}; {}'
               'import_module(\'{}\').{}()"'.format(
  -               argv, module, callable_
  +               argv, src_in_sys_path, module, callable_
               )
           ]
   
           self.venv.run(*cmd, shell=True, call=True)
   
  +    @property
  +    def _module(self):
  +        poetry = self.poetry
  +        package = poetry.package
  +        path = poetry.file.parent
  +        module = Module(
  +            package.name, path.as_posix()
  +        )
  +        return module
  +
       def merge_application_definition(self, merge_args=True):
           if self._application is None \
                   or (self._application_definition_merged
  
verification_info: {"golden_diff": "diff --git a/poetry/console/commands/script.py b/poetry/console/commands/script.py\n--- a/poetry/console/commands/script.py\n+++ b/poetry/console/commands/script.py\n@@ -1,5 +1,6 @@\n import sys\n \n+from ...masonry.utils.module import Module\n from .venv_command import VenvCommand\n \n \n@@ -25,19 +26,32 @@\n \n         module, callable_ = scripts[script].split(':')\n \n+        src_in_sys_path = 'sys.path.append(\\'src\\'); '\\\n+            if self._module.is_in_src() else ''\n+\n         cmd = ['python', '-c']\n \n         cmd += [\n             '\"import sys; '\n             'from importlib import import_module; '\n-            'sys.argv = {!r}; '\n+            'sys.argv = {!r}; {}'\n             'import_module(\\'{}\\').{}()\"'.format(\n-               argv, module, callable_\n+               argv, src_in_sys_path, module, callable_\n             )\n         ]\n \n         self.venv.run(*cmd, shell=True, call=True)\n \n+    @property\n+    def _module(self):\n+        poetry = self.poetry\n+        package = poetry.package\n+        path = poetry.file.parent\n+        module = Module(\n+            package.name, path.as_posix()\n+        )\n+        return module\n+\n     def merge_application_definition(self, merge_args=True):\n         if self._application is None \\\n                 or (self._application_definition_merged\n", "issue": "poetry script: unable to find entry point module, if package resides in src\n`poetry script` is unable to find the entry point module in `src`\r\n\r\n```\r\n[NameError]\r\nname 'Module' is not defined\r\nscript <script-name> [<args>]...\r\n```\n", "before_files": [{"content": "import sys\n\nfrom .venv_command import VenvCommand\n\n\nclass ScriptCommand(VenvCommand):\n    \"\"\"\n    Executes a script defined in <comment>pyproject.toml</comment>\n\n    script\n        { script-name : The name of the script to execute }\n        { args?* : The command and arguments/options to pass to the script. }\n    \"\"\"\n\n    def handle(self):\n        script = self.argument('script-name')\n        argv = [script] + self.argument('args')\n\n        scripts = self.poetry.local_config.get('scripts')\n        if not scripts:\n            raise RuntimeError('No scripts defined in pyproject.toml')\n\n        if script not in scripts:\n            raise ValueError('Script {} is not defined'.format(script))\n\n        module, callable_ = scripts[script].split(':')\n\n        cmd = ['python', '-c']\n\n        cmd += [\n            '\"import sys; '\n            'from importlib import import_module; '\n            'sys.argv = {!r}; '\n            'import_module(\\'{}\\').{}()\"'.format(\n               argv, module, callable_\n            )\n        ]\n\n        self.venv.run(*cmd, shell=True, call=True)\n\n    def merge_application_definition(self, merge_args=True):\n        if self._application is None \\\n                or (self._application_definition_merged\n                    and (self._application_definition_merged_with_args or not merge_args)):\n            return\n\n        if merge_args:\n            current_arguments = self._definition.get_arguments()\n            self._definition.set_arguments(self._application.get_definition().get_arguments())\n            self._definition.add_arguments(current_arguments)\n\n        self._application_definition_merged = True\n        if merge_args:\n            self._application_definition_merged_with_args = True\n", "path": "poetry/console/commands/script.py"}]}