You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PEP-723 describes how to add comments to a script to specify what its dependencies should be similar to a pyproject.toml. The Python Packaging Docs give more information and include future updates to the spec.
example.py:
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "requests<3",
# "rich",
# ]
# ///
import requests
from rich.pretty import pprint
resp = requests.get("https://peps.python.org/api/peps.json")
data = resp.json()
pprint([(k, v["title"]) for k, v in data.items()][:10])
uv supports running the above script directly with uv run example.py. The downside with this is that each time you run it with uv it will make calls to the network to ensure its on the correct versions of the packages each time. Fine for development, less so for production use cases.
It would be nice if shiv could do something similar like shiv --inline-script example.py --output-file example to make a portable script that needs no network requirement.
The text was updated successfully, but these errors were encountered:
PEP-723 describes how to add comments to a script to specify what its dependencies should be similar to a
pyproject.toml
. The Python Packaging Docs give more information and include future updates to the spec.example.py
:uv supports running the above script directly with
uv run example.py
. The downside with this is that each time you run it with uv it will make calls to the network to ensure its on the correct versions of the packages each time. Fine for development, less so for production use cases.It would be nice if
shiv
could do something similar likeshiv --inline-script example.py --output-file example
to make a portable script that needs no network requirement.The text was updated successfully, but these errors were encountered: