uv/docs/reference
Trevor Manz 585456a607
feat: Support remote scripts with uv run (#6375)
<!--
Thank you for contributing to uv! To help us out with reviewing, please
consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

First off, congratulations on the 0.3 release! The PEP 723 standalone
scripts support is awesome, and I can already imagine a long tail of
little scripts of my own that would benefit from this functionality.

## Background

I really like the Deno CLI's support for running and installing remote
scripts.

```
deno run <url>
```

```
deno install --name foo <url>
```

I can see parallels with `uv run` and `uvx`. After mentioning this on
Discord, @zanieb suggested I could take a stab at a PR to implement
similar functionality for uv.

## Summary

This PR attempts to add support for executing remote standalone scripts
directly with `uv run`. While this is already possible by downloading
the script (i.e., via curl/wget) and then using uv run, having direct
support would be convenient.

The proposed functionality is:

```sh
uv run <url>
```

Another addition/alternative could be to support running scripts via
stdin:

```sh
curl -sL <url> | uv run -
```

But that is not implemented in this PR.

## Test Plan

I noticed that GitHub and `files.pythonhosted.org` URLs are used in some
of the tests. I've created a personal [GitHub
Gist](https://gist.github.com/manzt/cb24f3066c32983672025b04b9f98d1f)
with the example from PEP 723 for now to test this functionality.

~However, I couldn't figure out how to get the `with_snapshot` config
filter to filter out the tempfile path, so the test is currently
failing. Any assistance with this would be appreciated.~

## Notes

I'm not totally pleased with the implementation of this PR. I think it
would be better to handle the case earlier (and probably reuse the
cache), and avoid mutation, but since run command requires a local path
this was the simplest implementation I could come up with.

I know that performance is paramount with uv so I totally understand if
this requires a different approach or something more explicit to avoid
"inferring" the path. I'm just taking this as an opportunity to learn a
little more Rust and acquaint myself with the code base. cheers!

---------

Co-authored-by: Andrew Gallant <jamslam@gmail.com>
2024-10-10 14:10:17 -04:00
..
benchmarks.md Add link to benchmarks in documentation (#6257) 2024-08-20 12:54:46 -04:00
cli.md feat: Support remote scripts with uv run (#6375) 2024-10-10 14:10:17 -04:00
index.md Disable collapsible navigation in the documentation (#5674) 2024-08-16 18:09:21 -05:00
platforms.md Add 3.13 support to the platform reference (#7971) 2024-10-07 12:06:43 -05:00
resolver-internals.md Fix up reference to environment markers in resolver reference (#6773) 2024-08-28 18:00:43 -04:00
settings.md Implement trusted publishing (#7548) 2024-09-24 16:07:20 +00:00
versioning.md Move some documents to relevant sections (#5968) 2024-08-09 17:31:10 +00:00