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

Composite script with multiple invocations triggers recursive script error #2829

Closed
1 task done
tachylatus opened this issue Apr 17, 2024 · 2 comments · Fixed by #2830
Closed
1 task done

Composite script with multiple invocations triggers recursive script error #2829

tachylatus opened this issue Apr 17, 2024 · 2 comments · Fixed by #2830
Labels
🐛 bug Something isn't working

Comments

@tachylatus
Copy link
Contributor

  • I have searched the issue tracker and believe that this is not a duplicate.

Make sure you run commands with -v flag before pasting the output.

Steps to reproduce

  • Script snippet for pyproject.toml:
    [tool.pdm.scripts]
    foo.composite = ["bar hello", "bar world"]
    bar.composite = ["baz {args}"]
    baz.shell = "echo {args}"
    
  • Run the "foo" script:
    pdm run -v foo

Actual behavior

Running <task foo>: []
Running <task bar>: ['hello']
Running <task baz>: echo hello
hello
[PdmUsageError]: Script bar is recursive.

Exit code: 1

Expected behavior

Running <task foo>: []
Running <task bar>: ['hello']
Running <task baz>: echo hello
hello
Running <task bar>: ['world']
Running <task baz>: echo world
world

Exit code: 0

Environment Information

PDM version:
  2.14.0
Python Interpreter:
  /redacted/.venv/bin/python (3.12)
Project Root:
  /redacted
Local Packages:
  
{
  "implementation_name": "cpython",
  "implementation_version": "3.12.0",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "5.15.133.1-microsoft-standard-WSL2",
  "platform_system": "Linux",
  "platform_version": "#1 SMP Thu Oct 5 21:02:42 UTC 2023",
  "python_full_version": "3.12.0",
  "platform_python_implementation": "CPython",
  "python_version": "3.12",
  "sys_platform": "linux"
}
@pawamoy
Copy link
Sponsor Contributor

pawamoy commented Apr 17, 2024

IMO PDM shouldn't prevent running scripts if they call themselves recursively. The stop condition could be based on the file-system (presence/absence of files). If they reach the recursion limit of Python, I'd call this a user error.

Also yes, the logic for detecting recursion is currently flawed.

@tachylatus
Copy link
Contributor Author

Workaround

When invoking a nested composite script, prepend the command with {pdm} run.

Example:

[tool.pdm.scripts]
foo.composite = ["{pdm} run bar hello", "{pdm} run bar world"]
bar.composite = ["baz {args}"]
baz.shell = "echo {args}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants