Skip to content

Commit

Permalink
Update run.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MagicalLas committed Nov 7, 2019
1 parent b218969 commit 5f4f0b8
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions poetry/console/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ def run_script(self, script, args):
module, callable_ = script.split(":")

src_in_sys_path = "sys.path.append('src'); " if self._module.is_in_src() else ""
fixed_args = list(map(self.__fix_args_quotation_mark, args))

cmd = ["python", "-c"]

cmd += [
"import sys; "
"from importlib import import_module; "
"sys.argv = {!r}; {}"
"import_module('{}').{}()".format(args, src_in_sys_path, module, callable_)
"import_module('{}').{}()".format(fixed_args, src_in_sys_path, module, callable_)
]

return self.env.execute(*cmd)
Expand All @@ -57,4 +58,23 @@ def _module(self):
path = poetry.file.parent
module = Module(package.name, path.as_posix(), package.packages)

return module
def merge_application_definition(self, merge_args=True):
if self._application is None or (
self._application_definition_merged
and (self._application_definition_merged_with_args or not merge_args)
):
return

if merge_args:
current_arguments = self._definition.get_arguments()
self._definition.set_arguments(
self._application.get_definition().get_arguments()
)
self._definition.add_arguments(current_arguments)

self._application_definition_merged = True
if merge_args:
self._application_definition_merged_with_args = True

def __fix_args_quotation_mark(self, args):
return str(args).replace('"', '\\""')

0 comments on commit 5f4f0b8

Please sign in to comment.