Skip to content

Commit 9e1a33b

Browse files
authored
Add example PEP 723 Inline script metadata (#266)
1 parent 61f9179 commit 9e1a33b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,25 @@ The proper [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) line for Pyth
403403
#!/usr/bin/env python3
404404
```
405405

406+
If your script has external dependencies hosted on PyPI, add
407+
[PEP 723 Inline script metadata](https://peps.python.org/pep-0723/) and a `uv run` shebang line
408+
to allow easy execution on macOS and Linux.
409+
410+
```py
411+
#!/usr/bin/env -S uv run --script
412+
# /// script
413+
# requires-python = ">=3.13"
414+
# dependencies = [
415+
# "httpx>=0.28.1",
416+
# ]
417+
# ///
418+
419+
import httpx
420+
print(httpx.get("https://example.com").text)
421+
```
422+
423+
On Windows, remove the `-S` from the shebang and execute the script using the `py` launcher.
424+
406425
## Package Dependency Tree
407426

408427
`uv tree` is a command for listing installed packages in the form of a dependency tree. For large

0 commit comments

Comments
 (0)