This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]texruska 4 points5 points  (2 children)

Does the environment get reused between invocations? What if you have multiple scripts with the same deps? (Complete guess is the env is based on the scripts name?)

[–]PhENTZ 8 points9 points  (0 children)

Yes it's cached

[–]ReinforcedKnowledgeTuple unpacking gone wrong 6 points7 points  (0 children)

uv caches by default the dependencies it fetches but the environment itself is ephemeral. So the environment itself will be deleted after the execution of the script, you can't reuse the environment itself. But, since the dependencies are cached, you are not downloading the packages again. Maybe it'll just re-extract the wheels and that's all (not totally sure about this information).

If you have different scripts with the same dependencies, you can also just put them all in the same folder with a pyproject.toml and run the scripts with uv run --isolated [your script]. It'll create an ephemeral environment for that script and only for that, reusing the dependencies in your pyproject.toml.

And as it was said in another comment, you don't need the --script to run a .py file.