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

uv run with stdin #6467

Closed
billy-doyle opened this issue Aug 22, 2024 · 3 comments · Fixed by #6481
Closed

uv run with stdin #6467

billy-doyle opened this issue Aug 22, 2024 · 3 comments · Fixed by #6481
Assignees
Labels
enhancement New feature or improvement to existing functionality help wanted Contribution especially encouraged

Comments

@billy-doyle
Copy link
Contributor

billy-doyle commented Aug 22, 2024

inspired by https://docs.astral.sh/uv/guides/scripts/#declaring-script-dependencies and some tweets being able to just send someone a command and boom they can run a py script

MRE:

billy@sa ~/uv_eof % uv run - <<EOF
print("hello world")
EOF
error: Failed to spawn: `-`
  Caused by: No such file or directory (os error 2)

Short dash(-) here represents stdin, similar to how k8s allows:

kubectl apply -f - <<EOF
apiVersion: v1
kind: ServiceAccount
metadata:
  name: kubectl-actions
  namespace: my-v2-restore
EOF

Some more details and how kubectl does it (in go tho ofc) https://stackoverflow.com/a/72168173/9992341 and https://github.com/kubernetes/cli-runtime/blob/v0.21.0/pkg/resource/builder.go#L245

basically turns any snippet someone else wants to run with

billy@sa ~/uv_eof % curl -LsSf https://astral.sh/uv/install.sh | sh && uv run - <<EOF               
print("hello world")
EOF
@zanieb
Copy link
Member

zanieb commented Aug 22, 2024

Yeah, we can support this.

@zanieb zanieb added enhancement New feature or improvement to existing functionality help wanted Contribution especially encouraged labels Aug 22, 2024
@charliermarsh
Copy link
Member

This should be not-too-difficult to add if anyone is looking for a contribution :)

@charliermarsh charliermarsh self-assigned this Aug 23, 2024
@charliermarsh
Copy link
Member

I'm gonna do this as a break from hard issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement to existing functionality help wanted Contribution especially encouraged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants