Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relay exit code in poetry run #2904

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion poetry/console/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def run_script(self, script: Union[str, dict], args: str) -> Any:
"import sys; "
"from importlib import import_module; "
"sys.argv = {!r}; {}"
"import_module('{}').{}()".format(args, src_in_sys_path, module, callable_)
"sys.exit(import_module('{}').{}())".format(args, src_in_sys_path, module, callable_)
]

return self.env.execute(*cmd)
Empty file.
9 changes: 9 additions & 0 deletions tests/fixtures/project_with_scripts/project/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import sys


def relay(args=None):
args = args or sys.argv[1:]
print("entered relay")
print(args)
exit_code = args[0]
return exit_code
15 changes: 15 additions & 0 deletions tests/fixtures/project_with_scripts/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tool.poetry]
name = "project-with-scripts"
version = "1.2.3"
description = "This is a description"
authors = ["Your Name <you@example.com>"]
license = "MIT"
packages = [{include = "project"}]

[tool.poetry.dependencies]
python = "*"

[tool.poetry.dev-dependencies]

[tool.poetry.scripts]
relay = "project.main:relay"