Last active
March 28, 2025 11:24
-
-
Save ritesh/81d4f6df8bf6d59385064e5d4fc16f75 to your computer and use it in GitHub Desktop.
A chmod+x'-able Python script, useful for code that lives in a single file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env -S uv run --script | |
# /// script | |
# requires-python = ">=3.13" | |
# dependencies = [ | |
# "httpx>=0.28.1", | |
# ] | |
# /// | |
# | |
# Your python script is now chmod +x -able like a bash script with the above hashbang line. Magic! | |
# The above is possible due to https://peps.python.org/pep-0723/ - read Dave's blog (linked below) for more details | |
# You do need the uv tool installed which you can do by running | |
# curl -LsSf https://astral.sh/uv/install.sh | sh | |
# If you're paranoid about running random install.sh scripts from the internet (and you should be!) | |
# inspect what it does by running | |
# curl -LsSf https://astral.sh/uv/install.sh | less | |
# Wouldn't recommend installing uv via pipx as i'm not sure there's any advantage to it. uv replaces pip/pipx/venv etc. | |
# Read more here: https://thisdavej.com/share-python-scripts-like-a-pro-uv-and-pep-723-for-easy-deployment/ | |
import httpx | |
import json | |
import argparse | |
import asyncio | |
import textwrap | |
import os |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment