Commit 161b19cb by Wagner Macedo Committed by GitHub

poetry run: deprecate uninstalled entry points (#7606)

parent 7585c375
......@@ -63,6 +63,9 @@ class RunCommand(EnvCommand):
if script_path.exists():
args = [str(script_path), *args[1:]]
break
else:
# If we reach this point, the script is not installed
self._warning_not_installed_script(args[0])
if isinstance(script, dict):
script = script["callable"]
......@@ -81,3 +84,14 @@ class RunCommand(EnvCommand):
]
return self.env.execute(*cmd)
def _warning_not_installed_script(self, script: str) -> None:
message = f"""\
Warning: '{script}' is an entry point defined in pyproject.toml, but it's not \
installed as a script. You may get improper `sys.argv[0]`.
The support to run uninstalled scripts will be removed in a future release.
Run `poetry install` to resolve and get rid of this message.
"""
self.line_error(message, style="warning")
......@@ -180,3 +180,17 @@ def test_run_script_sys_argv0(
)
argv1 = "absolute" if installed_script else "relative"
assert tester.execute(f"check-argv0 {argv1}") == 0
if installed_script:
expected_message = ""
else:
expected_message = """\
Warning: 'check-argv0' is an entry point defined in pyproject.toml, but it's not \
installed as a script. You may get improper `sys.argv[0]`.
The support to run uninstalled scripts will be removed in a future release.
Run `poetry install` to resolve and get rid of this message.
"""
assert tester.io.fetch_error() == expected_message
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment